ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
MWMatthew Wafler04/10/2010

I have been messing with a macro for a couple of days now and about have it worked out with the exception of my sketch not being fully defined....I have tired 2 different ways to make it defined and can not get it to work....the first way was to copy some code to make the sketch defined..that just locked up my computer....guess I really don't understand the code I copied in...the next thing I tired was using Smart dimension inside the macro which works ok BUT when I run the macro it stops to where I have to click the green check after the smart dimension before it completes the macro....if there a way to bypass the stop and write in code to make it accept the smart dimension?

Here is the code:

Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim SelMgr As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim BlankOD As Double
Dim BlankThickness As Double
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Dim myForm As New Blank_Info
myForm.Caption = "Enter in OD and Thickness"
myForm.Show
BlankOD = (myForm.OD / 2) / 39.37
BlankThickness = myForm.Thickness / 39.37
Set myForm = Nothing
boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Dim SkCircle As Object
Set SkCircle = Part.SketchManager.CreateCircle(0, 0, 0, BlankOD, 0, 0)
Part.SetPickMode
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0.04039049919485, 0.05009444444444, 0, False, 0, Nothing, 0)
Dim Annotation As Object
Set Annotation = Part.AddDimension2(0, 0, 0)
Part.ClearSelection2 True
Part.Parameter("D1@Sketch1").SystemValue = BlankOD
Part.ClearSelection2 True
Part.ShowNamedView2 "*Trimetric", 8
Part.ClearSelection2 True
Part.FeatureManager.FeatureExtrusion2 True, False, True, 0, 0, BlankThickness, 0, False, False, False, False, 0.008726646259972, 0.008726646259972, False, False, False, False, 1, 1, 1, 0, 0, False
Part.SelectionManager.EnableContourSelection = 0
boolstatus = Part.Extension.SelectByID2("Extrude1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
Part.SelectedFeatureProperties 0, 0, 0, 0, 0, 0, 0, 1, 0, "BLANK OD"
Part.ClearSelection2 True
End Sub