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

How can add a parallelogram shape by Script?

Enthusiast ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

to add Rectangle i using:

var oRec= oDocument.rectangles.add();

But Can i setting this Rectangle to a parallelogram shape?

or

How can add a parallelogram shape by Script?

TOPICS
Scripting

Views

1.3K

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 , May 07, 2018 May 07, 2018

HI,

Would setting the shear angle get you the result you want?

oRec.shearAngle = 45;

hope this helps

Malcolm

Votes

Translate

Translate
Community Expert ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

HI,

Would setting the shear angle get you the result you want?

oRec.shearAngle = 45;

hope this helps

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
People's Champ ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

Hi,

Setting shear angle is certainly a good way to go given that you would be able to compute the angle so the final shape has the expected dimensions.

Another solution would be to set you own geometry playing with path and pathPoints Array but then you would loose editability regarding to shear angle property.

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 ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

Hi Loic,

good point. One could work with the entirePath array of an added polygon or rectangle.

Or one could move two path points of an added rectangle.

Also possible:

Combine the two ways, the one with the shearAngle and building a new polygon with entirePath array.

Example:

var doc = app.documents[0];

var rect = doc.rectangles.add({geometricBounds : [0,0,100,100] ,fillColor : doc.colors.itemByName("Magenta") });

rect.shearAngle = 10;

var polygon = doc.polygons.add({fillColor : doc.colors.itemByName("Yellow")});

polygon.paths[0].entirePath = rect.paths[0].entirePath;

Rectangle and polygon are two distinct objects. And it's not only the fill color.

The rectangle is transformed, the polygon is not transformed:

Square-vs-Polygon-1.png

Square-vs-Polygon-2.png

Depending on what you want you could remove the rectangle.

Regards,
Uwe

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 ,
May 07, 2018 May 07, 2018

Copy link to clipboard

Copied

LATEST

You'll see the difference of the two construction methods more easily if you fill the objects with the same image.

In the example below I set the value for shearAngle to 45 so that this effect is better visible:

Square-vs-Polygon-3.png

Square-vs-Polygon-4.png

Regards,
Uwe

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