We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Create and then undo several elements together

yahavsa
Contributor

Hello

I create several elements using the ACAPI_Element_Create function in a "for" loop. After that, I'm trying to undo it (using ctrl+z) and right now it undo each element one by one (For example, if I create ten elements in my function and I want to undo it, I have to press ctrl+z ten times).

I'm wondering if there is a way so I can ctrl+z all the elements that I just created all together by using ctrl+z ONE time?

I did try to use the ACAPI_Database_StartClippingSession() function before the "for" loop and then use the ACAPI_Database_StopClippingSession() function at the end of the "for" loop, but it didn't work for me

 

Windows 11, Visual Studio 2022, ArchiCAD 27,  C++

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Viktor Kovacs
Graphisoft
Graphisoft

When you do modifications in Archicad you always need to wrap your changes in a ACAPI_CallUndoableCommand call. Everything happens inside the call will be undo-ed in one step.

 

The code should be something like this:

 

ACAPI_CallUndoableCommand ("Create Walls", [&] () -> GSErrCode {
     // create as many walls as you need
     return NoError;
});

 

 

View solution in original post

1 REPLY 1
Solution
Viktor Kovacs
Graphisoft
Graphisoft

When you do modifications in Archicad you always need to wrap your changes in a ACAPI_CallUndoableCommand call. Everything happens inside the call will be undo-ed in one step.

 

The code should be something like this:

 

ACAPI_CallUndoableCommand ("Create Walls", [&] () -> GSErrCode {
     // create as many walls as you need
     return NoError;
});