Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: Anonymous

You said you wanted the solution to be in VBA instead of iLogic right.  Well here's the VBA macro I sometimes use for arranging dimensions and re-centering dimension text.  I hope you can get some use out of it too.

Sub Center_ArrangeAllDims()
    If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
        Call MsgBox("This rule only works for Drawing Documents.", vbOKOnly, "WRONG DOCUMENT TYPE")
        Exit Sub
    End If
    Dim oDDoc As DrawingDocument
    Set oDDoc = ThisApplication.ActiveDocument
    Dim oSheet As Inventor.Sheet
    Set oSheet = oDDoc.ActiveSheet
    Dim oDDims As DrawingDimensions
    Set oDDims = oSheet.DrawingDimensions
    Dim oDDim As DrawingDimension
    For Each oDDim In oDDims
        If TypeOf oDDim Is LinearGeneralDimension Or _
            TypeOf oDDim Is AngularGeneralDimension Then
            Call oDDim.CenterText
        End If
    Next
    Dim oBaselineDimSet As BaselineDimensionSet
    For Each oBaselineDimSet In oDDims.BaselineDimensionSets
        Call oBaselineDimSet.ArrangeText
    Next
    Dim oChainDimSet As ChainDimensionSet
    For Each oChainDimSet In oDDims.ChainDimensionSets
        Call oChainDimSet.Arrange(oChainDimSet.Members.Item(1))
    Next
    Dim oCollection As ObjectCollection
    Set oCollection = ThisApplication.TransientObjects.CreateObjectCollection
    'Dim oLinGenDim As LinearGeneralDimension
    Dim oGenDim As GeneralDimension
    For Each oGenDim In oDDims.GeneralDimensions
        If TypeOf oGenDim Is LinearGeneralDimension Then
            Call oCollection.Add(oGenDim)
        End If
    Next
    If oCollection.Count > 1 Then
        Call oDDims.Arrange(oCollection)
    End If
End Sub

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)