How to convert rectangle object using Scissors tool?

Community Beginner ,
Dec 16, 2020

Copy link to clipboard

Copied

Hello All,

I wanted to trim/divide the object by using the top right and bottom left corners as shown in the below screenshot. I have done this by manually using Scissors tool. 

How to do a script for this conversion?

20201217_012228.jpg

 

Thanks.

Most Valuable Participant
Correct answer by pixxxelschubser | Most Valuable Participant

@anna duraim38716857 

Unfortunatly you script cannot work.

 

Here is a working variant with remove the pathPoint[3] of the created rectangle

// Set color values for the CMYK object
var cmykCol = new CMYKColor();
cmykCol.black = 100.0;
cmykCol.cyan = 0.0;
cmykCol.magenta = 0.0;
cmykCol.yellow = 0;

var myDocument = app.activeDocument;
var artLayer = myDocument.layers.add()

var rect1 = artLayer.pathItems.rectangle( -449.855743408203,815.611206054688, 14.173, 8.504 );
rect1.fillColor = cmykCol;
rect1.pathPoints[3].remove();
TOPICS
Scripting

Views

88

Likes

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

How to convert rectangle object using Scissors tool?

Community Beginner ,
Dec 16, 2020

Copy link to clipboard

Copied

Hello All,

I wanted to trim/divide the object by using the top right and bottom left corners as shown in the below screenshot. I have done this by manually using Scissors tool. 

How to do a script for this conversion?

20201217_012228.jpg

 

Thanks.

Most Valuable Participant
Correct answer by pixxxelschubser | Most Valuable Participant

@anna duraim38716857 

Unfortunatly you script cannot work.

 

Here is a working variant with remove the pathPoint[3] of the created rectangle

// Set color values for the CMYK object
var cmykCol = new CMYKColor();
cmykCol.black = 100.0;
cmykCol.cyan = 0.0;
cmykCol.magenta = 0.0;
cmykCol.yellow = 0;

var myDocument = app.activeDocument;
var artLayer = myDocument.layers.add()

var rect1 = artLayer.pathItems.rectangle( -449.855743408203,815.611206054688, 14.173, 8.504 );
rect1.fillColor = cmykCol;
rect1.pathPoints[3].remove();
TOPICS
Scripting

Views

89

Likes

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
Dec 16, 2020 0
Engaged ,
Dec 17, 2020

Copy link to clipboard

Copied

Can you be more specific? Are they always squares (not rectangles with different width/height), will they ever be rotated, are you using the Rectangle tool every time, are you running this on every square in the document or just the selection, etc?

Likes

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
Reply
Loading...
Dec 17, 2020 0
Community Beginner ,
Dec 17, 2020

Copy link to clipboard

Copied

Actually, this is a rectangle but I draw it like a square shape.

I need to delete the bottom right Anchor point for the selected rectangle object.

Screenshot 2020-12-17 at 5.08.16 PM.png

How can we remove the anchor point through script? 

Likes

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
Reply
Loading...
Dec 17, 2020 0
Engaged ,
Dec 17, 2020

Copy link to clipboard

Copied

It depends. Will it ever be rotated? Are you running this on just the selection or every square?

Likes

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
Reply
Loading...
Dec 17, 2020 0
Community Beginner ,
Dec 17, 2020

Copy link to clipboard

Copied

My steps in script like below.

  1.  Create rectangle - Success
  2.  Fill color - Success
  3.  Remove anchor points - How?

 

This is my script:

var artLayer = myDocument.layers.add()

var rect1 = artLayer.pathItems.rectangle( 449.855743408203,815.611206054688, 14.173, 8.504 );


// Set color values for the CMYK object
var cmykCol = new CMYKColor();
cmykCol.black = 100.0;
cmykCol.cyan = 0.0;
cmykCol.magenta = 0.0;
cmykCol.yellow = 0;

The above code, it is applying the black color for the object. Here I need to remove the bottom right anchorpoint.

Likes

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
Reply
Loading...
Dec 17, 2020 0
Engaged ,
Dec 17, 2020

Copy link to clipboard

Copied

Lol. I guess that kind of answers my questions, but without you explicitly saying it I have to guess here. I'm asking because if the shape is not rotated, you can assume the bottom right will always be the same pathPoint in the pathItem.pathPoints array. You can directly call pathPoint.remove() to remove that anchor point:

 

var rect1 = artLayer.pathItems.rectangle(449.855743408203, 815.611206054688, 14.173, 8.504);
rect1.pathPoints[3].remove();

 If it might be rotated this will not work, you'd have to compare the points to one another in order to determine the orientation to get the one at the bottom right, which is why I've asked you twice.

I don't actually understand why you're using rectangles. This is one of the reasons you should try to explain further or show your script sooner, because it's not clear what you're actually trying to accomplish and this is a prime example of an XY Problem, where you're asking how to accomplish what you think is a solution to a problem instead of asking about that original problem to begin with.

 

The original problem is that you're trying to make a triangle, right? You're only asking about rectangles because you assume that you'd need to make one and then remove a point to create it as a triangle?

 

var artLayer = app.activeDocument.layers.add();

// If you know only 3 points are needed, why create the rectangle at all?
var points = [
    [815.611206054688, 449.855743408203],
    [829.748206054688, 449.855743408203],
    [815.611206054688, 441.351743408203]
];
var triangle = artLayer.pathItems.add();

// https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/#pathitem-setentirepath
triangle.setEntirePath(points);
triangle.closed = true;

 

ice_screenshot_20201217-052913.png

Likes

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
Reply
Loading...
Dec 17, 2020 1
Most Valuable Participant ,
Dec 17, 2020

Copy link to clipboard

Copied

@anna duraim38716857 

Unfortunatly you script cannot work.

 

Here is a working variant with remove the pathPoint[3] of the created rectangle

// Set color values for the CMYK object
var cmykCol = new CMYKColor();
cmykCol.black = 100.0;
cmykCol.cyan = 0.0;
cmykCol.magenta = 0.0;
cmykCol.yellow = 0;

var myDocument = app.activeDocument;
var artLayer = myDocument.layers.add()

var rect1 = artLayer.pathItems.rectangle( -449.855743408203,815.611206054688, 14.173, 8.504 );
rect1.fillColor = cmykCol;
rect1.pathPoints[3].remove();

Likes

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
Reply
Loading...
Dec 17, 2020 1
Community Beginner ,
Dec 17, 2020

Copy link to clipboard

Copied

Thanks a lot, Now it is working fine.

Likes

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
Reply
Loading...
Dec 17, 2020 1
Resources