Copy link to clipboard
Copied
Hi,
Could anyone guide me with making a script that would generate a rectangle shape, where the user could specify:
Width, height, linetype (defaults to dashed), outline thickness, outline color (defaults to black), no fill or fill color (but defaults to no fill), bleed size (defaults to 1/2")
Ideally the script would generate a graphic template like the sample below: a dashed line black rectangle (Finished Size Rectangle) based on the the user inputted width and height, but would also generate two more rectangles:
As a bonus it would be great if the Document Setup dimensions would be able to update automatically to the values of the red Bleed Rectangle.
Thanks for any help you can provide on this!!!
Copy link to clipboard
Copied
Hello @TestriteVisual,
I created a similar type script you can use as a starting point, you'll need to modify it to your specific needs.
you can find it in the post below...
Regards,
Mike
Copy link to clipboard
Copied
Awesome Mike,
Very much appreciated, I'll give it a go!!
Copy link to clipboard
Copied
Hi Mike,
Could you please tell me what broad text swap change, if any, I could make to have all of the "rectangle frame tool" shapes that are created to just be plane "rectangle tool" shapes instead?
Thanks!
Copy link to clipboard
Copied
Any chance you coul provide an Adobe link for where I could find all the script variables? Much appreciated!!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi @TestriteVisual , The Y1,X1,Y2,X2 format for geometric bounds isn’t very intuitive, so in addition to @Mike Bro ’s script, the bounds of an empty rectangle could be set as x,y,w,h via a function like this:
app.scriptPreferences.measurementUnit = MeasurementUnits.INCHES
app.activeDocument.zeroPoint = [0,0]
var p = app.activeDocument.pages[0];
//makes an empty rectangle with no content assignment at x,y,w,h
var f = setXYWH(p,1,1,5,5)
/**
* Makes a recatangle at x,y,width,height
* @param the page to target
* @param x
* @param y
* @param width
* @param height
* @return the rectangle
*
*/
function setXYWH(p,x,y,w,h){
return p.rectangles.add ({geometricBounds:[y,x, y+h, x+w], contentType:ContentType.UNASSIGNED});
}
Here’s the rectangle properties API page:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Rectangle.html#d1e217417