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' 👍.
If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS
Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)