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 COLOUR, MASS, AND CUSTOM PROPERTY OF GEOMETRY CREATED BY FEATURE IN ONE GO

shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
I have modified the standard sheet metal model feature to be more straight forward for me.  If I select a particular material in my custom sheet metal feature, at the moment it sets the thickness, inner rad and kfactor to the appropriate values.  Would be create if it also could set the colour, mass and assign a string to a material custom property.  Is there a way to have a feature assign properties to bodies it is creating at the same time?

Best Answer

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    Answer ✓
    Yes, if the operation expecting to get body to assign property to, that means you need to feed it a query which resolves to a body. id is Id in the function declaration means that on the second argument this function expecting to get a value of Id type and use it in the function body as variable named "id"

Answers

  • Alex_KempenAlex_Kempen Member Posts: 258 EDU
    setProperty (along with qCreatedBy, usually) can be used to add whatever properties you like to entities created by a feature. Do note, however, that user defined properties will always take precedence over FeatureScript defined properties; if a user overrides a FeatureScript set value, the user's override will take precedence.
    Software Developer at Epic Systems
    FRC Design Mentor - Team 1306 BadgerBots


  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
    @Alex_Kempen
    Thanks again.  I'm not sure though, how to reference the bodies that are being created by the feature.
  • Alex_KempenAlex_Kempen Member Posts: 258 EDU
    qCreatedBy(id, EntityType.BODY) will return a query for every body made by the current feature. If you pass in a sub id to your call of the sheet metal FS (i.e. id + “sheetMetal”), use that in place of “id” in qCreatedBy. However, you probably don’t need a subId for your feature since you’re only really doing one operation.
    Software Developer at Epic Systems
    FRC Design Mentor - Team 1306 BadgerBots


  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
    OK.  So the "q" things can query geometry that is being generated.  For risk of starting to look like an idiot, What is the id supposed to be set to?  once the qCreatedBy executes, how do I reference what is inside.  Or maybe there is a definition of qCreatedBy somewhere I can read?  I'm starting to wonder if its just me or is the onshape featurescript doc exceptionally brief and missing a lot of definitions?
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    The functions starting from q are generally for consructing queries, the query is a condition for picking context entities. All onshape features dealing with queries are able to resolve them internally and find specific entities to proceed with. So the first thing to know about the queries - they are filtering conditions, not the entities itself,untill they are not evaluated. The qCreatedBy() query constructor function requares the id of the context modifying operation and resolves to the entities created by the operation with specified id, or by all the operations for which id is a root. If you want all the bodies created in the scope of the feature you can just use the following query: qCreatedBy(id, EntityType.BODY). The id variable you passed into the query constructor is the same variable that was passed into the current feature, so its a root id and query based on it will resolve to all the bodies created using the id variable as a parent id.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
    @konstantin_shiriazdanov
    That makes sense.  There is an "id is Id" defined in the opening feature function.  So I would use "qCreatedBy(id, EntityType.BODY)." directly inside of the function that is attempting to set a custom property?
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    Answer ✓
    Yes, if the operation expecting to get body to assign property to, that means you need to feed it a query which resolves to a body. id is Id in the function declaration means that on the second argument this function expecting to get a value of Id type and use it in the function body as variable named "id"
  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
    @konstantin_shiriazdanov
    @NeilCooke

    So I have managed to set things up working.  Mass, colour and a custom property that holds a material callout and a raw material code, all get updated during the creation of the sheet metal feature.  My problem has become that the custom properties go blank after I perform additional operations on the part like chamfer or put a hole through a face.  Is there a way to stop this from happening?  I notice the beam feature does not suffer from this so I'm wondering if it is just a sheet metal symptom.
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    I don't know much about sheet metal features, but it definitely shouldn't behave like that. Can you share the example?
  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
    @konstantin_shiriazdanov
    Here is the public document. CUSTOM SHEET METAL FEATURES | Part Studio 1 (onshape.com).  I set the custom property to update the standard description property that everyone has just so you can see what's happening.
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    This is something really strange for me. I can't see how can this happen. However if you finish sheet metal part first, this property reset is no more occuring, so it's something specific to sheet metal I beleve. You would better reach support with this.



  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
    @konstantin_shiriazdanov
    Thanks for the help.  It seems like the body being active, other features keep resetting it.  Must be something in the background doing some work on the body in extra to the feature being used to grantee the sheet metal remains un-foldable.  This is what I'm imagining with absolutely nothing concrete to base it on.  Does @NeilCooke has any ideas?  I probably will try to accomplish this same thing but by modifying the finish sheet metal feature.  I want to include a flat pattern bounding box calculation anyways so the finish command may be the best place for all this to happen in one go.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
    In case any one out there is interested @Alex_Kempen @NeilCooke. I have tried using setAttributes and getAttributes to feed information down to my finishing feature.  The bodies attributes also get lost when features modify the bodies in between the two features.  I have created a support ticket for this but if anyone has an idea to workaround this, I would love to hear it.  At the moment I'm thinking of storing things in variables to be pulled in later.  Problem I'm seeing is multiple sheet metal part features over writing the part studio variables and the finish sheet metal feature being unable to correctly apply properties.  I keep telling myself to just suck it up.  But evetime I use my finish sheet metal feature and have to select the same material again that I previously selecting in the sheet metal model feature, it feels so wrong.  The finish sheet metal feature should be able to know what to do based on previous information.  I'm wishing I could somehow hack the deeper level sheet metal functions.  The flange feature, for instance, knows to set things how the parent feature was set.  I'm wishing I could pull in the info the same way the other sheet metal features do.
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    I may have a version of why this is happening - you assign property to the solid body (while it still being active sheet metal) but when you modify active sheet metal solid the modifying operation actually interacts with underlying surface body and then sm solid body is recreated by thickening it. And according to behavior we see, this sm solid body is actually a new body and for some reason it do not inherits properties assigned with FS.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO
    edited June 2021
    @konstantin_shiriazdanov I was thinking it was something like that. I'm wondering if there is a way the query the under lying surface and use it to carry the setAttributes down the line. Iv noticed surface looking functions while examining the code. Will have to dig into this some more. Thanks for pointing out and solidifying the fact that the body is indeed being recreated everytime the body it worked. This fact makes sheet metal capability in Onshape feel a little more like they had to hack something to add the functionality. And explains other strange behaviors I have notice in the past that can lead a user to have to fight the system a bit.

    Edit:

    I'm surprised this is an issue. I'm surprised people have not attempted do add these types of user friendly abilities to sheet metal before and already reported it. It's kind of standard everywhere that you can setup predetermined values for your sheet metal and just select one.
  • mitchell_braun924mitchell_braun924 Member Posts: 4 PRO

    @shawn_crocker

    The link for CUSTOM SHEET METAL FEATURES | Part Studio 1 (onshape.com). is broken, I have been trying to work out adding a function to insert a Kfactor based on material and would be interested in seeing how you solved that problem.

  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO

    @mitchell_braun924 Here is a new link. https://trebormanufacturing.onshape.com/documents/7cb3a2aaddb5ef9738251ee3/w/a227091b7cf37b893b5234a4/e/3aa2a86ddc6fe0731bb619c9

    I have revamped that feature I think since that link was posted and the studio id must have changed. The feature is an edited standard feature. I have commented out portions of the standard feature that I either didn't need or needed to override to try and maintain the context of the standard feature. There are a few feature studios in there that work together. One of them is a modified finish feature. The finish feature applies properties to the sheet metal parts. The finish feature provides an option to apply to all sheet metal parts regardless of which parent sheet metal feature created the parts. I messed up a bit and I have noticed sometimes the option will apply properties to parts in the studio that are not actually active sheet metal parts. I haven't taken the time yet to add in a more robust filter method for that feature function. 😁

  • mitchell_braun924mitchell_braun924 Member Posts: 4 PRO

    @shawn_crocker

    Thanks for sharing! My goal has been to edit the sheet metal model feature (Assign kfactor based off thickness & material / assign material and other quality of life features), but it has been eluding me to this point.

  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO

    Yes. As soon as I started into Onshape, the sheet metal feature immediately jumped out at me as "needing work". You will see in the feature there is a cvs import and the values in that gets mapped to an enum selection in the feature. I have always been extremely disappointed that enums cannot be generated from an external source. Its annoying to have to manually change the enum list in the feature every time a new material is added into the csv. I would lve to be able to mod the feature to accept a csv file as a feature input and have the enum list update according to what's in the csv. Maybe some day…. 🤔

  • mitchell_braun924mitchell_braun924 Member Posts: 4 PRO

    @shawn_crocker

    It would help a lot in compartmentalizing information. The one that really annoyed me when I started on this project was the inability of Featurescript to interact with the material library, I went and made a material library only to find out it will be somewhat redundant with any set property I put in.

    How do you have the FeatureList / the imported table csv laid out? I'm guessing that is where you have your thickness/radius/Kfactor?

  • shawn_crockershawn_crocker Member, OS Professional Posts: 937 PRO

    @mitchell_braun924 I did the same thing. Made a material Library just to find out I wasn't going to be able to automate it. I forgot the doc wouldn't let you download the one imported there. Here is a link to the template https://docs.google.com/spreadsheets/d/1d2jfeFvYkBt3GW53Z23xK4Zd6WhGEl6iZRwQv7Xz4Zk/edit?usp=drivesdk

Sign In or Register to comment.