Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NXOpen: RGB of a DisplayableObject

Status
Not open for further replies.

aerojockey

Aerospace
Jul 9, 2013
3
0
0
US
According to the documentation, DisplayableObject has a Color property, but it's an index, and I'm not sure what it's an index into. I assume it's am index into a palette (maybe a CDF object), but I don't know how to access the palette for a given object.

I tried passing the Color property value to UF_DISP_ask_color as the clr_num parameter, but it returned an RGB value that didn't match the color on the screen.

This is for NX 8.0.3

Thanks.
 
Replies continue below

Recommended for you

The 'color palette' is not assigned to a given object, but rather it's associated with a particular part file. That being said, 'UF_DISP_ask_closest_color_in_part' should return the color index (1-216) for an object when you pass this command the object's 'tag'. Generally speaking, you can find this index number, and thus the RGB values, in one of two ways. Inside of an NX session, you can go to...

Preferences -> Color Palettes...

...and at the bottom of the dialog, in the section labeled 'Options', select the 'Information' icon.

Or you can look at the CDF file specified at...

Customer Defaults -> gateway -> Visualization -> Color Palette

...but becareful because this does NOT necessarily represent the CDF file used in any particular part file, just the one that will be used if a new 'blank' part of created or will be used if you replace the CDF file in an open part with the current default, which can also be done from the 'Options' section of the Color Palette dialog. However, the scheme described above, selecting the 'Information' icon in the 'Options' section of the Color Palette dialog, will ALWAYS provide you the correct color data.

Not sure if this helps you all that much, but...

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Also bear in mind that sheet and solid bodies have faces that may or may not match the underlying body color. A solid body that appears to be blue may actually be a green solid body with blue faces.

Sketch entities may change display color depending on your preferences and the state of the sketch.

Components of an assembly add their own color complications.

www.nxjournaling.com
 
You two actually both did help. Once it was pointed out that the color palette is stored with the Part (which is kind of obvious in retrospect) I found the color palette I was looking for (Part.Colors). Then I realized that the color I see in the display window is actually face color, and it seems that face color is the one that gets set whenever the user chooses a display color.

So given a face and a part, I can get the RGB components of a face like so:

ColorManager colors = part.Colors;
int color_index = face.Color;
NXColor color = colors.Find(color_index);
NXColor.Rgb components = color.GetRgb();

Thanks for the help.
 
Status
Not open for further replies.
Back
Top