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
-
Yep, 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))), wheresomeQueryis 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
-
Yep, 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))), wheresomeQueryis 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.
-
Is this still the state of the art? Is there an FS solution yet?0
-
There is no FS solution yet, but we are closer -- a number of changes are in the works, that when combined, will make it possible to set part names and colors in FS.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc2
-
Bumping this thread. Is this still the best way? Very much looking forward to a FS solution.0
-
The state is still unchanged but we're very close to releasing this ability.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc2



