首页 > 其他 > 详细

SolidWorks二次开发::录制一个宏文件做一点修改就是一个好程序(螺母)

时间:2020-05-13 21:48:15      阅读:220      评论:0      收藏:0      [点我收藏+]

技术分享图片

‘ ******************************************************************************
‘ C:\Users\Administrator\AppData\Local\Temp\swx6576\Macro1.swb - macro recorded on 05/13/20 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 ‘链接到sldworks接口

‘ 新建文件
Set Part = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2018\templates\GB.prtdot", 0, 0, 0)
Dim swPart As PartDoc
Set swPart = Part
swApp.ActivateDoc2 "test1", False, longstatus
Set Part = swApp.ActiveDoc
Dim myModelView As Object

‘选择草图平面
boolstatus = Part.Extension.SelectByID2("前视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
‘插入草图
Part.SketchManager.InsertSketch True
‘画一个圆
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.017995, -0.005952, 0#)
‘画一个多边形
Dim vSkLines As Variant
vSkLines = Part.SketchManager.CreatePolygon(0, 0, 0, 3.34976656173865E-02, 0, 0, 6, True)
‘退出草图
Part.SketchManager.InsertSketch True

‘插入一个拉伸特征
Dim myFeature As Object
Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.02, 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
Part.ClearSelection2 True
‘ 全显视图
Part.ViewZoomtofit2

End Sub

 

SolidWorks二次开发::录制一个宏文件做一点修改就是一个好程序(螺母)

原文:https://www.cnblogs.com/shejiyizhan/p/12884829.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!