Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bend angle macro decimal point (VBA)

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
nkeeley
884 Views, 6 Replies

Bend angle macro decimal point (VBA)

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

6 REPLIES 6
Message 2 of 7
cwhetten
in reply to: nkeeley

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:

 

Angle Dimension Trailing Zeroes.PNG

 

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

Message 3 of 7
nkeeley
in reply to: cwhetten

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

Message 4 of 7
cwhetten
in reply to: nkeeley

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:

 

What I See.png

 

It would help me understand exactly what your code is doing.

 

Thanks.

 

Cameron Whetten
Inventor 2014

Message 5 of 7
nkeeley
in reply to: cwhetten

Sorry about that. Let's see if this one is any better.

Message 6 of 7
cwhetten
in reply to: nkeeley

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.

Message 7 of 7
nkeeley
in reply to: cwhetten

Worked perfect. Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums