标题: 在使用VB调用SW时遇到一个问题 [打印本页] 作者: howard2002 时间: 2006-5-23 07:44 标题: 在使用VB调用SW时遇到一个问题 Private Sub Command1_Click()
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Set swApp = CreateObject("sldworks.application")
swApp.UserControl = True
Set Part = swApp.NewDocument("D:\Program Files\SolidWorks\data\templates\零件.prtdot", 0, 0#, 0#) 'Set Part = swApp.NewDocument("D:\Program Files\SolidWorks\lang\chinese-simplified\Tutorial\part.prtdot", 0, 0#, 0#)
'有一个问题,选用这个模板后,boolstatus = Part.Extension.SelectByID2 不能选择其他的基准平面,系统自动选择从“前视基准面”开始画草图,即"boolstatus = Part.Extension.SelectByID2("上视基准面", "PLANE", 0#, 0#, 0#, False, 0, Nothing, 0)"无效,执行后boolstatus的值为false
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("上视基准面", "PLANE", 0#, 0#, 0#, False, 0, Nothing, 0)
Part.InsertSketch2 True
Part.CreateCircleByRadius2 0, 0, 0, 0.01
End Sub
选用Set Part = swApp.NewDocument("D:\Program Files\SolidWorks\data\templates\零件.prtdot", 0, 0#, 0#)语句
运行后,圆的草绘平面是“上视基准面”
而选用“D:\Program Files\SolidWorks\lang\chinese-simplified\Tutorial\part.prtdot”运行后,圆的草绘平面是“前视基准面”作者: pyczt 时间: 2006-5-23 10:02
试试这种语句,可能是基准面的名称不对
Private Sub Command1_Click()
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Set swApp = Application.SldWorks
Set Part = swApp.NewDocument("D:\Program Files\SolidWorks\lang\chinese-simplified\Tutorial\part.prtdot", 0, 0#, 0#)
boolstatus = Part.Extension.SelectByID2("上视", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.CreateCircleByRadius2 0, 0, 0, 0.01
Part.InsertSketch2 True
End Sub
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()