Change view label

Change view label

Tigerpirro
Advocate Advocate
1,273 Views
2 Replies
Message 1 of 3

Change view label

Tigerpirro
Advocate
Advocate

Hi, I'm struggling a bit with a fairly simple issue. I'm trying to write a function that goes throught all views on a drawing. If that drawing has a active label I want the code to change the text.

This is just to quickly switch between languages.

 

I have tried using these as templates

Solved: ilogic code to change View Label Text - Autodesk Community - Inventor

Solved: ilogic code to change View Label Text - Autodesk Community - Inventor

 

I kinda get stuck when I need the Scale to come from the active view.

Could anyone help?

 

 

My code:

'start of ilogic codeDim oDoc As DrawingDocument:  
oDoc = ThisDoc.Document
oModel = ThisDoc.ModelDocument

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

oSheets = oDoc.Sheets

For Each oSheet In oSheets
oViews = oSheet.DrawingViews
    For Each oView In oViews
    oView.ShowLabel = True
        Try
       
        'add the custom iproperties to the view label        
		oView.Label.FormattedText = "TEXT" & ActiveSheet.View("VIEW1").ScaleString
		
        
        Catch
        'do nothing if error        
		End Try
    Next
Next
'end of ilogic code
0 Likes
Accepted solutions (2)
1,274 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Tigerpirro 

If I understand correctly what you want, all you need is this code 🙂

For Each oSheet  As Sheet In ThisDrawing.Document.Sheets
    For Each oView As DrawingView In oSheet.DrawingViews
    If oView.ShowLabel Then oView.Label.FormattedText = "TEXT" & oView.ScaleString
    Next
Next
Message 3 of 3

Tigerpirro
Advocate
Advocate
Accepted solution
Thank you.
0 Likes