gpt4 book ai didi

vba - Solidworks 2013 - 更新宏并在 "GetCurrentSheet"上出错

转载 作者:行者123 更新时间:2023-12-04 04:41:50 24 4
gpt4 key购买 nike

Set swDocument = Application.SldWorks.ActiveDoc
Set Sheet = swDocument.GetCurrentSheet
MySheet = Sheet.GetName
MyPath = swDocument.GetPathName
Const swSelNOTES = 15

我正在使用 Solidworks 2010 宏并尝试将其更新到 Solidworks 2013,似乎他们已删除/折旧 GetCurrentSheet属性(property)在 Application.SldWorks.ActiveDoc有谁知道目前的方法来获得它?

最佳答案

据我所知,从来没有 获取当前工作表 上的方法ModelDoc2 对象,它实际上是 的一个方法绘图文档 类型。

所以,阅读你的代码,我想 ActiveDoc 不是 绘图文档 .
可以肯定的是,只需使用:

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/solidworks.interop.sldworks~solidworks.interop.sldworks.idrawingdoc~getcurrentsheet.html

http://help.solidworks.com/2013/English/api/sldworksapi/Get_and_Set_Sheet_Properties_Example_VB.htm

关于vba - Solidworks 2013 - 更新宏并在 "GetCurrentSheet"上出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18773410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com