Working with multiple Ordinate Dimension Sets

Working with multiple Ordinate Dimension Sets

inulobo
Advocate Advocate
834 Views
2 Replies
Message 1 of 3

Working with multiple Ordinate Dimension Sets

inulobo
Advocate
Advocate

I am struggling to capture each ordinate dimension set. I can get it to work if I set the item number manually. Can someone help me automate it so it sets the item number for the sets that contain ordinate dimensions sets? or if there is a better method please teach me.

 

 

Dim ss As SelectSet
Set ss = ThisApplication.ActiveDocument.SelectSet

Dim oDim As DrawingDimension
Dim ordDim As OrdinateDimension
Dim ordDim2 As OrdinateDimension
i=1
Set oOrdinateDims = ss.item(?????).OrdinateDimensionSet

For Each ordDim In ss
For Each ordDim2 In ordDim.OrdinateDimensionSet.Members
 If ordDim2.Text.Text <> 0 Then
  If ordDim2.IsInspectionDimension = True Then
  Else
  Call ordDim2.SetInspectionDimensionData(kRoundedEndsInspectionBorder)
  End If
 Else
 End If
Next
i = i + 1
Next

 

 

0 Likes
Accepted solutions (1)
835 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

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

EESignature

(Not an Autodesk Employee)

Message 3 of 3

inulobo
Advocate
Advocate
Accepted solution

I figured it out. I had a typo and I consolidated my information. See code block below. 

 

For Each ordDim2 In oDim.OrdinateDimensionSet.Members
 If ordDim2.Text.Text <> 0 Then
  If ordDim2.IsInspectionDimension = True Then
  Else
  Call ordDim2.SetInspectionDimensionData(kRoundedEndsInspectionBorder)
  End If
 Else
 End If
Next
i = i + 1
0 Likes