Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Break link to symbol

Explorer ,
Feb 05, 2011 Feb 05, 2011

If I right click on a symbol instance, I get a menu item, "Break link to symbol."  How can I do that same thing in Javascript?

1) That is, how do I use Javascript to break the link between a SymbolItem and the Symbol it represents? (i.e. without deleting the Symbol?)

2) Once the link is broken, how do I locate the Layer that was created when the link was broken?  That is, once the link is broken, it is no longer a SymbolItem; it becomes a Layer instead.  How do I locate that Layer?

3) How do I convert the Layer to a GroupItem?

TOPICS
Scripting
11.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Feb 06, 2011 Feb 06, 2011

1. there's no "break link" command, the symbol must be deleted to break the link, if you want to preserve the symbol, duplicate it before deleting

    look here, http://forums.adobe.com/message/3249285

2. in CS4 once the link is broken, the ex-symbolItem becomes a group, what do you mean by "locating" it? symbolitems(1).layer.name??

3. you can't convert layers to groups. Even if versions other that CS4 create layers after breaking the link, the art must be inside that layer, probably grouped already.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 07, 2011 Feb 07, 2011

Thanks for looking at these questions.

I know about deleting the Symbol to break the link, but using delete symbol to break the link is incredibly inefficient.  My program is spending over 95% of the time on that one command.  CS5 has a break link command, but I don't know how to access it from javascript.  I was hoping that would be more efficient than deleting the symbol.

When I delete the symbol, the instance is moved from the list of SymbolItems to the list of GroupItems.  It seems to end up as the last group in the layer, but I haven't seen any guarantee of this.  When using the break link command, CS5 creates a layer within a layer.  If the javascript equivalent does the same, I can "group" the layer, move the group outside the layer, then delete the layer.  I'm wondering if there's a better way. Is there any reason I might prefer a group over a layer?  If not, why have groups at all, just use layers?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2011 Feb 07, 2011
no problem,

break the link is incredibly inefficient

it takes really too long? how many symbols are there in your project? if you have a lot, are they all in your arboard? you wouldn't need to delete all the symbols, only the ones that have symbol instances on the artboard.

CS5 has a break link command, but I don't know how to access it from javascript.

do you mean break link command in the UI? not every command is available for scripting, break to link is one of them.

When using the break link command, CS5 creates a layer within a layer

group the symbol before breaking the link, and it will end up in a group instead of a layer.

Is there any reason I might prefer a group over a layer?  If not, why have groups at all, just use layers?

groups and layers have their own purposes, one reason to have a group would be to easily select it and move it around.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 07, 2011 Feb 07, 2011

At this point, I'm experimenting and trying to learn what can and cannot be done with scripts.  Mostly I'm finding thing I can't do.  I have about 50 symbols in my test drawing.

I do mean the break link in the UI.  It is surprising that javascript doesn't have an equivalent, but I've been discovering a lot of shortcomings in js.  Maybe I should consider plug-ins instead.

If I group the symbol first, I get a group within a group when I break the link.

Thanks for your input.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 25, 2012 May 25, 2012

Hi Carlos,

It works for me. However, I experienced another problem, the group after break link symbol can not be access, unless I run the script again, it is accessable. It sounds to me that it takes some times after the symbol Item is break link. Please advice me. Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2014 Jul 23, 2014
LATEST

I've been struggling with this for a script that breaks apart symbols containing symbols and recursively replaces the symbols with other symbols.  Good news is that I've got it working.  At first I thought that the broken symbols were replaced with groups, then realized that they were sublayers.

newLayer = docRef.layers.add();

mySymbol = docRef.symbols.getByName("pattern");

symbolItemRef = docRef.symbolItems.add(mySymbol);

symbolItemRef.breakLink();

brokenLayers = newLayer.layers;

    for (i=0, ii=brokenLayers.length; i<ii; i++)

    {

        brokenLayerRef  = brokenLayers;

        [do something with selected the layer]

     }

This paraphrases some of my code - hope it helps.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines