Getting BRepBody Appearence

Getting BRepBody Appearence

Anonymous
Not applicable
1,967 Views
8 Replies
Message 1 of 9

Getting BRepBody Appearence

Anonymous
Not applicable

hi,

 

I am trying to get the appearence that has been applied to a BRepBody object. how to get it when the appearence  source type is BodyAppearanceSource?

 

and what is the right way of getting the appearence of a BRepBody?

 

0 Likes
Accepted solutions (1)
1,968 Views
8 Replies
Replies (8)
Message 2 of 9

frankzhang
Alumni
Alumni
BRepBody has an interface to get the appearance, you can simply call body.appearence() regardless of the source type.
0 Likes
Message 3 of 9

Anonymous
Not applicable

When i use body.appearence() some times i get the wrong appearence, not the one that is visible in the scene. for example when i apply it to the root component i get a different material than the one displayed.

0 Likes
Message 4 of 9

frankzhang
Alumni
Alumni
if you don't mind, could you please post the problematic code snippet here so that i can check what's going wrong?
0 Likes
Message 5 of 9

Anonymous
Not applicable

Here is samll thing of what i'm trying to do, i got the first BRebBody from the collection in the root component

then i get the appearnce using body->appearance().

 

  Ptr<Component> rootComp = design->rootComponent();
  Ptr<BRepBodies> bodies = rootComp->bRepBodies();

  if (bodies->count() == 0)
    return false;

  Ptr<BRepBody> body = bodies->item(0);
  Ptr<Appearance> appearance = body->appearance();

  std::stringstream msg;
  msg << "Body: " << body->name() << " - Appearance: " << appearance->name() << "\n";
  ui->messageBox(msg.str());

 

After testing i found out that using body->appearance() returns the wrong one if:

1) The Appearance is applied to the Component not the BRepBody.

2) The Appearance is duplicated (in this case it returns either the original one or the duplicated one).

3) Some Designs i loaded from file (*.f3d) it didn't even get the name of the appearance correctly.

 

The image i provided show the code above running and getting the wrong appearance when i applied it to the root compoenent

the name of the appearance applied is Aluminum - Anodized Glossy (Blue) while the name i got was Steel - Satin.

 

0 Likes
Message 6 of 9

frankzhang
Alumni
Alumni

 

Thanks for the detailed explanation.

 

The behaviors are expected. Components and Bodies have their own appearances, what you see from the canvas is override effect, you don't explicitly set appearance to the body, so the body's appearance will remain default.

0 Likes
Message 7 of 9

Anonymous
Not applicable

So is there an easy way to get the appearance that is being displayed in the canvas?

If not what should i take into consideration when i'm trying to get it?

 

Thanks for your help.

0 Likes
Message 8 of 9

ekinsb
Alumni
Alumni
Accepted solution

I've identified a problem and will be filing a bug.  The Appearance property should be returning the appearance currently being used to display the body.  You should be aware that there can be face overrides so it's not necessarily the entire body that will be displayed with the appearance.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 9 of 9

Anonymous
Not applicable

Ok thanks for yor help.

I will take into consideration that there could be faces overrides while getting the appearence of the body.

0 Likes