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: 159 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,140 ✭✭✭✭✭
    Accepted 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: 122 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.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 159 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: 122 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.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 159 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,140 ✭✭✭✭✭
    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: 159 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,140 ✭✭✭✭✭
    Accepted 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: 159 PRO
  • shawn_crockershawn_crocker Member, OS Professional Posts: 159 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,140 ✭✭✭✭✭
    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: 159 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,140 ✭✭✭✭✭
    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: 159 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: 159 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,140 ✭✭✭✭✭
    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: 159 PRO
    edited June 14
    @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.
Sign In or Register to comment.