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.

editing logic + UIHint REMEMBER_PREVIOUS_VALUE

imants_smidchensimants_smidchens Member Posts: 62 EDU
I'd like to write a color picker&placer featurescript that works across documents - potentially expanding to more than just color later - using the remember previous value UIHint, but it appears as though the definition returned by editing logic cannot be remembered.

At first I thought it might be the parameter type causing issues, but this persists across various parameter types, including ones that can definitely be remembered normally.

I could just have it get the color and make users copy it to their clipboard, then assign it manually, but where's the fun in that?

Answers

  • Alex_KempenAlex_Kempen Member Posts: 244 EDU
    If I recall correctly, REMEMBER_PREVIOUS_VALUE doesn't work for anything parameters, but it does for string parameters. So you might have to jump through some hoops to serialize and de-serialize your values into strings first.

    For your use case, you may find it easier to provide tooling for both defining and then using a variable containing an arbitrary color; this would allow users to store the variables in a manner of their choosing (e.g. variable studios) and use them freely. That being said, that workflow may still be worse than simply saving and using custom colors directly via the built in color picker widget.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



  • imants_smidchensimants_smidchens Member Posts: 62 EDU
    If I recall correctly, REMEMBER_PREVIOUS_VALUE doesn't work for anything parameters, but it does for string parameters. So you might have to jump through some hoops to serialize and de-serialize your values into strings first.

    For your use case, you may find it easier to provide tooling for both defining and then using a variable containing an arbitrary color; this would allow users to store the variables in a manner of their choosing (e.g. variable studios) and use them freely. That being said, that workflow may still be worse than simply saving and using custom colors directly via the built in color picker widget.
    Unfortunately this doesn't work for any parameter type (as far as I can tell) - I tried splitting the color into seperate r/g/b/alpha channels, but as soon as editing logic acts on the UI, it no longer remembers any values for the next time.

    I think you might be right - better to just use the default color picker widget (though I had hoped to expand this to be applicable to more than just colors)
Sign In or Register to comment.