See the top rated post in this thread. Click here

Results 1 to 5 of 5

Thread: change fractional precision of a linear dimension

  1. #1
    Member
    Join Date
    2020-05
    Posts
    7
    Login to Give a bone
    0

    Default change fractional precision of a linear dimension

    I would like to be able, on an individual basis, to be able to override the fractional precision of a linear dimension. (From 1/16" to 1/32").

    the code "dim.Obj.PrimaryUnitsPrecision = acDimPrecisionFive" doesn't seem to make any difference. Is there a different object I should be using?

    Thanks

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: change fractional precision of a linear dimension

    "dim.Obj" Is that a typo? Can you show your code. Go to the Advanced editor and use the # code tags.
    C:> ED WORKING....

  3. #3
    Member
    Join Date
    2020-05
    Posts
    7
    Login to Give a bone
    0

    Default Re: change fractional precision of a linear dimension

    Yes the dim.Obj was a typo. This is the code I am trying to use. The "If" statement was what I added to attempt to change the fractional precision.

    Code:
    Public Sub DimAligned(DimX1, DimY1, DimX2, DimY2, DimLX, DimLY, DimText, TRot, Lsf, DimPrec)
        Dim Pnt1(0 To 2) As Double
        Dim Pnt2(0 To 2) As Double
        Dim TextLoc(0 To 2) As Double
        Dim dimObj As AcadDimAligned
        Dim DimStyle As AcadDimStyle
        
        Pnt1(0) = DimX1
        Pnt1(1) = DimY1
        Pnt1(2) = 0
        Pnt2(0) = DimX2
        Pnt2(1) = DimY2
        Pnt2(2) = 0
        TextLoc(0) = DimLX
        TextLoc(1) = DimLY
        TextLoc(2) = 0
            
        Set DimStyle = ThisDrawing.DimStyles("cti standard$0")
        ThisDrawing.ActiveDimStyle = DimStyle
        
            
        Set dimObj = ThisDrawing.ModelSpace.AddDimAligned(Pnt1, Pnt2, TextLoc)
        dimObj.TextOverride = DimText
        dimObj.TextRotation = TRot
        
        dimObj.LinearScaleFactor = Lsf
        dimObj.VerticalTextPosition = acAbove
        If DimPrec <> "" Then
            dimObj.PrimaryUnitsPrecision = acDimPrecisionSix
        End If
        
        ThisDrawing.Regen acAllViewports
        dimObj.Update
        
    End Sub
    Last edited by Ed Jobe; 2021-11-08 at 03:33 PM. Reason: Added CODE tags

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    1

    Default Re: change fractional precision of a linear dimension

    Your DimPrec comparison is wrong. Here is a cleaned up version.

    However, it's not recommended to be adding a bunch of dim style overrides. It would be better to create a dim style with the precision you want and then use the dim's StyleName property to set the style.
    Code:
    Public Sub dimTest()
        MyDimAligned 1, 1, 0, 0, 0, 0, 0
    End Sub
    Public Sub MyDimAligned(DimX1 As Double, DimY1 As Double, DimX2 As Double, _
                DimY2 As Double, DimLX As Double, DimLY As Double, _
                  TRot As Double, Optional DimText As String, _
                 Optional Lsf As Double, Optional DimPrec As Integer)
        ' If you don't specify the data type, Variant is assumed.
        ' Use the Optional keyword when applicable. They must be at the end.
        ' Don't name variables the same as other library names,
        ' e.g. DimAligned and DimStyle are AutoCAD library names.
        Dim Pnt1(0 To 2) As Double
        Dim Pnt2(0 To 2) As Double
        Dim TextLoc(0 To 2) As Double
        Dim dimObj As AcadDimAligned
        Dim oDimStyle As AcadDimStyle
        Dim DimStyleLSF As Double
        
        Pnt1(0) = DimX1
        Pnt1(1) = DimY1
        Pnt1(2) = 0
        Pnt2(0) = DimX2
        Pnt2(1) = DimY2
        Pnt2(2) = 0
        TextLoc(0) = DimLX
        TextLoc(1) = DimLY
        TextLoc(2) = 0
            
        Set oDimStyle = ThisDrawing.DimStyles("standard")
        ThisDrawing.ActiveDimStyle = oDimStyle
        DimStyleLSF = ThisDrawing.GetVariable("DIMLFAC")
        
            
        Set dimObj = ThisDrawing.ModelSpace.AddDimAligned(Pnt1, Pnt2, TextLoc)
        With dimObj
            If DimText <> "" Then .TextOverride = DimText
            .TextRotation = TRot
            If Lsf <> DimStyleLSF And Lsf <> 0 Then .LinearScaleFactor = Lsf
            .VerticalTextPosition = acAbove
            If DimPrec <> acDimPrecisionSix Then .PrimaryUnitsPrecision = acDimPrecisionSix
            .Update
        End With
        ThisDrawing.Regen acAllViewports
        
    End Sub
    C:> ED WORKING....

  5. #5
    Member
    Join Date
    2020-05
    Posts
    7
    Login to Give a bone
    0

    Default Re: change fractional precision of a linear dimension

    Thanks, It is doing exactly what I wanted it to do.

Similar Threads

  1. Control Fractional Dimension Size
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 3
    Last Post: 2018-11-06, 09:45 PM
  2. 2012: Imperial units - deciaml inch - fractional inch - feet and fractional?
    By Mauri12345 in forum AutoCAD General
    Replies: 8
    Last Post: 2015-05-13, 04:20 PM
  3. Linear Parameters vs. Linear Dimensional Constraint
    By melissa_r_alexander in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2010-07-09, 05:10 PM
  4. AEC precision vs Acad precision
    By jason.bell in forum CAD Management - General
    Replies: 0
    Last Post: 2008-02-25, 09:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •