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.
FS get and set properties
graham_lock
Member Posts: 157 PRO
Hi all,
I'm simply trying to get / set the name property on parts.
If I try reading the name property I get the following error:
@getProperty: Cannot get properties during feature regeneration
If I try to set the name property I get the following error:
Precondition of setProperty failed (definition.entities is Query)
I would have expected this to be simple so I'm probably missing something.
Test document at:
Any help appreciated.
Thank you.
0
Best Answers
-
Matt_Shields Member, Onshape Employees Posts: 438If you haven't done so, I'd take the FeatureSciript course in the Learning Center.
https://learn.onshape.com/learn/course/featurescript-fundamentals/introduction-to-featurescript/featurescript-introduction
Also, here's a simple custom feature that renames parts. Take a look at its code.
https://cad.onshape.com/documents/64b50e5bc8361661aeb6c1f6/w/919a68c15737d7e96bf07b66/e/4d32423cb852bf388b384783
0 -
_anton Member, Onshape Employees Posts: 412BTW, what may not be obvious is that you can't get properties in a feature, only set them. Properties are often set after feature regeneration, so, while the feature is being executed, you wouldn't be guaranteed to get the right value. getProperty will only work in custom part property code and custom table code.
If you just want to store metadata on parts, use attributes.0
Answers
https://learn.onshape.com/learn/course/featurescript-fundamentals/introduction-to-featurescript/featurescript-introduction
Also, here's a simple custom feature that renames parts. Take a look at its code.
https://cad.onshape.com/documents/64b50e5bc8361661aeb6c1f6/w/919a68c15737d7e96bf07b66/e/4d32423cb852bf388b384783
If you just want to store metadata on parts, use attributes.