Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Given a mate connector how do you find the owner body for it?
pmd
Member, Developers Posts: 63 PRO
How do you go from a mate connector to the owner part?
I tried qOwnerBody(mc) but that seems to return the MC itself since MC's are bodies in their own right.
https://cad.onshape.com/documents/fc195edc346146cb553ba40a/w/ee195a6b5394daccf5b1a8d8/e/36e00d6dd082306d848814a5
The reason I want this is I am using the MC to indicate a reference point on a part and do not want the user to have select both the MC and the part.
I tried qOwnerBody(mc) but that seems to return the MC itself since MC's are bodies in their own right.
annotation { "Feature Type Name" : "OwnerOfMC" } export const myFeature = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "My Query", "Filter" : BodyType.MATE_CONNECTOR, "MaxNumberOfPicks" : 1 } definition.mc is Query; } { var mc_owner = qOwnerBody(definition.mc); debug(context, mc_owner); });
The reason I want this is I am using the MC to indicate a reference point on a part and do not want the user to have select both the MC and the part.
Tagged:
0
Best Answer
-
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565qAdjacent and qOwnerBody don't work because the mate connector is actually its own body, with BodyType.MATE_CONNECTOR.
One option is to loop through every part, and check if (evaluateQuery(qIntersection(myConnector, qMateConnectorsOfParts(part))) == []).
However, it's worth noting that mate connectors created live in the feature dialog (by selecting position that's not a previously-created mate connector feature) do NOT have owner parts. Those mate connectors will disappear when the feature dialog closes and will not be inserted with the part into an assembly.
So for this case I would actually suggest adding a separate "Part" field to specify the part. If you'd like, you can add an editing logic function which auto-populates that field with something like qClosestTo(qAllModifiableSolids(), evMateConnector(...).origin) when a mate connector is selected, but still lets the user override that if another part is needed.
5
Answers
Philadelphia User Group Leader
One option is to loop through every part, and check if (evaluateQuery(qIntersection(myConnector, qMateConnectorsOfParts(part))) == []).
However, it's worth noting that mate connectors created live in the feature dialog (by selecting position that's not a previously-created mate connector feature) do NOT have owner parts. Those mate connectors will disappear when the feature dialog closes and will not be inserted with the part into an assembly.
So for this case I would actually suggest adding a separate "Part" field to specify the part. If you'd like, you can add an editing logic function which auto-populates that field with something like qClosestTo(qAllModifiableSolids(), evMateConnector(...).origin) when a mate connector is selected, but still lets the user override that if another part is needed.
Would we be able to use qPartsAttachedTo, like we can in Sheet Metal?
IR for AS/NZS 1100