FeatureScript UIHint.READ_ONLY
graham_lock
Member Posts: 277 PRO
Hi,
Does anyone have an example of how to use annotation with UIHint.READ_ONLY?
I essentially want to display a definition.xxx value (purely for user feedback) which is calculated within the feature.
Thank you.
Does anyone have an example of how to use annotation with UIHint.READ_ONLY?
I essentially want to display a definition.xxx value (purely for user feedback) which is calculated within the feature.
Thank you.
0
Best Answer
-
This is how you would setup a read only property
annotation { "Name" : "My Length", "UIHint":UIHint.READ_ONLY } isLength(definition.myLength, LENGTH_BOUNDS);But, setting the property to be calculated in the feature and shown to the user requires using editing logic. It doesn't run in the feature but rather as a step that happens before the feature when the user modifies their inputs. In some cases this will work just fine, but depending on your use case, this might not work well, especially if other operations need to happen first.
Another way you can display a value to the user is to just put out an information level toast.reportFeatureInfo(context, id, "Value I want to show");
This can be used in the actual feature, the downside is that only one piece of info can be shown.www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications1
Answers
-
This is how you would setup a read only property
annotation { "Name" : "My Length", "UIHint":UIHint.READ_ONLY } isLength(definition.myLength, LENGTH_BOUNDS);But, setting the property to be calculated in the feature and shown to the user requires using editing logic. It doesn't run in the feature but rather as a step that happens before the feature when the user modifies their inputs. In some cases this will work just fine, but depending on your use case, this might not work well, especially if other operations need to happen first.
Another way you can display a value to the user is to just put out an information level toast.reportFeatureInfo(context, id, "Value I want to show");
This can be used in the actual feature, the downside is that only one piece of info can be shown.www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
Experts in Onshape Automation - Custom Features and Integrated Applications1 -
Thank you.0
