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.
FS to remember previous selections
ben_partouch
Member, csevp Posts: 134 PRO
Hi all,
Anyone with suggestion on how to get my custom feature to remember the selections from the previous use?
(I mean only in the same part studio)
This was brought up here a while ago but I couldn't really use the info in the discussion.
Thank you.
0
Comments
I actually just wrote a blog article about this. Another user messaged me with the same question.
You can read the article on my website:
https://www.smartbenchsoftware.com/post/reading-previous-feature-inputs
It includes a sample feature if you want to see it in action.
Custom FeatureScript and Onshape Integrated Applications
Thanks @Caden_Armstrong . That would be me, as I was wondering about the likelihood of this IR being possible. You managed to quickly implement a solution to it.
I have some thoughts on the topic, but I'll add it to the IR
Custom FeatureScript and Onshape Integrated Applications
@Caden_Armstrong Thank you! I'm very excited to give this a try.
@Caden_Armstrong if I understand correctly this should work for queries as well?
It works for everything else but the queries.
Thank you🙏
@ben_partouch The way I demoed here is pretty similar to what Caden shows in his article except he's storing the queries with setAttribute() not setVariable(). Happy to answer questions as well.
The queries will work, if they are still valid. If operations happen in between that change entity IDs, the queries are no longer going to resolve.
Custom FeatureScript and Onshape Integrated Applications
@EvanReese, @Caden_Armstrong,
Thank you both. Much appreciated🙏
I shifted to Evan's method only because it's not tied to an external feature I wanted to keep things simple as this is already pretty complex for my FS knowledge.
I still can't make it to work. Maybe I'm not placing the getVariable function in the right place. The executing part of my code is pretty busy, mostly with functions that measure my selections. Should I share this with you?
Thank you.
I think I got it. Thank you!
@EvanReese what if I have multiple queries? Should I duplicate the relevant snippets? Thank you.
@ben_partouch Caden's way can be within the same feature too fyi. I can't think of any big pros/cons to either, but would love to learn if there are any.
If you have multiple queries, then yes, in principle you could duplicate those parts of the code, but I think if you're doing it multiple times or using this technique in more than one custom feature, you should write them into a reusable set of functions. It makes the code more readable, and makes edits and bug fixing easier.