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: inulobo

Maybe this will make more sense for you.  I've laid the code out a bit different.  As you can see, I've defined my variables right at the top. Then I'm checking the Type of each item within the SelectSet, before attempting to use them.  This is usually a good idea to help avoid potential errors.   Once I know why Type of object it is, I then proceed to work with it as usual.  Some of the code is repetitive right now, but you could likely define and use an additional Sub routine to clean that up, if needed.  I didn't know what you were planning on doing if the object was a DrawingDimension Type object, so I just left a comment in there.

Here's the reformatted code:

Sub OrdDims()

    Dim oOrdDimSet As OrdinateDimensionSet
    Dim oOrdDim As OrdinateDimension
    Dim oDDim As DrawingDimension

    Dim oSelSet As Inventor.SelectSet
    Set oSelSet = ThisApplication.ActiveDocument.SelectSet
    If oSelSet.Count = 0 Then Exit Sub
    
    For Each oItem In oSelSet
        If TypeOf oItem Is OrdinateDimensionSet Then
            Set oOrdDimSet = oItem
            For Each oOrdDim In oOrdDimSet.Members
                If oOrdDim.Text.Text <> "0" Then
                    If oOrdDim.IsInspectionDimension = False Then
                        Call oOrdDim.SetInspectionDimensionData(kRoundedEndsInspectionBorder)
                    End If
                End If
            Next
        ElseIf TypeOf oItem Is OrdinateDimension Then
            Set oOrdDim = oItem
            If oOrdDim.IsOrdinateSetMember Then
                Set oOrdDimSet = oOrdDim.OrdinateDimensionSet
                For Each oOrdDim In oOrdDimSet.Members
                    If oOrdDim.Text.Text <> "0" Then
                        If oOrdDim.IsInspectionDimension = False Then
                            Call oOrdDim.SetInspectionDimensionData(kRoundedEndsInspectionBorder)
                        End If
                    End If
                Next
            Else
                If oOrdDim.Text.Text <> "0" Then
                    If oOrdDim.IsInspectionDimension = False Then
                        Call oOrdDim.SetInspectionDimensionData(kRoundedEndsInspectionBorder)
                    End If
                End If
            End If
        ElseIf TypeOf oItem Is DrawingDimension Then
            Set oDDim = oItem
            'do what you want with it
        End If
    Next
End Sub

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

If you have time, please... Vote For My IDEAS :light_bulb:and Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)