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: 445 ✭✭✭
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:
    var tangentPlane = evSurfaceDefinition(context, {            "face" : definition.face    });        var originalObject =qContainsPoint(qBodyType(qEverything(EntityType.BODY),BodyType.SOLID),tangentPlane.origin );


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.

Answers

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

    the last part should be 

        var tangentPlane = evFaceTangentPlane(context, {            "face" : definition.surface,            "parameter" : vector(0.5, 0.5)    });
    
    of course the above returns a surface, not a tangent plane.
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 928
    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 \ Director, Architecture and FeatureScript \ Onshape Inc
  • dave_cowdendave_cowden Member, Developers Posts: 445 ✭✭✭
    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.