Musisback Posted March 23, 2011 Share Posted March 23, 2011 I would like to know if it is possible to get the name of the color set in the Color>Plain C olor of a texture object. I can get the name of a texture or the type of color: getname(GetShaderRecord(TextureHandle,1))that return ''NNA Plain Color'' But Can't find a way to actually find that plain color. Thanks for your help, Quote Link to comment
Vectorworks, Inc Employee klinzey Posted March 23, 2011 Vectorworks, Inc Employee Share Posted March 23, 2011 There is no direct access to the color name but you can get the RGB values from the record attached to the texture. The record name for 2010 and 2011 is different. For 2010 R=GetRField(TextureHandle,'NNAPlain Color','Color'); G=GetRField(TextureHandle,'NNAPlain Color','Color G'); B=GetRField(TextureHandle,'NNAPlain Color','Color B'); After that you can use RGBtoIndex and then IsUserColor to get the color name. You must use a DYNARRAY[] OF CHAR for the IsUserColor . Quote Link to comment
Musisback Posted March 24, 2011 Author Share Posted March 24, 2011 Well it does not work. It looks like the color is stored with a integer (short) in the record of the texture. So information is lost. When RGBtoIndex is found, it is slightly different of then correct one. By correct one, i meant then one a get with GetFillBack(obHd, red, green, blue); RGBToColorIndex(red, green, blue, colorIDX); ok := IsUserColor(colorIDX, colorName); When then FillBack is the same color. In this last case GetFillBack returns longint. Then, there is no lost of information. Any Ideas to go around that problem? Quote Link to comment
Musisback Posted March 25, 2011 Author Share Posted March 25, 2011 Ok, I understood what is going on: The RGB stored in the record of the texture is a shortint The function RGBToColorIndex expects longint. ( like the longints that GetFillBack returns.) there is a 257 factor between the two kinds of RGB. so, I can get the name of my color with the script : R:=num2strF(GetRField(TextureHandle,'NNAPlain Color','Color')); G:=num2strF(GetRField(TextureHandle,'NNAPlain Color','Color G')); B:=num2strF(GetRField(TextureHandle,'NNAPlain Color','Color B')); RGBToColorIndex(r*257, g*257, b*257, colorID); ok := IsUserColor(colorID, colorName); But, there is another problem. IsUserColor only returns a name when the color is a color of the active document. And VW does not import the colors of the texture as 'active document colors'. So is looks like the only thing I can do to get the name of the color of a texture is to have all the colors in my document template. Does that make sens? Did I miss something? Thanks, 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.