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.

Custom Feature Part Name (Ovyl)

EvanReeseEvanReese Member, Mentor Posts: 2,675 PRO
edited October 2022 in General
Many of you all have already used the Part Name feature that I wrote (based on some code originally by @NeilCooke). I just pushed a pretty big update to it, so I thought I'd go ahead and make a dedicated post about the feature, which can be a good way for people to find it, ask questions about it, and for me to add update notes as needed.

Here are the updates I made for V10:
  1. It no longer has a dedicated part number area. You just pick whether it should set the part name, part number, or both. I thought having a single field to fill for PN was a pain, and that having up to 6 to work with was nicer. If you need the number to be different than the name, I recommend just using the feature twice in a row.
  2. It handles rounding better. If you're using an expression, you have the option to round it to a certain decimal place. If the output of the expression is a length or angle, then you'll also see the option to choose display units", so that when the number is rounded, it shows the right thing. For example if you give it 1*inch you'll be able to choose "inch" as a display unit and the output will be 1, not 0.0254 (which is 1 inch in meters)
  3. The delimiter character can just be typed so you can use whatever you want.
Many of these updates are likely to break any existing models they're used in, so I recommend not updating places it's already been used, and just using V9 for new features.

Evan Reese
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com
Tagged:

Comments

  • julian_julian372julian_julian372 Member Posts: 20 ✭✭
    Hi Evan,
    thankyou so much for this FS, It is absolutely amazing. I have been using it alot with 'configurations' for part naming and part numbering.
    Keeping my documents clean and labeled nicely. Especially when using variable configured parts into Assemblies. The part names and part numbers all now make sense. More so the Part Names.

    I was having a lot of issues initially where the Parts Names were not getting updated in existing part studio projects., I was finally able resolved my issue by right click Part, selecting properties and resetting all properties. Then everything started to work as expected.
  • EvanReeseEvanReese Member, Mentor Posts: 2,675 PRO
    @julian_julian372 Glad it's helpful. I know it's been handy for us!
    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • Zabi_GhafarZabi_Ghafar Member Posts: 2

    Hi Evan,

    Thank you for this custom feature it has been an absolute lifesaver. I did notice however that the max number of segments you could have is limited to 6. Is there a way I can increase the number of segments?

  • EvanReeseEvanReese Member, Mentor Posts: 2,675 PRO

    Wow I never thought anyone would hit that limit haha. I'll take a look when I can. You might be able to work around it for now by getting more than 1 out of a segment using toString() functions and ~ for concatenation. You can also stretch the feature UI wide to have more room to read since it will become long.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • _anton_anton Member, Onshape Employees Posts: 501 image

    You could rework the feature to use an array parameter instead - unlimited segments that way.

  • EvanReeseEvanReese Member, Mentor Posts: 2,675 PRO

    Thanks for the suggestion! It's been a while since writing this (and I based most of it off of one by Neil). I do recall starting with an array param and hitting a dead end somewhere with that. Might have just been lack of code skill at the time. Now that we can right click a string field and convert to expression this feature is probably due for a full V2 anyway, so I'll give it a look.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • marci_van_dortmarci_van_dort Member Posts: 14

    Thanks for this FS Evan, I've used it quite a bit for labeling configurable parts, but there were some UI elements that annoyed me so I decided to fix them.

    Here's what I changed:
    - you can now add a space around the separator (I think this reads more easily)
    - the segments are now an array, which means you can add as many as you like, but more importantly, you can reorder them.
    - the option to round a value only appears if the expression actually is a value with units.

    If anyone else wants to use this, you can find it here: Part Name FS

    she/her

  • EvanReeseEvanReese Member, Mentor Posts: 2,675 PRO

    This is one I'd do pretty differently if I re-wrote it today. Love those changes. I think the array thing won't be configurable, right? If I recall that was the reason for not doing it that way.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • eric_pestyeric_pesty Member, pcbaevp Posts: 2,467 PRO
    edited November 10

    @marci_van_dort:
    Have you tried the set property FS?

    Could be an alternative depending on what you are trying to do…

    https://cad.onshape.com/documents/861d68af1cee67efb9e4843d/w/53981180c0515118622d7818/e/30f1b225bf4ab0be37fc09b2

    Also the variable to string is quite useful:
    https://cad.onshape.com/documents/19dacc01596e7c326bbfb137/v/c0b9911b5033a220bcbe87e5/e/16035d1ed4a973a81c4d8bc0

  • marci_van_dortmarci_van_dort Member Posts: 14

    Huh indeed, I hadn't realized they weren't configurable. Though that is fairly easily worked around by using a variable and configuring that instead.

    she/her

  • marci_van_dortmarci_van_dort Member Posts: 14

    Thank eric, I'll keep that in mind for the future. For now just setting the part name suffices for me

    she/her

  • vanowmvanowm Member Posts: 111 ✭✭

    This is a very useful feature, thank you!

    Would you add a note, that this FS only works on parts that hasn't been renamed manually. If a part was renamed manually, user must use Reset ALL button in part's properties, which is a bummer…

Sign In or Register to comment.