Center dims code

Center dims code

blandb
Mentor Mentor
257 Views
3 Replies
Message 1 of 4

Center dims code

blandb
Mentor
Mentor

I took this from the api help, and modified it based on a video I found, but any ideas as why this needs to be ran twice to get all dims??

 

    ' Set a reference to the active drawing document
    Dim oDoc As DrawingDocument
    oDoc = ThisDoc.Document

    ' Set a reference to the active sheet
    Dim oSheet As Sheet
     oSheet = oDoc.ActiveSheet

    Dim oDrawingDim As DrawingDimension

    ' Iterate over all dimensions in the drawing and
    ' center them if they are linear or angular.

    For Each oDrawingDim In oSheet.DrawingDimensions
        If TypeOf oDrawingDim Is LinearGeneralDimension Or _
           TypeOf oDrawingDim Is AngularGeneralDimension Then
            oDrawingDim.CenterText
        End If
    Next
iLogicVb.UpdateWhenDone = True
InventorVb.DocumentUpdate()
Autodesk Certified Professional
258 Views
3 Replies
Replies (3)
Message 2 of 4

alewer
Advocate
Advocate

I am dealing with the exact same problem and would love if anyone has a solution. In my case it is a c# addin.

0 Likes
Message 3 of 4

bradeneuropeArthur
Mentor
Mentor

It not a real big problem.

 

I have solved it this way

 

For Each oDrawingDim In oSheet.DrawingDimensions
        If TypeOf oDrawingDim Is LinearGeneralDimension Or _
           TypeOf oDrawingDim Is AngularGeneralDimension Then
            oDrawingDim.CenterText
oDrawingDim.CenterText
End If Next

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 4 of 4

alewer
Advocate
Advocate

We have pretty much done the same. However it is a bit annoying and I was hoping somebody had a "proper" fix. Calling CenterText() twice is not an extreme burden, but it is still a workaround. I am guessing this is a bug and we will be using this workaround for a long time to come.