Copy link to clipboard
Copied
Hi i have a Layer "Corner Marks" that i would like to automatically fit to the outside bounds of the artboard (the 4 corners.). the Marks are auto inserted but seem to be offset from the artboard a little bit. Thanks everyone.
From (All 4 Corners)
I would like to go to (All 4 COrners)
huzzah. now you're asking good questions!
In the perfect circumstances, the resize method might work, but being that conditions need to be ideal, i would recommend choosing a different direction.
But for the sake of learning new things, let's look at why you're getting the error that you're getting. the resize method works on art objects (pathItems,groupItems,compoundPathItems,rasterItems,etc), but 'selection' is an array. So if you're changing
app.activeDocument.groupitems[0].resize(#,#)
to
...
app.acti
Copy link to clipboard
Copied
Do you have some code you need help with, or do you have a specific question? Or are you looking for someone to write the code?
Copy link to clipboard
Copied
I'm kind of looking to see if this is already created somewhere. I do not have code for this. I've dabbled with indesign scripts but what i'm seeing is that they are in some cases quite different in the scripting.
Copy link to clipboard
Copied
Some of the functionality is different and some DOM elements are accessed in different ways, but logically everything works the same. If you write up the logic you're looking for, we can help you with the Illustrator specific API stuff.
It's probably unlikely that you're going to find this exact script already written, but who knows.
Copy link to clipboard
Copied
This does what i want in reverse. app.activeDocument.fitArtboardToSelectedArt(0);. I tried to Switch Artboard & SelectedArt didnt work like i was hoping. I'm gonna dig alittle deeper on the forums and see if i can find something closer to what i want.
***UPDATE***
I'm thinking that rather than Going by "Layer Name" i should go by Selection. It would allow me a little more flexibility.
Copy link to clipboard
Copied
Ok let me know if there is a better way to do this. Do you for see any problems with this? The only thing i may have trouble with is "groupItems" everytime i change this to selection it does not work.
app.activeDocument.groupItems[0].resize(98.764,99.5932);
Copy link to clipboard
Copied
huzzah. now you're asking good questions!
In the perfect circumstances, the resize method might work, but being that conditions need to be ideal, i would recommend choosing a different direction.
But for the sake of learning new things, let's look at why you're getting the error that you're getting. the resize method works on art objects (pathItems,groupItems,compoundPathItems,rasterItems,etc), but 'selection' is an array. So if you're changing
app.activeDocument.groupitems[0].resize(#,#)
to
app.activeDocument.selection.resize(#,#)
you're going to get an error because resize is not a method of the array object.
If you're changing
app.activeDocument.groupitems[0].resize(#,#)
to
app.activeDocument.selection[0](#,#)
and still getting the error, it's likely that there is no selection.
I'm merely taking a stab in the dark here since i don't know what error you got, what the file looks like or the state of the file when you ran the script.
Now let's consider a better, more portable way to do this.
Take each corner mark (as an array), determine it's position (which one is closest to the top left of the artboard, which one is closest to the top right, etc), then change the position of the mark to match the edges of the artboard. Here's some pseudo-code:
buffer = 20
for each corner mark
if this corner mark's position is within 'buffer' of the top left corner of the artboard
move this corner mark to match the edges of the artboard
else if ... top right
else if ... bottom left
else if ... bottom right
Copy link to clipboard
Copied
Excellent thank you so much for your help. Works Like a charm.
Copy link to clipboard
Copied
awesome. glad to help. come on back any time with questions, we're glad to help around here. 😃
Find more inspiration, events, and resources on the new Adobe Community
Explore Now