代码如下:
Dim swApp
Dim PART
DIM filename
On Error Resume Next
Set swapp = GetObject(, "SldWorks.Application")
If Err Then
Err.Clear
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
swApp.Visible = true
swApp.UserControl = True
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
filename = objFSO.getAbsolutePathName(".") & "opt.SLDPRT"
'Set objFile = objFSO.GetFile("opt.SLDPRT")
Set PART = swApp.OpenDoc(filename)
swapp.ActivateDoc2 "opt"
Set PART = swApp.ActiveDoc
谢谢各位老师指点。作者: jimcao 时间: 2013-5-11 13:20
楼主,我也想学基于VB的SW二次开发,能介绍些相关资料吗?谢谢作者: ly_alen 时间: 2013-5-12 07:44
关于楼主遇到的这个问题。我先在也碰到了,很困惑。我的也是对一个尺寸驱动的零件进行参数化建模,接果报错。不知道楼主解决了没?能否传授些经验,谢谢!作者: lyqqmxm 时间: 2013-5-13 18:08
"d5@sketch"不存在吧,修改一下你的Solidwork全局变量作者: TAOTAO5016 时间: 2013-5-13 18:12
The Name argument for this method does not have to be the "full" dimension name. For example, you only need to pass "D1" not "D1@Base-Revolve". The full dimension name is required if you call IModelDoc2:arameter.
SOLIDWORKS recognizes some characters as special characters. The use of these characters in part or feature names can cause this method to fail and not return a dimension. These special characters are not recognized in names of parts or features: