Hi Dave,
Your drawing sheet contains not only general dimensions but hole thread notes as well.
These notes are accessible via Sheet.DrawingNotes.HoleThreadNotes collection.
I’ve modified the rule to take into account both types. In addition I added document type check that is useful if you plan to run this rule as the external rule.
Please note that Inventor API internal length unit is centimeter.
'external rule
'change dim style for all dims less than specified value Threshold
Dim Threshold As Double = 1 ' inch
'convert to centimeters - Inventor internal database length units
Threshold = Threshold * 2.54
If Not TypeOf ThisDoc.Document Is DrawingDocument Then
MessageBox.Show("This rule is intended for drawing documents only.", _
"Change Style", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
'drawing document
Dim oDrawDoc As DrawingDocument = ThisDoc.Document
'active sheet
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim n As Integer = 0 'counter
'reference to the style manager
Dim oStylesMgr As DrawingStylesManager = oDrawDoc.StylesManager
'get the reference to the target dimension style (by name)
Dim oNewStyle As DimensionStyle _
= oStylesMgr.DimensionStyles.Item("Architectural (No Zeros)")
'transform general dimensions
Dim oDims As DrawingDimensions = oSheet.DrawingDimensions
For Each oDim As GeneralDimension In oDims
'replace style if dim value is less than Threshold
If oDim.ModelValue < Threshold Then
oDim.Style = oNewStyle
n += 1
End If
Next
'transform Hole Thread Notes
Dim oThreadNote As HoleThreadNote
For Each oThreadNote In oSheet.DrawingNotes.HoleThreadNotes
If oThreadNote.ModelValue < Threshold Then
'replace style if dim value is less than Threshold
oThreadNote.Style = oNewStyle
n += 1
End If
Next
MessageBox.Show("Done" & vbNewLine & "Dimensions changed: " & n, _
"Change Style", MessageBoxButtons.OK, MessageBoxIcon.Information)
The easiest way to discover Inventor objects is described by Adam Nagy in the following nice post
http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html
cheers,
Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network