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.

FeatureScript UIHint.READ_ONLY

graham_lockgraham_lock Member Posts: 148 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.

Best Answer

  • Caden_ArmstrongCaden_Armstrong Member Posts: 180 PRO
    edited July 17 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 --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications

Answers

  • Caden_ArmstrongCaden_Armstrong Member Posts: 180 PRO
    edited July 17 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 --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • graham_lockgraham_lock Member Posts: 148 PRO
    Thank you.
Sign In or Register to comment.