nvkelso / illustrator-scripts

JavaScript ExtendScript for automating and extending Adobe Illustrator
248 stars 135 forks source link

Find and replace script fails when object has been renamed #4

Open Retroker opened 3 years ago

Retroker commented 3 years ago

Suppose I am trying to replace some objects by an ellipse.

findAndReplaceGraphic_centered returns an error when one of the selected objects have been renamed somehow.

If we select two objects like <Ellipse> and <Path> everything goes well.

However, if one of them has a name, like <Ellipse> and FooBar, the script returns the following error:

Error 25: Expected: ].
Line: 1
-> subArray1["object"]=[PathItem FooBar]
nvkelso commented 3 years ago

I haven't used these script in my daily practice in quite some time. To work around it can you adjust your object names?

Retroker commented 3 years ago

Yes, if we just delete the object names leaving it blank Illustrator rename the object with default names and everything starts working again.

I think someone can be saved by this thread though... because it took me a while to figure out what was causing the error.

The problems with deleting names are, of course, having to do it manually (very annoying) and not being able to use names to organize your work (I personally have this practice of naming too many objects to make it easier for me to access Layers panel).