- 技术邻 >
- CAD&结构设计 >
- SolidWorks
SolidWorks参数化建模VBA运行不成功? 10
麻烦各位大佬看一下,这个程序能打开模型,能另存为模型,但是就是不能改变参数,不知道问题出在哪里,求教!
Dim swApp
Dim Part
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")
Set objFile = objFSO.GetFile("beam.SLDPRT")
Set Part = swApp.OpenDoc(objFSO.GetAbsolutePathName(objFile),1)
Set Part = swApp.ActivateDoc("beam.SLDPRT")
'swApp.Visible = true
Call ChangePara(Part, 0.3, 0.3)
Sub ChangePara(Part, Val1, Val2)
Part.Parameter("D1@草图2").System Value = Val1
Part.Parameter("D1@凸台-拉伸1").System Value = Val2
Part.EditRebuild
End Sub
Part.SaveAs(objFSO.GetParentFolderName(objFile) & "\" & "beam1.SLDPRT")
swApp.CloseDoc "beam.SLDPRT"