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

[JS] How to get object variable of added polygon?

Contributor ,
Dec 20, 2016 Dec 20, 2016

Copy link to clipboard

Copied

var AddPolygon = app.activeWindow.activePage.polygons.add(

    fillColor:"Black", 

}).paths[0].entirePath = [[0,0], [10,0], [10,10],[0,10]]; 

alert( AddPolygon );

Hi

I want to get polygon object variable.

But, polygon add function return values have coordinates.

How to get Polygon object variable?

Thanks in advance.

TOPICS
Scripting

Views

459

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

People's Champ , Dec 20, 2016 Dec 20, 2016

That's because you are editing the object property at the declaration stage thus returning the value of the property.

var AddPolygon = app.activeWindow.activePage.polygons.add( 

{   

    fillColor:"Black",   

});

AddPolygon.paths[0].entirePath = [[0,0], [10,0], [10,10],[0,10]];   

 

alert( AddPolygon );

Votes

Translate

Translate
People's Champ ,
Dec 20, 2016 Dec 20, 2016

Copy link to clipboard

Copied

That's because you are editing the object property at the declaration stage thus returning the value of the property.

var AddPolygon = app.activeWindow.activePage.polygons.add( 

{   

    fillColor:"Black",   

});

AddPolygon.paths[0].entirePath = [[0,0], [10,0], [10,10],[0,10]];   

 

alert( AddPolygon );

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
People's Champ ,
Dec 20, 2016 Dec 20, 2016

Copy link to clipboard

Copied

By the way what's the point of declaring a polygon which turns to be a rectangle ?

Something like this would have outputted the same result:

var AddShape = app.activeWindow.activePage.rectangles.add( 

{   

    fillColor:"Black",   

  geometricBounds:[0,0,10,10],

});

 

alert( AddShape );

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
Contributor ,
Dec 20, 2016 Dec 20, 2016

Copy link to clipboard

Copied

LATEST

It is just sample coordinates..

Thank you

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