如何获取绘图草图是否正在编辑? (Autodesk Inventor C++ API)
How to get if the drawing sketch is being edited? (Autodesk Inventor C++ API)
我需要在 Inventor 中添加草图并进行编辑。但是,如果已经在编辑另一个草图,我的程序将终止,甚至 try/catch 也无济于事。我找不到草图的 属性 显示它是否正在编辑。我的主要代码部分在这里:
// All of these three functions pass try/catch perfectly. Program never terminates
Inventor::Application^ App = (Inventor::Application^)Marshal::GetActiveObject("Inventor.Application");
DrawingDocument^ Doc = (DrawingDocument^)App->ActiveDocument;
Sheet^ Sh = Doc->ActiveSheet;
DrawingSketch^ Sk;
try
{
Sh->Sketches->Add();
Sk = Sh->Sketches[Sh->Sketches->Count];
Sk->Edit(); // Crushes the program completely if another sketch is being edited
}
catch (...)
{
return;
}
我试图循环浏览所有草图并将它们全部关闭。这种行为方式我无法理解。
try
{
// Note: in Inventor indexes definitely start from 1
for (int i = 1; i <= Sh->Sketches->Count; i++)
{
Sk = Sh->Sketches[i];
Sk->ExitEdit();
}
}
catch (...)
{
return;
}
例如,当草图 2 打开时,尝试关闭草图 1 的第一个循环 (i = 1) 以某种方式关闭了草图 2。而现在无法关闭的第二个迭代 (i = 2) sketch 2,因为它已经关闭,调用 'catch' 并进一步调用 'return'.
我不熟悉 C++,但这里是 VBA 如何检测绘图草图处于编辑模式的示例
Dim oDrawing As DrawingDocument
Set oDrawing = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDrawing.ActiveSheet
Dim editedObject As Variant
Set editedObject = ThisApplication.ActiveEditObject
If editedObject.Type = ObjectTypeEnum.kDrawingSketchObject Then
Dim activeEditSketch As DrawingSketch
Set activeEditSketch = editedObject
activeEditSketch.ExitEdit
End If
Dim oSketch As DrawingSketch
Set oSketch = oSheet.Sketches.Add()
我希望,您可以将此代码转换为 C++
我需要在 Inventor 中添加草图并进行编辑。但是,如果已经在编辑另一个草图,我的程序将终止,甚至 try/catch 也无济于事。我找不到草图的 属性 显示它是否正在编辑。我的主要代码部分在这里:
// All of these three functions pass try/catch perfectly. Program never terminates
Inventor::Application^ App = (Inventor::Application^)Marshal::GetActiveObject("Inventor.Application");
DrawingDocument^ Doc = (DrawingDocument^)App->ActiveDocument;
Sheet^ Sh = Doc->ActiveSheet;
DrawingSketch^ Sk;
try
{
Sh->Sketches->Add();
Sk = Sh->Sketches[Sh->Sketches->Count];
Sk->Edit(); // Crushes the program completely if another sketch is being edited
}
catch (...)
{
return;
}
我试图循环浏览所有草图并将它们全部关闭。这种行为方式我无法理解。
try
{
// Note: in Inventor indexes definitely start from 1
for (int i = 1; i <= Sh->Sketches->Count; i++)
{
Sk = Sh->Sketches[i];
Sk->ExitEdit();
}
}
catch (...)
{
return;
}
例如,当草图 2 打开时,尝试关闭草图 1 的第一个循环 (i = 1) 以某种方式关闭了草图 2。而现在无法关闭的第二个迭代 (i = 2) sketch 2,因为它已经关闭,调用 'catch' 并进一步调用 'return'.
我不熟悉 C++,但这里是 VBA 如何检测绘图草图处于编辑模式的示例
Dim oDrawing As DrawingDocument
Set oDrawing = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDrawing.ActiveSheet
Dim editedObject As Variant
Set editedObject = ThisApplication.ActiveEditObject
If editedObject.Type = ObjectTypeEnum.kDrawingSketchObject Then
Dim activeEditSketch As DrawingSketch
Set activeEditSketch = editedObject
activeEditSketch.ExitEdit
End If
Dim oSketch As DrawingSketch
Set oSketch = oSheet.Sketches.Add()
我希望,您可以将此代码转换为 C++