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.
Check the entity type of an Id using featurescript
Best Answers
-
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 --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications1 -
Mate connectors are a type of body:
qBodyType(myquery, BodyType.MATE_CONNECTOR);
www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications0
Answers
-
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 --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications1 -
^ NB, the shorthand is qTransient("JHD").1
-
@_anton
As soon as I posted, I remembered there was a proper function for it. Old habits die hard.www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications0 -
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
0 -
Mate connectors are a type of body:
qBodyType(myquery, BodyType.MATE_CONNECTOR);
www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications0 -
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, EMEA0
-
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
0




