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

[CS5 - JS] Random questions...

Explorer ,
Jan 13, 2011 Jan 13, 2011

Copy link to clipboard

Copied

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!

TOPICS
Scripting

Views

1.5K

Translate

Translate

Report

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

correct answers 1 Correct answer

Explorer , Jan 17, 2011 Jan 17, 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() 

...

Votes

Translate

Translate
Adobe
Explorer ,
Jan 17, 2011 Jan 17, 2011

Copy link to clipboard

Copied

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
}

Votes

Translate

Translate

Report

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 ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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
Enthusiast ,
Jan 21, 2011 Jan 21, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 ,
Jan 24, 2011 Jan 24, 2011

Copy link to clipboard

Copied

Thanks, that's a great tip!

Votes

Translate

Translate

Report

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 09, 2013 Jul 09, 2013

Copy link to clipboard

Copied

Hey, man! Can you help me? I'm trying to add this bit of scripting to a file. I copied and pasted just as you've got it above. When I execute the script, it does everything corectly except for the fonts. A window pops up (I've attached an image) that lists all of the correct fonts used, but it doesn't save the fonts to the folder.Screen Shot 2013-07-09 at 9.51.15 AM.png

Any thoughts as to what I've done wrong? Maybe I put the code in the wrong place within the file? Any help is much appreciated

Votes

Translate

Translate

Report

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
Guru ,
Jul 09, 2013 Jul 09, 2013

Copy link to clipboard

Copied

The snippet in post 3 only displays a dialog of the font names nothing more…

Votes

Translate

Translate

Report

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
Enthusiast ,
Jul 09, 2013 Jul 09, 2013

Copy link to clipboard

Copied

As Mark said, that snippet only tells you what fonts been used in the document. To collect fonts to a folder is more complex, since you can not get the fonts location property from within Illustrator scripting DOM.

If you also have Indesign installed, you can have a look with [this script](http://pastebin.com/raw.php?i=EEPNWxCS), which can use to package fonts for .ai/.indd files.

If you don't have Indesign, I have another solution which is more complex.

BTW: You can package fonts with Illustrator CC directly now.

Votes

Translate

Translate

Report

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 10, 2013 Jul 10, 2013

Copy link to clipboard

Copied

Thanks, Molu. I looked at your script in pastebin and tried to implement it, but I received an error with Line 23. If you are interested, would you PM me?I'd like to try and figure this out. I have both indesign and illustrator.

I'm currently copying the fonts from illustrator into indesign and packaging that way. This method works fine, except that it is time consuming (relative to a script doing it). I know that collecting fonts in illustrator can be done because of programs like Scoop and Flightcheck, so I'm hoping to make it a reality for me without dishing out some dough.

Any thoughts?

Votes

Translate

Translate

Report

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 ,
Jul 10, 2013 Jul 10, 2013

Copy link to clipboard

Copied

What do you need to do?

Votes

Translate

Translate

Report

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 10, 2013 Jul 10, 2013

Copy link to clipboard

Copied

LATEST

I'd like to collect fonts in illustrator. I'm currently copying the fonts from illustrator into indesign and packaging that way. This method works fine, except that it is time consuming (relative to a script doing it). I know that collecting fonts in illustrator can be done because of plugins/scripts like Scoop and Flightcheck and ArtFiles, so I'm hoping to make it a reality for me without dishing out some dough.

Votes

Translate

Translate

Report

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