|
Dim swApp As SldWorks.SldWorks
Dim Model As ModelDoc2
Dim YSBmodel As ModelDoc2
Dim pth As String
Dim strpath As String
Dim nErrors As Long
Dim nWarnings As Long
Sub InsertPart()
Set swApp = Application.SldWorks
strpath = swApp.GetCurrentWorkingDirectory
Set Model = swApp.ActiveDoc
pth = strpath & "零件1.SLDPRT"
temp = openAsm(pth) '在添加零部件之前,先打开它
Model.AddComponent4 pth, "配置1", 0, 0, 0
End Sub
Function openAsm(ByVal pth As String)
Dim path As String
Dim newswapp As SldWorks.SldWorks
Set newswapp = Application.SldWorks
path = pth
Set YSBmodel = newswapp.OpenDoc6(path, 1, swOpenDocOptions_Silent, "", nErrors, nWarnings)
YSBmodel.Visible = False '我不想看到零件1
End Function |
|