×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NXOpen: RGB of a DisplayableObject

NXOpen: RGB of a DisplayableObject

NXOpen: RGB of a DisplayableObject

(OP)
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.

RE: NXOpen: RGB of a DisplayableObject

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.

RE: NXOpen: RGB of a DisplayableObject

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

RE: NXOpen: RGB of a DisplayableObject

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources