Given a mate connector how do you find the owner body for it?

pmd
pmd Member, Developers Posts: 68 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.

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);
    });

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.
Tagged:

Best Answer

Answers

  • marcus_bernstein
    marcus_bernstein Member, User Group Leader Posts: 35 EDU
    I'd bet there's a cleaner way, but depending on your application a qAdjacent may work fine. 
    Any chance Onshape is looking for interns?

    Philadelphia User Group Leader
  • pmd
    pmd Member, Developers Posts: 68 PRO
    I will do as you suggest - I sort of guessed implicit MC's might be a problem. I will read up on auto-populating - seems perfect for my case. 
  • MBartlett21
    MBartlett21 Member, OS Professional, Developers Posts: 2,064 ✭✭✭✭✭
    @kevin_o_toole_1
    Would we be able to use qPartsAttachedTo, like we can in Sheet Metal?
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • kevin_o_toole_1
    kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565 image
    @MBartlett21qPartsAttachedTo() will not give you Mate Connectors. a query like qOwnerPartsOfMateConnectors() is on our to-do list. In the meantime my suggestions above are the best solutions.
  • Derek_Van_Allen_BD
    Derek_Van_Allen_BD Member Posts: 1,168 PRO

    @kevin_o_toole_1 or maybe @_anton is this still the state of querying for owner parts associated with mate connectors? I've got some custom features that would really benefit from a qOwnerPartsOfMateConnectors() that would rather not open Pandora's box of combinatorics problems