Cannot get solid body from selection - returns NULL

Cannot get solid body from selection - returns NULL

DWhiteley
Advisor Advisor
613 Views
2 Replies
Message 1 of 3

Cannot get solid body from selection - returns NULL

DWhiteley
Advisor
Advisor

I've used this code so far:

 

Ptr<Selection> bodysel = ui->selectEntity("Select component", "SolidBodies"); // this works
Ptr<Base> compb = bodysel->entity(); // this works
Ptr<Component> comp = compb; //returns NUL

 

I'm trying to assign what I select to comp.

 

HELP

 

Dave W

0 Likes
Accepted solutions (1)
614 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

The entity property of the Selection object will return a BRepBody object and then you're trying to assign it to variable typed as a Component.  That won't work.  It should be more like this.

 

Ptr<Selection> bodysel = ui->selectEntity("Select component", "SolidBodies"); 
Ptr<BRepBody> body = bodysel->entity();
Ptr<Component> comp = body->parentComponent(); 
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 3

DWhiteley
Advisor
Advisor

Thank you Brian, worked a treat!

0 Likes