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.

Set Property (New Custom Feature!) 🆕

MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
edited July 2024 in FeatureScript

Set Property (New Custom Feature!)


Set Property allows you to:

  • Dynamically set the properties of your part or multiple parts.
  • Set custom properties.

Tips:

  • Custom property ID's are found in your company settings.
  • Right click on any value input to convert it to expression. This means you can use variables to drive the values.
  • Want more cool custom features? Visit https://www.cadsharp.com/featurescripts/




Do you spend hours everyday in Onshape? Consider automating your process with custom features and API.
CADSharp specializes in custom features and API.



Learn more about the Gospel of Christ  ( Here )

CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴

Comments

  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
    edited July 2024

    Supported Properties
    • Name
    • Material
    • Appearance
    • Description
    • Part Number
    • Vendor
    • Project
    • Product Line
    • Title 1
    • Title 2
    • Title 3
    • Mass Override
    • Exclude From BOM
    • Not Revision Managed
    • Unit of Measure
    • Custom 1
    • Custom 2
    • Custom 3


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • Stefan_BregStefan_Breg Member Posts: 7

    Toll dass ihr das macht! Danke dafür!

  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO

    Sure thing! 😎


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • Jon_HJon_H Member Posts: 37 PRO
    edited March 13

    Hi @MichaelPascoe and thanks for the script ! Maybe I'm doing something wrong but when using the script to change the name of a part whose name had previously been manually changed, it doesn't work.

    https://cad.onshape.com/documents/d46d641aba26104e94b70a37/w/5a96188877debc677f6c3507/e/c137d8b212e42c0fb242f04a

    I can get the name to change and make that dynamic by linking it to variables and so on, it all works great. Just not if I previously name the file manually which is the case most of the time as I don't necessarily plan in advance to need to configure the name.

  • PattabiPattabi Member Posts: 54 ✭✭

    @Jon_H You can click on reset all in the properties tab. Then it works see the video below.

    Set Property.gif
  • Jon_HJon_H Member Posts: 37 PRO

    Thanks @Pattabi_Kakumanu for the workaround ! At least this restores the script functionality, but it also clears all the other properties which then need to be manually re-entered, not very practical. I hope there is a way for the featurescript to detect that it needs to reset the name property and that it is possible to reset only one field.

  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
    edited March 13

    @Jon_H Currently this is one of Onshape's limitations. FeatureScript is unable to override manually set properties. Resetting the property like Pattabi showed, is the only way to reset that specific property to allow FS to set it.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
    edited March 17

    .

    Update!

    https://cad.onshape.com/documents/861d68af1cee67efb9e4843d/w/53981180c0515118622d7818/e/65b0c9acba56e6a4786405…

    • Name changed to Get/Set Property.
    • Added option to (GET) property.
      Note: Due to how Onshape currently works, get property is not live in the feature tree.
      So to update it, you will have to manually open the feature and click the Refresh button.
    GetSetProperty Demo.gif

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 156 PRO

    I need to check the forums more frequently, I was struggling to get and set materials properties because they exist outside of normal runtime and here you go dropping the solution to my problem 2 weeks ago with a more elegant refresh button to boot.

  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
    edited April 2

    .

    Update!

    https://cad.onshape.com/documents/861d68af1cee67efb9e4843d/w/53981180c0515118622d7818/e/65b0c9acba56e6a4786405…

    • Name changed to Property / Attribute.
    • Some properties can now be applied to faces.
    • You can now Get / Set attributes. (This is useful when transferring data to downstream studios via derived parts.)

    (TIP: If you intend to keep data with your part through export and import outside of Onshape, then use Properties not Attributes.)

    image.png

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • EvanReeseEvanReese Member, Mentor Posts: 2,489 ✭✭✭✭✭

    This feature just keeps getting better! GET is a big deal

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 156 PRO

    GET is one thing, but I think you're burying the lede here with that comment about property exports to external software @MichaelPascoe . You mean to tell me that this whole time the parasolid file format supports metadata for materials and tagging faces for custom properties? If so I have some unkind words for the CAMWorks developers and their implementation of parts interrogation and the literal man-years wasted re-clicking on parts for nesting orientation and material schedules.

  • FladdieFladdie Member Posts: 4

    Hi @MichaelPascoe ,

    Thank you for your excellent “Set Property” custom feature—it's been extremely helpful in managing metadata in Onshape.

    I’ve run into a specific issue when working with imported parts (e.g. STEP files):

    1. I import a standard part such as a DIN 912 M5x20 screw.
    2. Onshape automatically assigns the part name “DIN 912 M5x20” based on the STEP file.
    3. I modify the geometry (e.g., make the screw longer to match an M5x30).
    4. Then I try to update the part name using your custom feature.
    5. However, the name does not change—it becomes #partname or simply stays the same.

    The "Reset all" button is grayed out in the Properties tab — so there is no way to reset the name.

  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
    edited April 29

    @Fladdie can you share an example document or part file? I'll take a look.

    @EvanReese ty 😎

    @Derek_Van_Allen_BD Yes, you can keep metadata with parts. Here, I'm getting the face property that I embedded, exported, then imported into Onshape:

    image.png

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO

    @Derek_Van_Allen_BD Today I just used it to transfer a measured variable from one studio to another. Pretty useful.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
    edited May 2

    .

    Update!

    https://cad.onshape.com/documents/861d68af1cee67efb9e4843d/w/53981180c0515118622d7818/e/65b0c9acba56e6a4786405…

    • Added Features input. This is useful for setting properties or attributes of bodies created by a specific feature. A use case would be setting a property for all parts created by a Frame feature.
    image.png

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
    edited May 22

    .

    Update!

    https://cad.onshape.com/documents/861d68af1cee67efb9e4843d/w/53981180c0515118622d7818/e/65b0c9acba56e6a4786405…

    • Added OppositeDirection.png Query Finder for retrieving or making automated selections. See the Query Finder forum post on how to use it.
      Tip: You can set selections for the query finder using the SetQuery.png Set Query Attribute feature.
    • Added new set operation "Identity". You can now set the identity of an entity to stabilize downstream features.
    • Added new get operation "Transient id". You can now get the transient id of an entity.
    • Added mate connector input type when setting attributes.
    • Fixed bug where feature would fail when getting a non string attribute.
    image.png

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • Richard_InvRichard_Inv Member Posts: 34 PRO
    edited July 2

    Is it possible to get this to override onshape's Configured Properties?

    I've set most of my part's properties with Configured Properties (as different part sizes have different part numbers, descriptions etc), but I want only the name to be controlled by this script (I'm using your Convert To String custom feature to achieve this).

    In the example below, I'd want the part name to be '125mm' which works perfectly if I clear the Configured Properties, but gets overridden if I don't. Even though I haven't used the Configured Properties to set the part name

    image.png
  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO

    @Richard_Inv Once a property has been set manually, you have to clear all properties in order to reset it to allow features to override the properties. It would be nice if we could override, but properties are outside the scope of the feature tree; which is probably the reason we have to manually reset the properties. Having the option to reset only one property would be really helpful.

    Are you saying that even if you don't configure the name property, it will not let you override it unless you reset all properties?

    I recommend clearing all properties and using the Property / Attribute feature to control all of them. This way you don't have to mess with the property configuration panel. If you need help with logical statements, let me know and I can give some quick tips or take a look at your document.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • ivan_gavendaivan_gavenda Member Posts: 3

    Hi. Even after Reset All properties, I don't see new ones (not in property table, not in assembly BoM). I've tried to create also very simple file with just 1 property to control, but I don't see a way how to make it work. I've spend whole yesterday try to understand the basics of FeatureScript, but this is definettely not my area and fill-in attached SET dialog took me quite a time, but still no result. How can I make it work? - To have SET PROPERTY in part properties and in assembly BoM.

  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO

    @ivan_gavenda It looks like you don't have any parts selected in your feature. If that doesn't fix it, please share a link to your document and I'll take a closer look to see what the issue could be.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • ivan_gavendaivan_gavenda Member Posts: 3

    @MichaelPascoe You are right, No parts were selected ( I was so focused on new stuff, that I overlooked this basic condition). Now it is working fine. Thank you.

  • paulpat1000paulpat1000 Member Posts: 3 PRO

    I think I'm misunderstanding something fundamental. I wish use this awesome tool to set part properties where the part belongs to a configuration scheme. I had previously come to a conclusion that this doesn't work. Now I am unsure.

    My understanding is that a part property is either (1) set for the entire configuration group (all configs) by right-clicking the part and setting properties there (eg all parts are from Vendor X); or by (2) the "configured properties" table that can individualize the properties on a per-config basis (eg vendor part number for config Y). Furthermore, I understanding that the SET feature here basically automates method 1. But this means that a property set this way will effectively apply an individualized property to all configurations, which of course is not the desired outcome.

    I'm pretty sure I'm missing something and would appreciate being corrected.

  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
    edited July 31

    @paulpat1000 The Property / Attribute feature is for setting properties without having to use the "configured properties" tab. I found that the configured properties tab doesn't work as I would like. Setting the properties with this feature allows the feature to be configured with normal configurations instead of property configurations.

    If you want to control a single property input with more than one configuration input (ex: A list as well as a variable as well as a checkbox), then instead of right clicking the input and configuring it, you would need to have the different configurations drive a variable or multiple variables and then use that variable in the Property / Attribute feature.

    If you share an example document of what you are trying to do, I will show you how to implement the Property / Attribute feature for your document.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • lennart_miene143lennart_miene143 Member Posts: 2 PRO

    Hi @MichaelPascoe, is there also a possiblity to set the system property "Category"? I activated "multivalue" for Category and created some own categories to organize the visibility of the properties.

    I tried it with custom Property and its ID but it did not work.

  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO

    @lennart_miene143 not that I'm aware of. This could be a special property that can only be set by the system. Depending on your use case, there may be another way to achieve what you want. What is your end goal?


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • lennart_miene143lennart_miene143 Member Posts: 2 PRO

    @MichaelPascoe I created 4 categories with different properties to show up in the properties of a part. If I always showed all of them at once it would be a mess. Furthermore, I created a custom feature to assign a correct part number to a selected part based on its category and on the input fields that show up in the feature dialog.
    Here is one example: Fill out all the inputs and the properties of the part will have the same values as well as a part number that is calculated out of these inputs:

    grafik.png

    grafik.png

    Here is another example with further custom properties:

    grafik.png


    As we use so many custom properties its quite a mess in the property dialog. So I hid them all and you can only see them when you choose the corresponding category:

    grafik.png grafik.png

    In a part studio I usually trust my custom feature so I think the properties are correct. In an assembly, to be able to look up the correct properties I have to open the properties of a part and always try to select the proper category to show the corresponding custom properties.
    I thought I could avoid this by automatically selecting the correct category and only showing the necessary custom properties. But I don't make a big deal about it since I'm already very happy about the custom feature and the automatic part number.

  • MichaelPascoeMichaelPascoe Member Posts: 2,464 PRO
    edited August 7

    There has to be a way to set or get the Catergory property. It has a property Id, but I'm not sure. Are you setting or getting the Category with your custom feature in the pics?

    Perhaps open an Onshape ticket and ask if it is possible to set the Category property via featureScript. If you figure it out, I'll add it to the feature. 😎


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
Sign In or Register to comment.