VBA test view label visibility and if view label text contains view name

VBA test view label visibility and if view label text contains view name

peter.roman
Advocate Advocate
508 Views
1 Reply
Message 1 of 2

VBA test view label visibility and if view label text contains view name

peter.roman
Advocate
Advocate

Hi,

In a VBA macro, is there any way to test if a view label:

1. is visible

2. contains the "view label" / view name

 

I want to modify the code at the link below to pick up projected views with broken alignment, in addition to detail/section/auxiliary views, and think testing for the above rather than view type will give the right results.

https://forums.autodesk.com/t5/inventor-ideas/drawings-re-number-detail-amp-section-views/idc-p/9232... 

 

2020-01-06 09_37_31-Window.png

 

 

 

 

 

 

 

 

 

2020-01-06 09_36_07-Window.png

0 Likes
509 Views
1 Reply
Reply (1)
Message 2 of 2

Sergio.D.Suárez
Mentor
Mentor

Hi, here I show you an example in VBA.
This code will take your active sheet from the drawing document.Test all the views that are on your drawing sheet. First it will verify if the label is visible and then it will verify if it contains the view name. If it finds these matches it will show the name of the view in the message box.

Sub TestView()
    Dim doc As DrawingDocument
    Set doc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = doc.ActiveSheet
    
    Dim oView As DrawingView
    
    For Each oView In oSheet.DrawingViews
        If oView.ShowLabel = True And _
        InStr(oView.Label.FormattedText, "<DrawingViewName/>") <> 0 Then
             MsgBox (oView.Name)
         End If
    Next
End Sub

 I hope this can help you develop your code. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes