Petri Posted November 10, 2006 Share Posted November 10, 2006 I can't figure out how to get the name of the gradient used in an object. (Early blindness, I guess.) Quote Link to comment
Rick Francken Posted November 10, 2006 Share Posted November 10, 2006 Hi Petri, I haven't tried this, but... Assuming "hObject" is the handle to your object that has gradient fill var GradientIndex: longint; GradientName: string; begin {try this first} GradientIndex:= GetFPat(hObject); {if that doesn't work, try this instead} GradientIndex:= GetObjectVariableLongint(hObject, 695); {now that you have the index of the gradient, you can get its name} GradientName:= Index2Name(GradientIndex); end; Try creating a simple rectangle with a gradient fill, and then export a file as Vectorscript. Then you can see what VS functions are used to define the gradient, as well as what functions are used to set the gradient as a fill for a particular object. In this case I noticed a line that looked like this: SetObjectVariableLongInt (objectHandle,695,result * -1); According to the VS Function Reference for the GetFPat function, "A negative value corresponds to internal index of a vector fill pattern applied to the object". Also, the 695 Object Selector is Object Fill Style. Since we want to find the value, use the "Get??" function instead of the "Set??" function. Good luck, Quote Link to comment
Petri Posted November 10, 2006 Author Share Posted November 10, 2006 Thanks, Rick. That makes sense - but does not work. I get the gradient index (they seem to be negative, ie. are vector fills), but no name is returned with Index2Name. How annoying! Well, I've had the same problem with hatches. PROCEDURE GetGradientName; VAR gradientIndex : LONGINT; gradientName : STRING; obHd : HANDLE; BEGIN obHd := FSACTLAYER; gradientIndex := GETFPAT(obHd); gradientName := INDEX2NAME(gradientIndex); {MESSAGE(gradientName);} MESSAGE(gradientIndex); END; RUN(GetGradientName); Quote Link to comment
PeterT Posted November 11, 2006 Share Posted November 11, 2006 Get the name of the NEGATIVE index number i.e. gradientName := INDEX2NAME(-gradientIndex); I can't recall where I learned this, but for negative index numbers you need to get them back to positive before you get the name. Same for Hatches. Quote Link to comment
Petri Posted November 11, 2006 Author Share Posted November 11, 2006 Peter, you are a genius! Thank you VERY much! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.