Jump to content
Developer Wiki and Function Reference Links ×

Getting texture plain color name from script.


Recommended Posts

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,

Link to comment
  • Vectorworks, Inc Employee

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 .

Link to comment

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?

Link to comment

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,

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...