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.
How to add a part length to a part name
I often use extruded aluminium lengths to build machine
enclosures for customers, and when I have finished the design I export the
model as a Parasolid.
When designing the model the length of each extrusion is
defined by a Configuration variable.
My clients need to have the length of each extrusion in
the part name so that they know what to order, for example, “Alprofil 40 x 40 Light
L1000”, where L1000 is the length in mm. Is there any way to append L1000
automatically to the Part Name?
I appreciate that this will have to be done using
FeatureScript and would appreciate any help.
Thank you.
Best Answers
-
I believe if the "variable" is from a drop down pick list then the answer is yes and directly from the config table, no FS required.If it's from an actual variable then answer then the answer is not today. I believe there could be a workaround using individual "Measure Distance" features to wrap back into the names but what we really want it to be able to directly read the part properties values.Owen S.Business Systems and Configuration Controller
HWM-Water Ltd5 -
@owen_sparks - to make it work for extrusions, you would take our code for extruding (publicly available) and add these couple of lines. You will already have the extrusion depth (for a blind extrusion). For other types, you would need a few more lines to figure out exactly what the distance was.
The example i posted was just a quickie to show how to change the name of a feature
Philip Thomas - Onshape5 -
@owen_sparks - The problem with the 'Beams' custom feature is that it can make multiple extrusions with miters and other end treatments.
That makes it hard to roll up to a single value in the feature name.Philip Thomas - Onshape5
Answers
-
I believe if the "variable" is from a drop down pick list then the answer is yes and directly from the config table, no FS required.If it's from an actual variable then answer then the answer is not today. I believe there could be a workaround using individual "Measure Distance" features to wrap back into the names but what we really want it to be able to directly read the part properties values.Owen S.Business Systems and Configuration Controller
HWM-Water Ltd5 -
Thanks. It is from an actual variable so I will see what arrives to do it in the future.0
-
David - here is a simple example of how to do this


https://cad.onshape.com/documents/61e112bec493ae9f0cdd1eef/w/422f340a0bd2767715b1fc6e/e/4e59cdbeeaf56dc6b10245a3annotation { "Feature Type Name" : "NAME OF FEATURE", "Feature Name Template" : "Feature Tree Name (#volume)" }export const hoseBead = defineFeature(function(context is Context, id is Id, definition is map)precondition{annotation { "Name" : "Pick a Part", "Filter" : EntityType.BODY, "MaxNumberOfPicks" : 1 }definition.myPart is Query;}{var partVolume = evVolume(context, {"entities" : definition.myPart});setFeatureComputedParameter(context, id, {"name" : "volume","value" : partVolume});});
Philip Thomas - Onshape1 -
Hi @philip_thomas, nice feature.I believe were after a length for a cutting list here. Is there any way to extract a length from a part?Cheers,Owen S.Business Systems and Configuration Controller
HWM-Water Ltd0 -
And insert it to part NAME so that it's defaulted on export name too..//rami0
-
@owen_sparks - to make it work for extrusions, you would take our code for extruding (publicly available) and add these couple of lines. You will already have the extrusion depth (for a blind extrusion). For other types, you would need a few more lines to figure out exactly what the distance was.
The example i posted was just a quickie to show how to change the name of a feature
Philip Thomas - Onshape5 -
Excellent, thanks for all the help, I will give it a go
0 -
@philip_thomas Good point Sir, hadn't thought of that. The same method sounds really useful in the beams FS too.Thanks for the nudge,Owen S.Business Systems and Configuration Controller
HWM-Water Ltd0 -
@owen_sparks - The problem with the 'Beams' custom feature is that it can make multiple extrusions with miters and other end treatments.
That makes it hard to roll up to a single value in the feature name.Philip Thomas - Onshape5 -
@owen_sparks - did you get anywhere with this for ‘Beams’ ? I’m completely new to OnShape ( from Inventor ) and this would really be useful as a stopgap measure for pipe lengths while I get my head around the new ways of working.0
-
Make sure you are using the correct up to date version of Beams. It will add the length for each beam in the part name and show a cut list in the custom table icon on the right.Senior Director, Technical Services, EMEA0
-
I didn't follow it up Stuart but following Neil's comment I will check it out as it seems to be solved. By the way I came from SolidWorks and love Onshape so much more.0
-
NeilCooke said:Make sure you are using the correct up to date version of Beams. It will add the length for each beam in the part name and show a cut list in the custom table icon on the right.@NeilCooke I have FeatureScript Beams official v16 and I don't get the beam length showing. Any ideas would be appreciated ?
Many thanks.
0 -
I removed the length from the feature because it does not take into account beams that have been manually trimmed afterwards. Open the custom table icon on the right to see the cut lengths.Senior Director, Technical Services, EMEA0





