Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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

david_goughdavid_gough Member Posts: 5 PRO

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

Answers

  • david_goughdavid_gough Member Posts: 5 PRO
    Thanks. It is from an actual variable so I will see what arrives to do it in the future.
  • philip_thomasphilip_thomas Member, Moderator, Onshape Employees, Developers Posts: 1,381
    David - here is a simple example of how to do this :)



    https://cad.onshape.com/documents/61e112bec493ae9f0cdd1eef/w/422f340a0bd2767715b1fc6e/e/4e59cdbeeaf56dc6b10245a3

    annotation { "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 - Onshape
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    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 Ltd
  • 3dcad3dcad Member, OS Professional, Mentor Posts: 2,475 PRO
    And insert it to part NAME so that it's defaulted on export name too..
    //rami
  • david_goughdavid_gough Member Posts: 5 PRO
    Excellent, thanks for all the help, I will give it a go  :)
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    edited May 2018
    @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 Ltd
  • stuart_wood540stuart_wood540 Member Posts: 6 PRO
    @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.
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    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, EMEAI
  • david_goughdavid_gough Member Posts: 5 PRO
    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.
  • stuart_wood540stuart_wood540 Member Posts: 6 PRO
    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.
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    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, EMEAI
Sign In or Register to comment.