Jump to content
Developer Wiki and Function Reference Links Read more... ×
Matthias Ganninger

Import Symbol during a Tool's DoModeEvent throws "Beta Undo Alert 9"

Recommended Posts

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

 

Share this post


Link to post

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

Share this post


Link to post

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 ?

Share this post


Link to post
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.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×