Controlling Arrowheads on Drawing Dimensions with VBA

Controlling Arrowheads on Drawing Dimensions with VBA

Anonymous
Not applicable
1,084 Views
5 Replies
Message 1 of 6

Controlling Arrowheads on Drawing Dimensions with VBA

Anonymous
Not applicable

Hello,

I am looking for a solid way of defining With VBA Code whether the Arrows on a dimension will be on the inside or on the outside.

I Can set it one way or the other for everything and I can have some on the outside and others on the inside with code, but it is not consistent on which ones will receive the change.

It appears that maybe inventor VBA can't change the style after it is dimensioned?

 

Here is some code that I think should work but doesn't......Thanks for your help.

 

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

 

Dim oSheet As Sheet
Set oSheet = oDrawDoc.Sheets.Item(1)


Dim Counter As Long
Counter = 0

 

Dim oDrawingDim As DrawingDimension


For Each oDrawingDim In oSheet.DrawingDimensions
Counter = Counter + 1


' Add some formatted text to all dimensions on the sheet.
oDrawingDim.Text.FormattedText = """"



Dim oStyleDim As DimensionStyle
Set oStyleDim = oDrawingDim.Style

oStyleDim.LinearPrecision = kThirtySecondsFractionalLinearPrecision

If oDrawingDim.ModelValue <= (10 * 2.54) Then
oStyleDim.LinearArrowsInside = False
Debug.Print Counter
Debug.Print oDrawingDim.ModelValue
Else
oStyleDim.LinearArrowsInside = True
End If

0 Likes
Accepted solutions (2)
1,085 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Noah,

 

   I believe that what is happenings in your code is that you are changing the global dimension style not just the single dimension you want the arrows on the outside. So you change it this way for one dimension and back again for the next. I would suggest that you create a new dimension style that has the arrows set to the outside and then change the smaller  dimensions to that style like so

 

 

 

If oDrawingDim.ModelValue <= (10 * 2.54) Then
oStyleDim = oDrawongDoc.Stylesmanager.DimensionStyles.Item("YourDimensionStyle")

End If

 

I am just learning this myself so please let me know if find a way to change it on individual dims.

 

0 Likes
Message 3 of 6

Anonymous
Not applicable

type in the previous post

oStyleDim = oDrawongDoc.Stylesmanager.DimensionStyles.Item("YourDimensionStyle")

 

should be 

oStyleDim = oDrawIngDoc.Stylesmanager.DimensionStyles.Item("YourDimensionStyle")

0 Likes
Message 4 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@Anonymous,

 

Try the below VBA code to change Arrowheads of Drawing dimension

 

Sub Main()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.Sheets.Item(1)
            
    Dim oDimension As DrawingDimension
    For Each oDimension In oSheet.DrawingDimensions
        If oDimension.ModelValue <= (10 * 2.54) Then
            oDimension.ArrowheadsInside = False
        Else
            oDimension.ArrowheadsInside = True
        End If
    Next
    Call oSheet.Update
    Call oDoc.Update
End Sub

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 6

Anonymous
Not applicable

Thanks a bunch! works perfect!

0 Likes
Message 6 of 6

Anonymous
Not applicable
Accepted solution

The accepted solution will change them individually.

0 Likes