Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.


What query will give me the solid body that owns a face?

dave_cowdendave_cowden Member, Developers Posts: 472 ✭✭✭
I have a face, and I thought this would give me the body that owns it:

var theBody = qOwnerBody(definition.face );

But that just gives me the face again.  I also tried 

var theBody = qOwnerBody(qOwnerBody(definition.face));

but that gives the same thing too.  The body is a user-created body so i do not have programmatic access to the id to use qCreatedBy.

This code works, but its really insane just to find the owning body:
<div>&nbsp; &nbsp; var tangentPlane = evSurfaceDefinition(context, {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "face" : definition.face</div><div>&nbsp; &nbsp; });</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; var originalObject =qContainsPoint(qBodyType(qEverything(EntityType.BODY),BodyType.SOLID),tangentPlane.origin );</div>

Shouldn't you be able to find the solid body that owns a face using qOwnerBody?  I think this code will generally work but its pretty nasty and there are some corners in which we could find multiple bodies if we happened to have a face on a boundary between two solids.


  • Options
    dave_cowdendave_cowden Member, Developers Posts: 472 ✭✭✭
    oh sorry, in that last code i pasted an older version, sorry.

    the last part should be 

    <div>&nbsp; &nbsp; var tangentPlane = evFaceTangentPlane(context, {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "face" : definition.surface,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "parameter" : vector(0.5, 0.5)</div><div>&nbsp; &nbsp; });
    of course the above returns a surface, not a tangent plane.</div>
  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,186
    qOwnerBody should work -- assuming the face is on that body and not, say, part of a different body (perhaps a surface body).  I'm surprised it gives you a face.  Does the output of debug(context, qOwnerBody(definition.face)) confirm that it resolves to one face?
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    dave_cowdendave_cowden Member, Developers Posts: 472 ✭✭✭
    Yes, it does. I also sebugged it graphically to see what it selected too.

    This is a pretty large project, so like that other extrude weirdness I'll try to narrow it down to an easier repro before having you look into it
Sign In or Register to comment.