solidworks二次开发vba中的代码改成vb代码求大神指点!
PrivateSubCommandButton1_Click()DimswAppAsSldWorks.SldWorksDimModelAsModelDoc2DimYSBm...
Private Sub CommandButton1_Click()
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
Set swApp = Application.SldWorks
strpath = swApp.GetCurrentWorkingDirectory
Set Model = swApp.ActiveDoc
pth = "C:\Users\Administrator\Desktop\毕业设计\夹具图库\通用件\T371613尖对位轴.SLDPRT"
openYSB (pth) '在添加零部件之前,先打开它
Model.AddComponent4 pth, "配置1", 0, 0, 0
End Sub
'这个函数打开零件1
Sub openYSB(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, "", 0, 0)
YSBmodel.Visible = False '我不想看到零件1
End Sub
Private Sub CommandButton2_Click()
Set swApp = Application.SldWorks
strpath = swApp.GetCurrentWorkingDirectory
Set Model = swApp.ActiveDoc
pth = "C:\Users\Administrator\Desktop\新建文件夹 (2)\T4130带肩衬套.SLDPRT"
openYSB (pth) '在添加零部件之前,先打开它
Model.AddComponent4 pth, "配置1", 0, 0, 0
End Sub
Private Sub CommandButton3_Click()
End
End Sub 展开
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
Set swApp = Application.SldWorks
strpath = swApp.GetCurrentWorkingDirectory
Set Model = swApp.ActiveDoc
pth = "C:\Users\Administrator\Desktop\毕业设计\夹具图库\通用件\T371613尖对位轴.SLDPRT"
openYSB (pth) '在添加零部件之前,先打开它
Model.AddComponent4 pth, "配置1", 0, 0, 0
End Sub
'这个函数打开零件1
Sub openYSB(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, "", 0, 0)
YSBmodel.Visible = False '我不想看到零件1
End Sub
Private Sub CommandButton2_Click()
Set swApp = Application.SldWorks
strpath = swApp.GetCurrentWorkingDirectory
Set Model = swApp.ActiveDoc
pth = "C:\Users\Administrator\Desktop\新建文件夹 (2)\T4130带肩衬套.SLDPRT"
openYSB (pth) '在添加零部件之前,先打开它
Model.AddComponent4 pth, "配置1", 0, 0, 0
End Sub
Private Sub CommandButton3_Click()
End
End Sub 展开
展开全部
你想表达什么?你给我邮箱,我给你一个完整的代码参考参考!
更多追问追答
追问
我是向装配体中添加零件,sw的vba中这个是可以运行的,但是我要在vb中运行,Set YSBmodel = newswapp.OpenDoc6(path, 1, swOpenDocOptions_Silent, "", 0, 0)
这句话出现了问题。。。。793192229@qq.com谢谢!大神指导
追答
我做的那个没有在装配中添加零件这个功能,你看看官方文件里面OpenDoc6这个函数的命令是什么样的!里面应该有解释!直接在google里面搜 OpenDoc6,然后打开“
2012 SolidWorks API Help - OpenDoc6 Method (ISldWorks)
”,“
2013 SolidWorks API Help - OpenDoc6 Method (ISldWorks)
”仔细看看!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询