• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using move with Rectangle

New Here ,
Jul 16, 2020 Jul 16, 2020

Copy link to clipboard

Copied

Hello,

I am working on a script that adjusts a rectangle graphic based on the size of a shoe. So based on the size of shoe graphics moves and is resized. My question is when I use the move method can i move it from rectangle center or other location of the rectangle. Seems default is top left corner. Below is the code!

 

case '13':
myPageItems=app.documents.item(0).pages.item(i);
//UnHidea Flag Rectangle Frame
try {
myRect=myPageItems.rectangles.itemByName("frmFLAG-LT");
myRect.move([138.5,263.4]);//[X,Y]293.2
//I resize the Image frame based on calculations made in excel file--> LindorFrameCalc
myRect.resize(CoordinateSpaces.innerCoordinates,AnchorPoint.TOP_LEFT_ANCHOR,ResizeMethods.multiplyingCurrentDimensionsBy,[1.27,1.27]);
myRect.fit(FitOptions.CONTENT_TO_FRAME);
myRect.visible=true;
}
catch (e) { $.write("Error Flag LEFT"+ e +"\u000D");}
break;

 

Thanks.

wlaflamme

TOPICS
Scripting

Views

424

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 17, 2020 Jul 17, 2020

Hi William,

indeed, a rectangle has no propertyAnchorPoint.CENTER_ANCHOR.

Therefore the error.

 

BarlaeDC suggested something like that:

 

var myRect = app.selection[0];

myRect.resize
(
	CoordinateSpaces.innerCoordinates,
	AnchorPoint.CENTER_ANCHOR,
	ResizeMethods.multiplyingCurrentDimensionsBy,
	[1.27,1.27]
);

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate
Community Expert ,
Jul 16, 2020 Jul 16, 2020

Copy link to clipboard

Copied

Hi,

 

Just change this AnchorPoint.TOP_LEFT_ANCHOR to any one of these.

 

AnchorPoint.BOTTOM_CENTER_ANCHOR

AnchorPoint.BOTTOM_LEFT_ANCHOR

AnchorPoint.BOTTOM_RIGHT_ANCHOR

AnchorPoint.CENTER_ANCHOR

AnchorPoint.LEFT_CENTER_ANCHOR

AnchorPoint.RIGHT_CENTER_ANCHOR

AnchorPoint.TOP_CENTER_ANCHOR

AnchorPoint.TOP_LEFT_ANCHOR

AnchorPoint.TOP_RIGHT_ANCHOR

 

Regards

 

Malcolm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Hello,

I tried the following but I had an error:

                 try { 
                myRect=myPageItems.rectangles.itemByName("frmFLAG-LT");          
                myRect.AnchorPoint.CENTER_ANCHOR;
                myRect.move([141.8,257.5]);//[X,Y]287.5
                //I resize the Image frame based on calculations made in excel file--> LindorFrameCalc
                myRect.visible=true;
                         } 
                   catch (e) {        $.write("Error Flag LEFT-10"+ e +"\u000D");} 

 

The error said "Object does not support the property or method 'AnchorPoint'Object does not support the Property "

Did I not understand your meaning?

William

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Hi William,

indeed, a rectangle has no propertyAnchorPoint.CENTER_ANCHOR.

Therefore the error.

 

BarlaeDC suggested something like that:

 

var myRect = app.selection[0];

myRect.resize
(
	CoordinateSpaces.innerCoordinates,
	AnchorPoint.CENTER_ANCHOR,
	ResizeMethods.multiplyingCurrentDimensionsBy,
	[1.27,1.27]
);

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Hi there,

 

Thanks for reaching out. I hope your issue is resolved now. We'd appreciate if you can mark the appropriate answer correct.

If you used any other method, please share it here. It'll help other users having similar concern.

If you still have issues, let us know. We'll be happy to help.

 

Regards,

Ashutosh

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 29, 2020 Jul 29, 2020

Copy link to clipboard

Copied

I noticed in doing this method this is more of a relative move and not an absolute coordinate system. Is it possible to do an abbsolute coordinate system move rather than incremental?

 

Thanks for the help. I apologize for late reply but summer vacation.

William

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2020 Jul 29, 2020

Copy link to clipboard

Copied

LATEST

Hi williaml41168081,

are you the same William who started this thread?

 

FWIW:
Method move() has two arguments. One to argument and one by argument.

So you can move something to an [x,y] position or by [x,y] values.

 

If you want to use the second argument in the method, the by-argument, just declare the first argument as undefined.

rectangle.move( undefined , [ "20mm" , "10pt" ] );

 

Look into the DOM documentation:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Rectangle.html#d1e217191__d1e220631

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines