CAD代码里没有UndoManager这个指令
时间: 2024-02-24 17:58:58 浏览: 26
抱歉,我之前的回答有误。在CAD中没有UndoManager这个对象,而是使用UndoSubcommand方法实现撤销操作。
你可以在每次创建标注之后,调用CAD的AddToUndo方法,将该操作添加到撤销列表中。当你需要撤销操作时,调用UndoSubcommand方法,逐步撤销每个标注。
以下是示例代码:
```csharp
// 创建第一个标注
Entity entity1 = new Entity();
// ...
// 将第一个标注添加到撤销列表中
Application.DocumentManager.MdiActiveDocument.Database.AddToUndo(new UndoAdd(entity1));
// 创建第二个标注
Entity entity2 = new Entity();
// ...
// 将第二个标注添加到撤销列表中
Application.DocumentManager.MdiActiveDocument.Database.AddToUndo(new UndoAdd(entity2));
// 创建第三个标注
Entity entity3 = new Entity();
// ...
// 将第三个标注添加到撤销列表中
Application.DocumentManager.MdiActiveDocument.Database.AddToUndo(new UndoAdd(entity3));
// 逐步撤销标注
while (Application.DocumentManager.MdiActiveDocument.Database.UndoLast() != null)
{
Application.DocumentManager.MdiActiveDocument.Database.UndoLast().UndoSubcommand();
}
```
注意,上述代码只是示例,具体实现可能需要根据你的代码进行调整。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)