1. Get the ModelData_BRepRepresentation of a part;
2. Get a list of all the Bodies that belong to this Part: ModelData_BodyList aBodyList = theBRep.Get();
3. Use Appearance(aBody) method of the ModelData_BRepRepresentation object to retrieve appearance of the Body;
4. Use ToColor method of the ModelData_Appearance object to get the color.
Here's an example of code for a viewer:
- class PartBRepVisitor : ModelData_Model.VoidElementVisitor
- {
- public PartBRepVisitor()
- {
- }
- public override void Apply(ModelData_Part thePart)
- {
- ModelData_BRepRepresentation aBRep = thePart.BRepRepresentation();
- if (aBRep != null)
- {
- ExploreBRep(aBRep);
- }
- }
- private void ExploreBRep(ModelData_BRepRepresentation theBRep)
- {
- ModelData_BodyList aBodyList = theBRep.Get();
- for (uint i = 0; i < aBodyList.Size(); ++i)
- {
- ModelData_Body aBody = aBodyList.Access(i);
- if (aBody.BodyType() == ModelData_BodyType.ModelData_BT_Acorn)
- {
- ModelData_Appearance anApperance = theBRep.Appearance(aBody);
- ModelData_Color aColor = new ModelData_Color();
- anApperance.ToColor(aColor);
- Console.WriteLine(aColor.R());
- Console.WriteLine(aColor.G());
- Console.WriteLine(aColor.B());
- }
- }
- }
- }