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.

Check the entity type of an Id using featurescript

mohammad_sadil_khanmohammad_sadil_khan Member Posts: 8 EDU
edited June 18 in FeatureScript
Hello Onshape Community,

I would like to know if there is any way, given Ids like ("JHD", "JKC"), I can know if these ids correspond to parts, edges, vertices, faces or mate connectors using Featurescript?

Thank you.

Best Answers

Answers

  • Caden_ArmstrongCaden_Armstrong Member Posts: 195 PRO
    Answer ✓
    You can turn an entity id into a query like so:

    var specificEntity = { "queryType" : QueryType.TRANSIENT, "transientId" : "JHD"} as Query;

    and then do a filter like qEntityType and a isQueryEmpty check to see if it matches.
    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • _anton_anton Member, Onshape Employees Posts: 413
    ^ NB, the shorthand is qTransient("JHD").
  • Caden_ArmstrongCaden_Armstrong Member Posts: 195 PRO
    @_anton
    As soon as I posted, I remembered there was a proper function for it. Old habits die hard.
    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • mohammad_sadil_khanmohammad_sadil_khan Member Posts: 8 EDU
    Hello,

    This is working, Thanks.
    I have another question. Since Mate Connector is not an Entitytype, mate connectors ids are being identified as body.
    Is there way around it? Thanks
  • Caden_ArmstrongCaden_Armstrong Member Posts: 195 PRO
    Answer ✓
    Mate connectors are a type of body:

    qBodyType(myquery, BodyType.MATE_CONNECTOR);
    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    You should never deal in transient IDs. If you are using println on an evaluated query then you’ll see the transient id but it can change if other features before it in the feature list change the context. Use specific queries only. 
    Senior Director, Technical Services, EMEAI
  • mohammad_sadil_khanmohammad_sadil_khan Member Posts: 8 EDU
    I am using the rollbackbarindex to query on the time the entities are first referred or created.
    Will it solve it?

    If not, can you please elaborate on the specific queries?

    Thanks
Sign In or Register to comment.