Question
Set SwDim = SwModel.AddDimension2(x1(ii), y1(ii), 0) → result is nothing.
Help me.
How to set swdim → How to get dimenion name.
Private Sub ll()
Dim x1(2), y1(2), x2(2), y2(2)
x1(0) = 0: x1(1) = 0.1: x1(2) = 0.1
y1(1) = 0: y1(1) = 0: y1(2) = 0.05
x2(0) = 0.1: x2(1) = 0.1: x2(2) = 0.1 - 0.01
y2(0) = 0: y2(1) = 0.05: y2(2) = 0.05
Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2
Set SwApp = Application.SldWorks
Set SwModel = SwApp.ActiveDoc
Dim SwSelMgr As SelectionMgr, Tmp
Tmp = SwModel.Extension.SelectByID2("Top Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
''
Dim SwSketch As Sketch, SwSketchSeg As SketchSegment, SwAnn As Annotation
Dim SwFeat As Feature, SwDim As Dimension
SwModel.InsertSketch2 True
For ii = 0 To 2
Set SwSketchSeg = SwModel.CreateLine2(x1(ii), y1(ii), 0, x2(ii), y2(ii), 0)
SwSketchSeg.Select True
Set SwDim = SwModel.AddDimension2(x1(ii), y1(ii), 0)
'Debug.Print SwDim.Name
Next ii
Set SwSketch = SwSketchSeg.GetSketch
Set SwFeat = SwSketch
SwModel.InsertSketch2 True
Debug.Print
Debug.Print SwFeat.Name
Stop
End Sub
don't Prompt box for Adddimension2 | SOLIDWORKS Forums
SolidworksApi macros