注册 登录
编程论坛 VB6论坛

各位大神棒棒忙,vb语言对solidworks二次开发的问题

manycrazy 发布于 2013-03-16 00:54, 524 次点击
把宏中的代码直接贴到vb中就出错了,在vba中运行还没事儿,怎么就不行了呢,新手求助

 Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim warning As Long
Dim error As Long
Private Sub Command1_Click()
Set swApp = CreateObject("SldWorks.Application")
Set swPart = swApp.ActiveDoc
swApp.Visible = True
Set swPart = swApp.OpenDoc6("C:\Documents and Settings\All Users\Application Data\SolidWorks\SolidWorks 2012\templates\零件.prtdot", swDocPART, swOpenDocOptions_Silent, "", error, warning)

boolstatus = Part.Extension.SelectByID2("前视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.011494, 0.036051, 0#)
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
Part.ShowNamedView2 "*上下二等角轴测", 8
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("草图1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Dim myFeature As Object
Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.01, 0.01, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, 0, 0, False)
Part.SelectionManager.EnableContourSelection = False

End Sub

3 回复
#2
Susake2013-03-16 00:54
不懂VB的来帮你顶下
#3
wube2013-03-16 15:02
kk
#4
wp2319572013-03-16 15:03
vb和vba当然不一样啦
1