|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
大家好,我是一个SOLIDWORKS的新手,在solidworks录制宏里面发现这样一个问题,希望大家能帮忙解决下:
solidworks在录制宏的时候,如果使用了智能尺寸来修改零部件属性,执行宏的过程中就没法自动执行智能尺寸修改特性的确认哪一步,必须手动选择确认才能继续执行宏,有时候录制的尺寸太多,如果不能自动执行,每一步都选择,效率太低。
下面是我录制的一个简单槽型件的宏代码,槽型件的槽宽为100mm,槽高为40mm,槽长为
100mm,壁厚4mm,执行宏的时候到修改尺寸确认那一步就不能自动执行,必须手点确认才可继续执行,有没有什么办法能够避免这个问题,需要在宏里面添加什么代码吗?
' ******************************************************************************
' C:\Documents and Settings\Administrator\Local Settings\Temp\swx2896\Macro1.swb - macro recorded on 11/24/09 by Administrator
' ******************************************************************************
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("前视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateLine(0#, 0.033917, 0#, 0#, 0#, 0#)
Set skSegment = Part.SketchManager.CreateLine(0#, 0#, 0#, 0.068485, 0#, 0#)
Set skSegment = Part.SketchManager.CreateLine(0.068485, 0#, 0#, 0.068485, 0.033917, 0#)
Part.SetPickMode
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", 0.03232958308413, -5.165071770335E-04, 0, False, 0, Nothing, 0)
Dim myDisplayDim As Object
Set myDisplayDim = Part.AddDimension2(0.02854186378589, -0.01153532695375, 0)
Part.ClearSelection2 True
Dim myDimension As Object
Set myDimension = Part.Parameter("D1@草图1")
myDimension.SystemValue = 0.1
boolstatus = Part.Extension.SelectByID2("Line1", "SKETCHSEGMENT", 3.061381080542E-04, 0.01842208931419, 0, False, 0, Nothing, 0)
Set myDisplayDim = Part.AddDimension2(-0.01863245838317, 0.01842208931419, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("D1@草图1@零件1.SLDPRT", "DIMENSION", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
Set myDimension = Part.Parameter("D2@草图1")
myDimension.SystemValue = 0.04
boolstatus = Part.Extension.SelectByID2("Line3", "SKETCHSEGMENT", 0.09913117798046, 0.02220980861244, 0, False, 0, Nothing, 0)
Set myDisplayDim = Part.AddDimension2(0.1177254363537, 0.02220980861244, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("D2@草图1@零件1.SLDPRT", "DIMENSION", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
Set myDimension = Part.Parameter("D3@草图1")
myDimension.SystemValue = 0.04
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
Part.ShowNamedView2 "*上下二等角轴测", 8
Dim customBendAllowanceData As Object
Set customBendAllowanceData = Part.FeatureManager.CreateCustomBendAllowance()
customBendAllowanceData.KFactor = 0.5
Dim myFeature As Object
Set myFeature = Part.FeatureManager.InsertSheetMetalBaseFlange2(0.004, True, 0.004, 0.1, 0.01, False, 0, 0, 1, customBendAllowanceData, False, 0, 0.0001, 0.0001, 0.5, True, False, True, True)
Part.ClearSelection2 True
End Sub |
|