Hi all. I have a short macro to add the compliment angle to all the bend angles on an Inventor 2014 drawing. I want it to always show one decimal point on the compliment angle, but if that would be '0' then it doesn't show it. I.e. in the attached picture I want it to be 58.0 (122.0) DOWN. I've attached the code here. Anybody have a suggestion?
Thanks!
Nathan
Sub Test()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oView As DrawingView
Set oView = oDoc.ActiveSheet.DrawingViews(1)
Dim oNewDimStyle As DimensionStyle
Set oNewDimStyle = oDoc.StylesManager.DimensionStyles.Item("RASOR")
Dim oNote As BendNote
Dim sTemp() As String
Dim sTemp1() As String
Dim iAngle As Double
For Each oNote In oDoc.ActiveSheet.DrawingNotes
If oNote.Type = kBendNoteObject Then
sTemp = Split(oNote.Text, " ")
For i = 0 To UBound(sTemp)
If InStr(sTemp(i), "°") > 0 Then
iAngle = CDbl(Split(sTemp(i), "°")(0))
If InStr(oNote.FormattedBendNote, "(") > 0 Then
sTemp1 = Split(oNote.FormattedBendNote, "(")
oNote.FormattedBendNote = Replace(oNote.FormattedBendNote, Split(sTemp1(1), ")")(0), CStr(180 - iAngle))
oNote.DimensionStyle = oNewDimStyle
Else
oNote.FormattedBendNote = Replace(oNote.FormattedBendNote, "</BendAngle>", "</BendAngle>" & "(" & CStr(180 - iAngle) & ")")
oNote.DimensionStyle = oNewDimStyle
End If
Exit For
End If
Next
End If
Next
End Sub
Solved! Go to Solution.
Solved by cwhetten. Go to Solution.
It seems to me that this would be controlled by your dimension style called "RASOR". You would need to edit the RASOR dim style and set the angular dimension precision to 1.1 and turn on the option for trailing zeros:
This would best be done in your template, but you could perhaps write some additional lines of code to modify the dim style.
Cameron Whetten
Inventor 2014
Cameron,
Thanks for the reply. My RASOR style is already setup exactly like you show. Honestly, I was hoping I forgot to check the trailing zeros box, but that doesn't seem to be it.
Nathan
Hi Nathan. Can you repost the image from your first post, but in higher resolution? I can't read it. This is what I see:
It would help me understand exactly what your code is doing.
Thanks.
Cameron Whetten
Inventor 2014
OK, I figured something out.
Instead of the Cstr( ) function, use the Format( ) function. So, for each instance of CStr(180 - iAngle) in your code, replace it with Format(180 - iAngle, "###.0").
I tested it and it seemed to work. Give it a try and post back.
Cameron Whetten
Inventor 2014
Please click "Accept as Solution" if this response answers your question.