Skip to main content
Rick E Johnson
Inspiring
January 24, 2021
Question

Can the SDK access user preferences for stroke weight?

  • January 24, 2021
  • 1 reply
  • 497 views

The user preferences for the constrain angle can be read through the SDK's AIPreference suite using the keyword "constrain/angle" but cannot find the keyword to get the user preferences for the chosen unit of measure for stroke weight. Also, would the value there reflect any changes the user may have made since startup? Any suggestions would be much appreciated.

This topic has been closed for replies.

1 reply

MilosR
Inspiring
January 28, 2021

1. In SDK all units are in points. I guess that preference you want is also stored in points to avoid storing multiple values. You can convert values to get value in desired unit.

2. With AIPreference you can get current value, but values in preference file are stored only upon AI shutdown process

Rick E Johnson
Inspiring
January 28, 2021

Thanks, Milos, that's related but not quite what I'm looking for. Until recently, my plugins only needed input on very small distances, so points were adequate for getting measurements. A more recent plugin uses larger values to measure or move an object, so it's much easier for users to use inches or mm. For this, I use sAIUser->IUAIRealToStringUnits and sAIUser->IUStringToAIReal to convert between the points the SDK needs and whatever units the user wants to work in.

 

Now when users who use mm also specify stroke widths, they want to specify it in mm as well. If I simply capture user units, then other users may be left specifying a stroke weight in inches. Adobe was wise to have a separate preference for stroke weight, aside from the general unit preference.

 

What I did in the meantime is that the plugin saves its own user preference and does its own math to convert to/from pt/mm when needed. The value in the text field gets "mm" or "pt" appended to it, and when it reads it again, it looks for those same characters to interpret the value.

 

I just thought it would be a better user experience to just blend in with whatever Illustrator's prefs for strokes were set to.

MilosR
Inspiring
February 2, 2021

As far as I can see there is "strokeUnits" property inside preferences with integer value. Is this preference you are looking for?