Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Capture View Label Line by Line

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
ebuckner
583 Views, 3 Replies

iLogic Capture View Label Line by Line

I have a pretty straight forward Rule that replaces the standard detail view scale (12:1) with a relative detail view scale (2X). The rule does this by comparing the deatil view scale to the base view scale and outputing the relationship, see below.

 

oView.Label.FormattedText = ("<StyleOverride FontSize = '.48'>" & "<StyleOverride Underline = 'true'>" & _

"DETAIL <DrawingViewName/><Br/>" & "</StyleOverride>" & "</StyleOverride>" & Round((oView.Scale / oView.ParentView.Scale),1) &"X")

 

This works perfect so long as my users arent changing the "stock" detail view label, the rub, they change them all the time and my rule conveniently overwrites them.

 

Does iLogic allow the programmatic copy and paste of an existing view label, line by line?

 

Or, better yet, is there a method to force the view scale property to accept a string?

3 REPLIES 3
Message 2 of 4

 Hi ebuckner,

 

I think you can capture the current view label and then reuse it when you set the formatted text, as in this example where sLabel captures the current view label value.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
    MessageBox.Show("You must select a drawing view first", "iLogic")
Exit Sub
End If

'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView = trycast(oSSet.item(1), DrawingView)

If oView IsNot Nothing Then
    'turn view label visibility on
    oView.ShowLabel = True
    'capture the current view label
    ViewLabel = oView.Label
    'get label as string
    sLabel = oView.Label.FormattedText
    oModelName = _
    oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
        Try
        'set the view label
        oView.Label.FormattedText = ("<StyleOverride FontSize = '.48'>" & _
        "<StyleOverride Underline = 'true'>" & sLabel & "<Br/>" & _
        "</StyleOverride>" & "</StyleOverride>" & _
        Round((oView.Scale / oView.ParentView.Scale),1) &"X")
        Catch
        'do nothing if error
        MessageBox.Show("Error", "Title")
        End Try
Else
    MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If

 

Message 3 of 4

Thanks Curtis!

 

That worked great for "cutting and pasting" the existing label however, the existing label includes a scale which is then included above the new scale value. I need to figure out how to delete a line or only capture all but the bottom line of text. Great start though, thanks again!

Message 4 of 4
ebuckner
in reply to: ebuckner

After some research into what excel guys are doing I've figured out how to grab a portion of our labels and replace it.

 

the keys are the INSTR, INSTRREV, and MID vba commands.

 

I'm attaching the entire iLogic rule which should make following easy enough. If you have questions about how any of this works let me know.

 

Here is the part that was hard to track down. The label in formatted form included <Br/>SCALE <*>X followed by either nothing or another line of text. The chunk below searches for the beginning and end of the target string and then determines if it's at the end of the entire string or within a larger string and reacts accordingly.

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 7016 StartFragment: 314 EndFragment: 6984 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

                If InStr(sPLabelFix2, "<Br/>SCALE") Then
                    Start = InStr (sPLabelFix2, "<Br/>SCALE")
                    'MsgBox (Start,,"Start")
                    Finish = InStrRev(sPLabelFix2, "X<Br/>")
                    'MsgBox (Finish,,"Finish")
                    If Finish = 0 Then
                        sGrab = Mid(sPLabelFix2, Start)
                    ElseIf Finish <> 0 Then
                        sGrab = Mid(sPLabelFix2, Start, Finish-Start+1)
                    End If
                    'MsgBox (sGrab,,"Grab")
                    sPLabelFix3 = Replace(sPLabelFix2, sGrab, "")
                    oView.Label.FormattedText = (sPLabelFix3)
                End If

 

 

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

Post to forums  

Autodesk Design & Make Report