Dimension macro

Hi..

need this type macro please help me.. 

i know dimension tool.. but possible to single click ( mm, inch, cm type )

Thanks

  • I have never used it myself, but GDG Macros has a commercial macro called, "Dimension Gator".

  • Here is the code

    ===========================

    Sub DrawDimension()
    Dim x As Double, y As Double, sx As Double, sy As Double, khoangcach As Double, xlen As Double, ylen As Double
    Dim pt1 As SnapPoint, pt2 As SnapPoint
    Dim s As Shape
    Dim arrowwidth As Double

    ActiveSelection.GetBoundingBox x, y, sx, sy, False
    ActiveSelection.GetSize xlen, ylen

    'kiem tra lon hon 50cm thi cho khoang cach xa ra
    If xlen > 19.68504628 Then
    khoangcach = 3
    arrowwidth = 35277 '10 point
    Else
    khoangcach = 1
    arrowwidth = 17638 '5 point
    End If


    Set pt1 = CreateSnapPoint(x, y - 0.5)
    Set pt2 = CreateSnapPoint(x + sx, y - 0.5)
    'Tao dimension hang ngang
    Set s = ActiveLayer.CreateLinearDimension(cdrDimensionHorizontal, pt1, pt2, True, , , cdrDimensionStyleDecimal, Units:=cdrDimensionUnitCM)

    s.Dimension.TextShape.SetPosition x + sx / 2, y - khoangcach
    s.Style.StringAssign "{""fill"":{""primaryColor"":""CMYK,USER,0,0,0,100,100,00000000-0000-0000-0000-000000000000"",""secondaryColor"":""CMYK,USER,0,0,0,0,100,00000000-0000-0000-0000-000000000000""},""outline"":{""width"":" & arrowwidth & ",""color"":""RGB255,USER,255,0,0,100,8273965b-a0fd-4e34-a5c2-a29720146cc3"",""leftArrow"":""M-1333253,-357244 L0,0 L-1333253,357244 L-1333253,-357244 Z|666626"",""rightArrow"":""M-1333253,-357244 L0,0 L-1333253,357244 L-1333253,-357244 Z|666626""},""character"":{""fill"":{""type"":""1"",""primaryColor"":""CMYK,USER,80,40,0,20,100,00000000-0000-0000-0000-000000000000"",""secondaryColor"":""CMYK,USER,0,0,0,0,100,00000000-0000-0000-0000-000000000000""},""angle"":""0"",""outline"":{""width"":""0"",""color"":""CMYK,USER,80,40,0,20,100,00000000-0000-0000-0000-000000000000""},""h_shift"":""0""" & _
    ",""v_shift"":""0"",""latin"":{""font"":""Arial"",""charset"":""0"",""size"":""127000"",""weight"":""164"",""italic"":""0"",""underline"":""0"",""overline"":""0"",""strikeout"":""0"",""script"":""0"",""effect"":""0""},""RTL"":{""font"":""Arial"",""charset"":""178"",""size"":""127000"",""weight"":""64"",""italic"":""0"",""underline"":""0"",""overline"":""0"",""strikeout"":""0"",""script"":""0"",""effect"":""0""},""farEast"":{""font"":""Batang"",""charset"":""129"",""size"":""127000"",""weight"":""16"",""italic"":""0"",""underline"":""0"",""overline"":""0"",""strikeout"":""0"",""script"":""0"",""effect"":""0""}},""dimension"":{""useDefaultOverhang"":""1"",""overhang"":""0"",""useDefaultAnchorGap"":""1"",""anchorGap"":""0"",""centerText"":""1"",""horizontalText"":""0"",""boxAroundText"":""0"",""" & _
    "textPlacement"":""0"",""textStyle"":""0"",""precision"":""1"",""units"":""15"",""angularUnits"":""1"",""showUnits"":""1"",""showLeadingZero"":""1"",""dynamicText"":""1"",""reverseTerminators"":""0"",""autoReverseTerminators"":""1"",""includeCDReverseTerminated"":""0"",""hideCDWhenReverseTerminated"":""0"",""useDefaultReverseTerminatedLength"":""1"",""showExtLines"":""1"",""showInnerExtensionLines"":""1"",""useDefaultLabelGap"":""1"",""hideGapOnFreeExtension"":""1"",""labelGap"":""0"",""reverseTerminatedLength"":""0"",""prefix"":"""",""suffix"":"""",""radialInsideOutside"":""0"",""radialTextAboveLine"":""0"",""radialSymbol"":""4"",""dimetricSymbol"":""6""}}"

    s.Outline.Color.RGBValue = 255
    s.Dimension.TextShape.Fill.UniformColor.RGBAssign 255, 0, 0

    'Tao dimension hang doc
    Set pt1 = CreateSnapPoint(x + sx + 0.5, y)
    Set pt2 = CreateSnapPoint(x + sx + 0.5, y + sy)
    Set s = ActiveLayer.CreateLinearDimension(cdrDimensionVertical, pt1, pt2, True, , , cdrDimensionStyleDecimal, 2, True, Units:=cdrDimensionUnitCM, Placement:=cdrDimensionWithinLine)
    s.Dimension.TextShape.SetPosition x + sx + khoangcach, y + sx / 2
    s.Style.StringAssign "{""fill"":{""primaryColor"":""CMYK,USER,0,0,0,100,100,00000000-0000-0000-0000-000000000000"",""secondaryColor"":""CMYK,USER,0,0,0,0,100,00000000-0000-0000-0000-000000000000""},""outline"":{""width"":" & arrowwidth & ",""color"":""RGB255,USER,255,0,0,100,8273965b-a0fd-4e34-a5c2-a29720146cc3"",""leftArrow"":""M-1333253,-357244 L0,0 L-1333253,357244 L-1333253,-357244 Z|666626"",""rightArrow"":""M-1333253,-357244 L0,0 L-1333253,357244 L-1333253,-357244 Z|666626""},""character"":{""fill"":{""type"":""1"",""primaryColor"":""CMYK,USER,80,40,0,20,100,00000000-0000-0000-0000-000000000000"",""secondaryColor"":""CMYK,USER,0,0,0,0,100,00000000-0000-0000-0000-000000000000""},""angle"":""0"",""outline"":{""width"":""0"",""color"":""CMYK,USER,80,40,0,20,100,00000000-0000-0000-0000-000000000000""},""h_shift"":""0""" & _
    ",""v_shift"":""0"",""latin"":{""font"":""Arial"",""charset"":""0"",""size"":""1270000"",""weight"":""164"",""italic"":""0"",""underline"":""0"",""overline"":""0"",""strikeout"":""0"",""script"":""0"",""effect"":""0""},""RTL"":{""font"":""Arial"",""charset"":""178"",""size"":""1270000"",""weight"":""64"",""italic"":""0"",""underline"":""0"",""overline"":""0"",""strikeout"":""0"",""script"":""0"",""effect"":""0""},""farEast"":{""font"":""Batang"",""charset"":""129"",""size"":""127000"",""weight"":""16"",""italic"":""0"",""underline"":""0"",""overline"":""0"",""strikeout"":""0"",""script"":""0"",""effect"":""0""}},""dimension"":{""useDefaultOverhang"":""1"",""overhang"":""0"",""useDefaultAnchorGap"":""1"",""anchorGap"":""0"",""centerText"":""1"",""horizontalText"":""0"",""boxAroundText"":""0"",""" & _
    "textPlacement"":""0"",""textStyle"":""0"",""precision"":""1"",""units"":""15"",""angularUnits"":""1"",""showUnits"":""1"",""showLeadingZero"":""1"",""dynamicText"":""1"",""reverseTerminators"":""0"",""autoReverseTerminators"":""1"",""includeCDReverseTerminated"":""0"",""hideCDWhenReverseTerminated"":""0"",""useDefaultReverseTerminatedLength"":""1"",""showExtLines"":""1"",""showInnerExtensionLines"":""1"",""useDefaultLabelGap"":""1"",""hideGapOnFreeExtension"":""1"",""labelGap"":""0"",""reverseTerminatedLength"":""0"",""prefix"":"""",""suffix"":"""",""radialInsideOutside"":""0"",""radialTextAboveLine"":""0"",""radialSymbol"":""4"",""dimetricSymbol"":""6""}}"

    s.Outline.Color.RGBValue = 255
    s.Dimension.TextShape.Fill.UniformColor.RGBAssign 255, 0, 0
    End Sub