下面是点击插件按钮运行的代码!!
Dim swApp As New SldWorks
Dim Part As Object
Part = swApp.ActiveDoc
Dim myModelView As Object
myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
Part.Extension.SelectByID2("前视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2(True) __**'SolidWorks闪退 ,没有这个代码也闪退**__
Dim skSegment As Object
skSegment = Part.SketchManager.CreateCircleByRadius(0, 0, 0, diameter / 2) '画圆
Part.ClearSelection2(True)
skSegment = Part.SketchManager.CreateLine(0.0#, diameter / 2, 0.0#, 0.0#, -diameter / 2, 0.0#) '画线
Part.ClearSelection2(True)
Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", -diameter / 2, 0, 0, False, 2, Nothing, 0) '裁剪
Part.SketchManager.SketchTrim(4, 0, 0, 0)
Part.SketchManager.InsertSketch(True)
Part.Extension.SelectByID2("Line1@草图1", "EXTSKETCHSEGMENT", 0, -0.0144352972972973, 0, False, 0, Nothing, 0) '重复
Part.ShowNamedView2("*上下二等角轴测", 8)
Part.ClearSelection2(True)
Part.Extension.SelectByID2("Line1@草图1", "EXTSKETCHSEGMENT", -0.179735448684255, 0.0133523994917368, 0, False, 16, Nothing, 0)
Dim myFeature As Object
myFeature = Part.FeatureManager.FeatureRevolve2(True, True, False, False, False, False, 0, 0, 6.2831853071796, 0, False, False, 0.01, 0.01, 0, 0, 0, True, True, True)
Part.SelectionManager.EnableContourSelection = False
End Function
https://zhidao.baidu.com/question/262997556856039165.html