Skip to main content
Inspiring
January 13, 2011
Answered

[CS5 - JS] Random questions...

  • January 13, 2011
  • 1 reply
  • 1981 views

Hi.

I come form InDesign scripting and I'm sorry to say that illustrator one is really raw...

Anyway, my problems are:

- Looks like it's not possible to get something like "textStyleRanges" within a paragraph so the only way to get different text style ranges in a paragraph is to loop through characters and check differences (am I wrong?)

- Looks like it's not possible to expand a symbolItem... is there a way to get this?

Thanks!

This topic has been closed for replies.
Correct answer Big_RA

You are correct.

In order to expand a symbol, you need to copy it to a temporary layer, Here's some code I use:

function unlinkSymbol(mySymb){
     var symbLayer=findOrCreateLayer("SymbolsTemp-----")
     var dupSymbol=mySymb.duplicate()            // Duplicate the symbol
     symbLayer.visible = true                             // Layer must be visible and unlocked
     symbLayer.locked = false
     symbLayer.symbolItems.add(dupSymbol)    // Place duplicate symbol on symbLayer
     dupSymbol.remove()                                   // Break the link
     var myGroup = symbLayer.groupItems[symbLayer.groupItems.length-1]
     myGroup.name = mySymb.name                // Name the group same as the original
     symbLayer.visible = false                            // Hide the layer, delete it later
     return myGroup
}

1 reply

Big_RACorrect answer
Inspiring
January 18, 2011

You are correct.

In order to expand a symbol, you need to copy it to a temporary layer, Here's some code I use:

function unlinkSymbol(mySymb){
     var symbLayer=findOrCreateLayer("SymbolsTemp-----")
     var dupSymbol=mySymb.duplicate()            // Duplicate the symbol
     symbLayer.visible = true                             // Layer must be visible and unlocked
     symbLayer.locked = false
     symbLayer.symbolItems.add(dupSymbol)    // Place duplicate symbol on symbLayer
     dupSymbol.remove()                                   // Break the link
     var myGroup = symbLayer.groupItems[symbLayer.groupItems.length-1]
     myGroup.name = mySymb.name                // Name the group same as the original
     symbLayer.visible = false                            // Hide the layer, delete it later
     return myGroup
}

Inspiring
January 19, 2011

Thanks big RA!

What about document fonts?

Is there any way to get fonts used within an Illustrator document?

Something similar to InDesign's "app.activeDocument.fonts"...

I just came across "app.textFonts" which is good but I only need the document's fonts.

Thanks!

Inspiring
January 22, 2011

function getUsedFonts (doc ){      var xmlString = new XML(doc.XMPString);      fontsInfo = xmlString.descendants("stFnt:fontName");      var ln = fontsInfo.length(), arr = [];      for (var i = 0; i<ln; i++){arr.push(fontsInfo)};      return arr; }

alert(getUsedFonts(activeDocument));

-- function I used in my fonts package script.  You should save the document first.