我需要在指定的 Solidworks 图纸中删除不必要的细节视图,但我需要使用后期绑定。首先,我尝试从特征树中删除细节视图,但随后它只删除了细节视图,留下了草图。然后我删除图纸中的细节视图,同样的结果。然后细节视图圈,同样的结果。最后我尝试删除草绘的圆圈,但它没有选择某个圆圈。当这段代码在 Solidworks API 中编译时,一切正常,但是当它在 Excel VBA 中编译时,它会做这个奇怪的事情。我怀疑这与后期绑定有关。有什么建议么?
Dim SwApp
On Error Resume Next
Set SwApp = GetObject(, "SldWorks.Application")
'If Solidworks is not started then start it
If Err.Number <> 0 Then
Set SwApp = CreateObject("SldWorks.Application")
End If
SwApp.Visible = True
Dim InitialDrawing2 As Object
Set InitialDrawing2 = SwApp.Opendoc(FormatSketchTemplateFolder & "FormatSketch+Tray.SLDDRW", 3)
Dim Status As Boolean
Status = InitialDrawing2.Extension.SelectByID2("Detail Circle2", "DETAILCIRCLE", 0, 0, 0, False, 0, Nothing, 0)
InitialDrawing2.EditDelete
Status = InitialDrawing2.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
InitialDrawing2.EditDelete