I have a sketch that I am editing in context. I am trying to place dimensions on the sketch automatically. I first create two lines, one vertical, one horizontal, based on the origin. I then use those lines as my horizontal and vertical datums for the autodimension2 function. It will not work! It keeps dimensioning to the edges of the part. What am I doing wrong!?
Sub addDims(ByVal swSketch As Sketch, ByVal swModel As ModelDoc2)
Dim sketchPoints As Object
Dim nretval As Integer
Dim bool As Boolean
Dim sketchmgr As SketchManager
Dim tempMod As ModelDoc2
tempMod = EditedPart.GetModelDoc2
'Dim LocalOrigin As Entity
'LocalOrigin = EditedPart.GetCorresponding(origin)
sketchmgr = swModel.SketchManager 'get the sketch manager
sketchPoints = swSketch.GetSketchPoints2 'get the sketch points in the sketch
swModel.ClearSelection2(True)
tempMod.ClearSelection2(True)
If originPoint IsNot Nothing Then
Dim HorizLine As SketchSegment
Dim vertLine As SketchSegment
HorizLine = sketchmgr.CreateLine(0.0#, 0.0#, 0.0#, 0.021598, 0.0#, 0.0#)
sketchmgr.CreateConstructionGeometry()
vertLine = sketchmgr.CreateLine(0.0#, 0.0#, 0.0#, 0.0#, 0.025063, 0.0#)
sketchmgr.CreateConstructionGeometry()
swModel.ClearSelection2(True)
bool = vertLine.Select3(True, swAutodimMark_e.swAutodimMarkHorizontalDatum, Nothing)
bool = HorizLine.Select3(True, swAutodimMark_e.swAutodimMarkVerticalDatum, Nothing)
Else
bool = origin.Select3(True, swAutodimMark_e.swAutodimMarkHorizontalDatum, Nothing)
bool = origin.Select3(True, swAutodimMark_e.swAutodimMarkHorizontalDatum, Nothing)
End If
'bool = swModel.Extension.SelectByID2("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, False, 8, Nothing, 0)
'bool = LocalOrigin.Select2(False, 0)
If bool Then
nretval = swSketch.AutoDimension2(swAutodimEntities_e.swAutodimEntitiesAll, _
swAutodimScheme_e.swAutodimSchemeOrdinate, _
swAutodimHorizontalPlacement_e.swAutodimHorizontalPlacementBelow, _
swAutodimScheme_e.swAutodimSchemeOrdinate, _
swAutodimVerticalPlacement_e.swAutodimVerticalPlacementLeft)
End If
End Sub
this is what I get:
Jason
SolidworksApi macros