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.

Options

Putting a part number automatically into a text feature

Tess_OkkerseTess_Okkerse Member Posts: 4
Hi all,

We are trying to find a way to automatically put a part number in a text feature. We have found feature scripts where you can configure the text, but we want onshape to grab the part number from the part properties instead of manually changing it in the configured properties. Our final goal is to have every plate we draw automatically engraved with it's part number.

I have looked through basically all the discussions here on the forum website and have so far found 1 person who also asked this question: @Triton_Engineering

Does somebody have a way of doing this? Maybe someone wrote a feature script?

Let me know! Thanks

Tess

Best Answers

Answers

  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,718 PRO

    This is possible with FS. Let me check if there is already something like it.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,718 PRO
    edited August 2023 Answer ✓

    I wasn't able to find any close examples so I worked one up. There is an issue with getting properties in FeatureScript; because they are created after the feature is finished, we have to get them in a separate part of the code called "editing logic". Because of this, the feature will not automatically update if the part numbers change. So we have to re-open the feature to manually update it if the part number ever changes.

    If you are pushing the part numbers instead of getting them from the properties, it is possible to set the part number without needing any refresh button. This is a different strategy. It all depends on how you would like to set your part numbers.

    CADSharp specializes in making custom features and Onshape apps. So let me know if you want to speed up your Onshape workflows and I can get you connected with the right people.

    https://cad.onshape.com/documents/1957f89f0e3f3d2ef6dae9b0/w/8cfa05a045d74aeaa97088d2/e/8bca73c63fa...



    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    Tess_OkkerseTess_Okkerse Member Posts: 4

    I wasn't able to find any close examples so I worked one up. There is an issue with getting properties in FeatureScript; because they are created after the feature is finished, we have to get them in a separate part of the code called "editing logic". Because of this, the feature will not automatically update if the part numbers change. So we have to re-open the feature to manually update it if the part number ever changes.

    CADSharp specializes in making custom features and Onshape apps. So let me know if you want to speed up your Onshape workflows and I can get you connected with the right people.

    https://cad.onshape.com/documents/1957f89f0e3f3d2ef6dae9b0/w/8cfa05a045d74aeaa97088d2/e/8bca73c63fa...


    This looks very promising! Thank you for this feature script!

    I have tried it with our part numbering system. We automatically generate a number that counts up and looks like "PRT-00......" something.
    There is an error generating right now as you can see in the screenshot below.

    Maybe the problem is that we also have letters in our part number system? 

    Can you solve this error? Would be amazing!



  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,718 PRO
    Answer ✓

    Try updating the feature. Should accept text now for part numbers.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
  • Options
    Tess_OkkerseTess_Okkerse Member Posts: 4
    It works perfectly! Thank you! 

    Last question: Is this feature script that you wrote open source? Or not? 

    I cannot seem to find the right button to upload it to our own workspaces
  • Options
    MichaelPascoeMichaelPascoe Member Posts: 1,718 PRO
    edited August 2023

    Yep, completely open source. It is stored within one of the tabs in the link I shared.

    You can add custom features to your toolbar by clicking the "+" button at the top of their document. 

    For my official features, I suggests adding my direct feature to  your toolbar. This way you will get all the updates that get pushed out. But since this is just a quick test, I suggest copying the document, versioning it, then adding that to your toolbar from your own document. You will have to version it, then view that version in order to add your own custom features to your toolbar.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   cadsharp.com/featurescripts 💎
Sign In or Register to comment.