Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Determine which options were selected when previously using a feature to create a part?
ENG_1
Member Posts: 4 ✭
Is there a way to access a piece of information that was input by selecting an enum value to create a feature, the next time that feature is used?
For instance, if I made a feature to create cube with an enum option for filleted edges, would it be possible to then use featurescript to query that cube and determine whether or not the user chose to have filleted edges?
For instance, if I made a feature to create cube with an enum option for filleted edges, would it be possible to then use featurescript to query that cube and determine whether or not the user chose to have filleted edges?
Tagged:
0
Best Answers
-
I think the way to go about this would be to use attributes; the first custom feature would need to set an attribute on the geometry which could then be queried by following custom scripts.
I'd think carefully about whether you actually want this to happen though; it would mean your second feature can only operate on geometry created by your specific first feature, and hidden interactions can often make UI confusing.
Arul Suresh
PhD, Mechanical Engineering, Stanford University5 -
the first solution I can think about is to create in the feature a global variable named for example "<FeatureName>_state" and save to this variable information about user-selected options in the map type like
setVariable("<FeatureName>_state",{"firstApplication":false, "filleted":definition.filleted}) and so on
and the next feature will scan this variable by getVariable()
5
Answers
-
I think the way to go about this would be to use attributes; the first custom feature would need to set an attribute on the geometry which could then be queried by following custom scripts.
I'd think carefully about whether you actually want this to happen though; it would mean your second feature can only operate on geometry created by your specific first feature, and hidden interactions can often make UI confusing.
Arul Suresh
PhD, Mechanical Engineering, Stanford University5 -
the first solution I can think about is to create in the feature a global variable named for example "<FeatureName>_state" and save to this variable information about user-selected options in the map type like
setVariable("<FeatureName>_state",{"firstApplication":false, "filleted":definition.filleted}) and so on
and the next feature will scan this variable by getVariable()
5 -
In this application, I think the attributes would suit you better, as they are associated to geometry and not global.
Say, for instance, you make two cube features, one of which has the fillet option and one which doesn't. Using attributes lets you respond to both of these in later features independently, rather than overwriting the Variable (which is necessarily a global variable).
Arul Suresh
PhD, Mechanical Engineering, Stanford University0 -
@lemon1324 from this point of view you are right
0 -
Or do you just want the next feature created to use the same inputs selected last time? In that case just use "UIHint" : "REMEMBER_PREVIOUS_VALUE"Senior Director, Technical Services, EMEA0
-
Thank you @lemon1324 and @konstantin_shiriazdanov, I believe these are exactly what I was looking for. I think that there might actually be a use for both global variables and attributes in my specific case.
0 -
I agree that Attributes are the tool for the job: One custom feature can set attributes that another can read. Here's a feature with examples as getting and setting attributes (which simply gets the attribute value and prints it to the console):
https://cad.onshape.com/documents/5de745b789701c60bf75fd19/w/3d4893fbd20b641cfbce25c9/e/71100f5de8e6955281228275
0




