Python States: Is it possible to switch states?

   1265   2   0
User Avatar
Member
575 posts
Joined: Nov. 2005
Offline
Hello,

let's say I have a tool that needs a drawn curve to work on it, resample attributes modifications and so on.
My goal is to have one state, named "modify state" for instance, that allows me to have all the handles and parameter interfaces to work on that curve, and one state to actually draw that curve with a "stroke state".
The "modify state" should have a button that clears the previous stroke and sets the tool into the "stroke state" until the stroke is finished. Now it should return to the "modify state"
Is that possible at all?
I tried this one in a the python state:
self.scene_viewer.setCurrentState("sidefx_stroke") # assuming that I can access this one as well
self.scene_viewer.enterCurrentNodeState()
it does not throw any error, but:
print self.scene_viewer.currentState()
still returns the normal state
any hints where to look at?

thanks for You time
Edited by sanostol - Dec. 27, 2020 08:00:20
User Avatar
Staff
396 posts
Joined: Feb. 2018
Offline
Maybe you could consider handling the functionalities you described as separate editing mode in the same state ? That seems more manageable and would avoid having to implement some complicated logic for switching states.

Your state class implementation would need to derive from the sidefx_stroke class, there is a sample available with the viewer state code generator. You can also look at the sidefx_attribpaint state which is also deriving from sidefx_stroke.
Edited by mabelzile - Dec. 27, 2020 11:46:25
User Avatar
Member
575 posts
Joined: Nov. 2005
Offline
Cool, thank You, I will try that way.
  • Quick Links