Set swDocument = Application.SldWorks.ActiveDoc
Set Sheet = swDocument.GetCurrentSheet
MySheet = Sheet.GetName
MyPath = swDocument.GetPathName
Const swSelNOTES = 15
我正在使用Solidworks 2010宏并尝试将其更新为Solidworks 2013,看起来他们已经删除/折旧GetCurrentSheet
上的Application.SldWorks.ActiveDoc
属性有没有人知道当前获取该方法的方法?
答案 0 :(得分:2)
据我记忆所知, ModelDoc2 对象上没有 GetCurrentSheet 方法,实际上它是 DrawingDoc 类型。
因此,阅读您的代码,我认为 ActiveDoc 不是 DrawingDoc 。 当然,只需使用:
Dim swApp as SldWorks
Dim swDrawing as DrawingDoc
Dim swDocument as ModelDoc2
Set swApp = Application.SldWorks
Set swDocument = swApp.ActiveDoc
Set swDrawing = swDocument
If swDrawing is Nothing Then
MsgBox "No valid drawing doc!"
Exit Sub
End If
或者
Dim swApp as SldWorks
Dim swDrawing as DrawingDoc
Dim swDocument as ModelDoc2
Set swApp = Application.SldWorks
Set swDocument = swApp.ActiveDoc
If swDocument.GetType() <> swDocumentTypes_e.swDocDRAWING Then
MsgBox "No valid drawing doc!"
Exit Sub
Else
Set swDrawing = swDocument
End If
你知道是不是这样。我还建议您检查API文档中的以下附加信息:
http://help.solidworks.com/2013/English/api/sldworksapi/Get_and_Set_Sheet_Properties_Example_VB.htm