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.
Part Naming
cory_isaacson
Member, Developers Posts: 43 PRO
I am using FS to generate multiple parts in a single feature (sometimes 20 or more). They come out with default names, like Part1, Part2, etc. I understand that part naming is not possible right now with FS. Is there a way to do this with the API, after the parts are generated? If so, how can I figure out what PartN is so I can rename it (such as MyPartN)?
0
Best Answer
-
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565Yep, we definitely want a pure FS solution for naming an other metadata in the future.
For now the process will involve the following steps:- (optional, might make querying easier later) In FeatureScript, call setAttribute on a part created with an attribute of e.g.
{ "myPart" : "top" }
or{ "myPart" : "side" ~ i }
- In the API, get deterministic ids for specific parts. This will involve calling Part Studios: Evaluate FeatureScript API with a function returning
transientQueriesToStrings(evaluateQuery(someQuery)))
, wheresomeQuery
is either:- A query for the specific part you want (possibly a
qCreatedBy("someOperation", EntityType.BODY)
), OR - If you did step 1, a qAttributeFilter for the specific attribute (e.g.
{ "myPart" : "top" }
) set for the part in step 1
- A query for the specific part you want (possibly a
- Use the Parts: Update Metadata API (or, for multiple parts, the Parts: Update Part Metadata API) to set the name of a Part based on its deterministic id.
In the meantime, let us know if you encounter any issues with the strategy outlined above!
6 - (optional, might make querying easier later) In FeatureScript, call setAttribute on a part created with an attribute of e.g.
Answers
For now the process will involve the following steps:
- (optional, might make querying easier later) In FeatureScript, call setAttribute on a part created with an attribute of e.g.
- In the API, get deterministic ids for specific parts. This will involve calling Part Studios: Evaluate FeatureScript API with a function returning
- A query for the specific part you want (possibly a
- If you did step 1, a qAttributeFilter for the specific attribute (e.g.
- Use the Parts: Update Metadata API (or, for multiple parts, the Parts: Update Part Metadata API) to set the name of a Part based on its deterministic id.
I sure you can see why we really want a pure FeatureScript solution{ "myPart" : "top" }
or{ "myPart" : "side" ~ i }
transientQueriesToStrings(evaluateQuery(someQuery)))
, wheresomeQuery
is either:qCreatedBy("someOperation", EntityType.BODY)
), OR{ "myPart" : "top" }
) set for the part in step 1In the meantime, let us know if you encounter any issues with the strategy outlined above!