Skip to main content
Participant
December 19, 2011
Question

Looking for "Replace with Symbol" script

  • December 19, 2011
  • 6 replies
  • 18700 views

So I am trying to replace gps points with a symbol I have created. I have found blogs referencing a script that can replace selected items with symbols saved in the symbols panel, but I can't seem to find the actual script! If anyone knows where I can find JET_ReplaceWithSymbol.jsx or any other script that can do the same function, it would be greatly appreciated!

This topic has been closed for replies.

6 replies

Participant
December 21, 2023

Hi guys. This plugin is very good, but does anyone know if when you replace the object to the symbol in your library, the size of the already created symbol could be maintained and not adapt to the size of the previously selected object?

Thanks a lot

schroef
Inspiring
December 21, 2023

@rafac92111371 

You need to select all the instance used, than select the new symbol on the panel and from the context menu (small menu top right) > choose replace.

 

It will replace all selected items and keep rotation and size etc etc

Im not sure you can replace but keep the size of the new selected item. If you commented out the part about scale it should work as you want but probably get misplaced, as its being placed by top and left. Meaning the symbol is not centered on the selected items

Check this video, when you comment  out those lines. It will keep the size of the pathItems selected and will also do the rotation properly. The second run i show is how the other version works which i adjusted

Participant
December 23, 2023

Thank you very much for your explanation, but it would be possible to download the pluggin to be able to comment on those lines as you show me in the image. I don't think the pluggin I have is like that.

Participant
June 13, 2019

Hello! I am having difficulty running the script. I am a n00bie here so hopefully this is a quick fix. I am using JET's script and when I try to run it in Illustrator it says there is a problem with line 15 of the code.

Is it something I am doing in my symbols window incorrectly? I ran it just last week and it was working fine...

pixxxelschubser
Community Expert
Community Expert
June 13, 2019

Are there unvisible or locked objects/layers in your document? (Screenshot?)

Participant
June 13, 2019

Yes! Wow that fixed it. Thank you so much!

Participant
October 12, 2015

Hi everyone,

I used Muppet Mark script:

It works really well but the script remove my layers name. I have a world map with pin points for each city separated by layers.

Some help? Muppet Mark

pixxxelschubser
Community Expert
Community Expert
December 19, 2011

This John Wundes script should be do the same:

http://www.wundes.com/JS4AI/copyToMultipleObjects.js

Unfortunately the Jet-scripts on his (--> http://www.illustrationetc.com/AI_Javascripts/) old site are not longer available. Maybe someone knows the current page. (Perhaps Jet himself  )

Inspiring
December 19, 2011

Found it… Im sure Jet won't object to me posting here… Hope it helps…

/*

JET_ReplaceWithSymbol.jsx

A Javascript for Adobe Illustrator

Purpose: Replaces selected items with Instances of a Symbol from the Symbols Panel.

The desired Symbol can be defined by its index number (its number of occurrance in the Panel).

*/

var docRef=app.activeDocument;

var symbolNum=prompt("Enter the number of the Symbol you want to replace each selected object",1);

for(i=0;i<docRef.selection.length;i++){

          var currObj=docRef.selection;

          var currLeft=currObj.left;

          var currTop=currObj.top;

          var currWidth=currObj.width;

          var currHeight=currObj.height;

          var currInstance=docRef.symbolItems.add(docRef.symbols[symbolNum-1]);

          currInstance.width*=currHeight/currInstance.height;

          currInstance.height=currHeight;

          currInstance.left=currLeft;

          currInstance.top=currTop;

          currInstance.selected=true;

          currObj.remove();

          redraw();

}

Inspiring
June 8, 2012

Hello everyone,

I have been reviewing various replace scripts for symbols, the above two by JET and Wundes seem to be the most commonly referenced.

Here is my question, I was hoping to add the ability to preserve rotation. So if the items being replaced had rotations already applied then the items replacing them would inherit that same rotation, hope that makes since.

I was hoping I could store the rotation value to a variable like in JET's simple script for width, height etc., but it seems its not that easy. I began to think maybe it's just not possible since no one has included rotation preservation, so I contacted Wundes and he said it is possible and to look into using matrix transforms. Ugh, I looked at things in the JS Scripting Reference as well as Senocular's tutorial for Transform Matrix. However I cant seem to get my head around it enough to even know where to begin and probably I am not at the point realistically to add it to either of these scripts.

JET's script is less involved, but Wundes script certainly offers some nice features, would someone be willing to walk me through or show me how to add rotation preservation to either of those two scripts. I would be really grateful and it would be a great learning experience for me with all this Matrix Transform stuff to see how it would be accomplished.

I appreciate any help, feedback, scripts... thanks everyone.

CarlosCanto
Community Expert
Community Expert
June 9, 2012

when an object is rotated, the application assigns a tag to it, you can tap into that tag's value an use it to rotate your symbol

var idoc = app.activeDocument;

var sel = idoc.selection[0];

var rotationTag = sel.tags[0];

alert(rotationTag.name + " : " + rotationTag.value + " Radians");

Inspiring
December 19, 2011

Did you also post in the general forum? Jet is still a regular contributor there… although he doesn't post here in scripting a great deal these days… I will have a look if I have this I keep quite a few of Jet's scripts for reference…