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.
What is the relationship between context in the editingLogic function and in the feature?
dave_cowden
Member, Developers Posts: 475 ✭✭✭
Based on a simple experiment with set/get Variable, it seems that the context passed to the editingLogic function and the context passed to the feature are not the same. This surprised me.
I'm looking at a use case in which the editingLogic function needs to construct some geometry in order to adjust user inputs. I'd like to avoid repeating these calculations again in the feature, but then i need these constructions to be accessible ( and mutable ) by the feature.
If I create geometry in the editingLogic function, are those things accessible and mutable if thy are passed to the feature via the definition?
I know that performance will be a concern if i'm getting into creating geometry in the editingLogicFunction, but in this case, there's no way to make a nice-to-use feature without it.
I'm looking at a use case in which the editingLogic function needs to construct some geometry in order to adjust user inputs. I'd like to avoid repeating these calculations again in the feature, but then i need these constructions to be accessible ( and mutable ) by the feature.
If I create geometry in the editingLogic function, are those things accessible and mutable if thy are passed to the feature via the definition?
I know that performance will be a concern if i'm getting into creating geometry in the editingLogicFunction, but in this case, there's no way to make a nice-to-use feature without it.
0
Best Answer
-
ilya_baran Onshape Employees, Developers, HDM Posts: 1,215We've updated/written the documentation since you likely last looked at it: https://cad.onshape.com/FsDoc/uispec.html#editing-logic-function
From there:- The
context
is passed in at a state immediately prior to the feature. After the editing logic function is executed, it will be rolled back to that same state, so changes made to the context will not persist.
Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc5 - The
Answers
From there:
- The
So it's the same context, but changes you make in the editing logic function get rolled back. It basically can't work any other way because regeneration cannot rely on the editing logic function having run at any particular point (merges etc. would not work).context
is passed in at a state immediately prior to the feature. After the editing logic function is executed, it will be rolled back to that same state, so changes made to the context will not persist.