Matthias Ganninger Posted October 5, 2018 Share Posted October 5, 2018 Hi, we are trying to import a symbol while handling a ToolModeMessage (VWTool_EventSink::DoModeEvent). That seems to work. However Vectorworks complains shortly afterwards with this message: "Beta Undo Alert 9. The Undo System is thrown-off by last action". Is it allowed to import a symbol during a ToolModeMessage? If yes, any hints on what we could do to satisfy the Undo System? Best Regards, Matthias Ganninger Quote Link to comment
Stefan Bender Posted October 8, 2018 Share Posted October 8, 2018 Hi Matthias, did you start an undo event before importing the symbol? This is absolutely necessary if you do something that affects the undo table such as importing a new object into the drawing or modifying the name lists. Hth, Stefan Quote Link to comment
Matthias Ganninger Posted October 9, 2018 Author Share Posted October 9, 2018 Hi Stefan, thanks for your answer. Explicitly starting an Undo Event before the import seems to help, as long as I do not end it explicitly. When I try to end the Undo event after the import (by calling ISDK::EndUndoEvent) the error comes back. If I leave the Undo step open it seems to work nearly perfect. Our intention with that code was to temporarily import a symbol to read and cache some data. So we were trying to get around the Undo system by not adding the imported object to it (because we immediately delete it before we are finished handling VWTool_EventSink::DoModeEvent). Our solution for now is to start an UndoEvent for the Import and roll it back after we are finished (by calling ISDK::UndoAndRemove). This seems to work. Is this a good idea to do while handling the tool event VWTool_EventSink::DoModeEvent ? Quote Link to comment
JBenghiat Posted October 10, 2018 Share Posted October 10, 2018 On 10/9/2018 at 5:14 AM, Matthias Ganninger said: Our solution for now is to start an UndoEvent for the Import and roll it back after we are finished (by calling ISDK::UndoAndRemove). This seems to work. Is this a good idea to do while handling the tool event VWTool_EventSink::DoModeEvent ? Yes, this is the preferred technique. I do find figuring out which events have built in undo events and which don't a bit of a challenge. The mode bar event does not normally have an undo event attached, as it doesn't usually modify the drawing or data, so it needs an undo event if you are importing a symbol or changing a preference record (i.e. you are coding what happens when the user presses the preferences button as opposed to relying on the default mode bar implementation). You'll notice that if you switch modes, then undo, the mode button does not undo. You'll want to call SupportUndoAndRemove() SetUndoMethod(kUndoSwapObjects) .. do your importing and extracting .. UndoAndRemove() Importing symbols ImportSelectedResource includes a call to AddAfterSwapObject(), so you don't need to add that manually. Unless you're just storing the data in a static variable, before you write the cache data to the file, you want to start another undo event SetUndoMethod(kUndoSwapObjects) do your store, and end the undo event. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.