Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: How to get fillColor for characterStyle

$
0
0

Vamitul wrote:

 

if the cstyles don't have defined a pointSize (or a leading, for that matter), they will return 1851876449 (meaning NothingEnum.NOTHING).

 

.. I was going to check if Linus was right on that, but of course you are correct -- this was my test script:

 

chs = app.activeDocument.characterStyles[1];
alert (chs.name);
alert (chs.fillColor);// alert (chs.fillColor.name); // error!
alert ((chs.fillColor == null) ? 'Not set' : chs.fillColor.name);
alert (chs.pointSize); // ???
alert ( (chs.pointSize == NothingEnum.nothing) ? "Not set" : chs.pointSize);

 

but .. for the long list of properties in the original post, I would suggest an entirely different method -- easier to debug, easier to maintain and easier to understand. Instead of building one single long string (possibly interspersed with ternary operations), create an array and use push to add each of the property lines in turn:

 

cssprops = [];if (chs.fillColor != null)
 cssprops.push('color: '+chs.fillColor.name+';');

 

Then use this

 

cssprops.join('\r')

 

to make it a single long line. It's easier to debug (etc.) because you typically need only one or two lines per inspected property. You can easily change the order in which properties are listed, and insert and remove any of the properties at will.


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>