0 Replies Latest reply on Aug 12, 2014 6:08 PM by jason van clark

    AutoDimension2 not working correctly editing sketch in context

    jason van clark

      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






                  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#)


                      vertLine = sketchmgr.CreateLine(0.0#, 0.0#, 0.0#, 0.0#, 0.025063, 0.0#)







                      bool = vertLine.Select3(True, swAutodimMark_e.swAutodimMarkHorizontalDatum, Nothing)

                      bool = HorizLine.Select3(True, swAutodimMark_e.swAutodimMarkVerticalDatum, Nothing)



                      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, _


                  End If


              End Sub



      this is what I get: