Reset colors in a CAD/XDE model

Colored ANC101.
XDE document of a single part with colored faces.
  1. Compactness. To have several faces (or parts) of the same color, XDE will not replicate the corresponding r-g-b values for each occurrence many times. You will rather end up having more and more links from a single existing color entity to all geometric primitives where it is used.
  2. Palette. By iterating this “Colors” section of the XDE document, you can easily collect all colors that are used in your design. We have exploited this possibility for implementing our “intelligent” color picker back in the days. Our color picker was supplemented with a custom palette prepopulated with all colors existing in the incoming part. Selecting a color from such a palette can be sometimes preferred over direct pixel picking as the latter depends on lightning and does not provide ab initio color.
  3. Easy cleanup. That’s what we need: just go over all the labels in the “Colors” section and nullify them.
“Smart” color picker uses the ab initio design colors in its predefined palette.
void ResetColors()
// Get color tool.
CT = XCAFDoc_DocumentTool::ColorTool( m_doc->Main() );

TDF_LabelSequence colorLabs;

for ( TDF_LabelSequence::Iterator lit(colorLabs);
lit.More(); lit.Next() )
TDF_Label colorLab = lit.Value();
XDE model after clean up.
ANC101 with all colors cleaned up.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store