iLogic View Label for all views on select sheets

iLogic View Label for all views on select sheets

LFMarshall
Advocate Advocate
1,000 Views
7 Replies
Message 1 of 8

iLogic View Label for all views on select sheets

LFMarshall
Advocate
Advocate

For several months I've been trying to get an iLogic rule to work but keep coming up short.  Any assistance would be greatly appreciated.

 

I've been able to piece together code from others to get most of the way there, but I need just one little piece to get over the hump.

 

What I'm looking for is to change all of the view labels on a single sheet (of flat patterns), with the Sheet Name "CUT FILES" to the Part Title and Description iprops of the part in the view.  This particular sheet is in a drawing with multiple sheets, but typically only one will have the name "CUT FILES".  I would like to set this rule to run prior to save, to ensure consistency in view labeling so having a code that only runs on one sheet is not ideal.

 

Below is the rule that I have together at this point, but it doesn't work.  It seems to just quit when it gets to SyntaxEditor Code Snippet

If ActiveSheet.Name IsNot "CUT FILES" Then Continue For

 If I remove that particular line the code runs, but on every view on every sheet.

SyntaxEditor Code Snippet

Dim oDoc As DrawingDocument:  oDoc = ThisDoc.Document

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

oSheets = oDoc.Sheets
For Each oSheet In oSheets
	If ActiveSheet.Name IsNot "CUT FILES" Then Continue For
		oViews = oSheet.DrawingViews
		For Each oView In oViews            
									
				If oView IsNot Nothing Then
				oView.ShowLabel = True
				'format the model iproperties   
				oStringTitle = "<StyleOverride Underline='True' FontSize='1.27'> <Property Document='model' PropertySet='Summary Information' Property='Title' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='2'>TITLE</Property></StyleOverride>"
				oStringDescription = "<Br/><StyleOverride FontSize='1.27'>   <Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
					 
				'add to the view label
				oView.Label.FormattedText = oStringTitle & oStringDescription       
				End If
        Next
Next

Thanks

 

LM

Inventor 2018 

Larry Marshall
Inventor 2021.2 , AutoCAD 2021, 3DS Max 2021
0 Likes
1,001 Views
7 Replies
Replies (7)
Message 2 of 8

philip1009
Advisor
Advisor

Try using <> instead of IsNot.

Message 3 of 8

LFMarshall
Advocate
Advocate

@philip1009wrote:

Try using <> instead of IsNot.


Thanks for the suggestion, unfortunately, that just crashed the program when I ran the rule.

Larry Marshall
Inventor 2021.2 , AutoCAD 2021, 3DS Max 2021
0 Likes
Message 4 of 8

Anonymous
Not applicable

It looks to me like you are only looking at one sheet. (ActiveSheet.name) I believe if you change that to oSheet the logic will look at all pages. You might then have to assign oSheet to ActiveSheet before going through the views.

 

 

 

 

kl

 

Message 5 of 8

marcin_otręba
Advisor
Advisor
as @Anonymous said you shoud use osheet instead active sheet if you want to check names of all sheets and you dont activate it one by one..
 
so this is the code:
 
 

For Each oSheet In oSheets
    If oSheet.Name <>"CUT FILES" Then 'Continue For - you dont need this
        oViews = oSheet.DrawingViews
        For Each oView In oViews            
                      
                If oView IsNot Nothing Then
                oView.ShowLabel = True
                'format the model iproperties   
                oStringTitle = "<StyleOverride Underline='True' FontSize='1.27'> <Property Document='model' PropertySet='Summary Information' Property='Title' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='2'>TITLE</Property></StyleOverride>"
                oStringDescription = "<Br/><StyleOverride FontSize='1.27'>   <Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
                    
                'add to the view label
                oView.Label.FormattedText = oStringTitle & oStringDescription       
                End If
        Next
Next

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 6 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support

Hello @LFMarshall,

 

Try below iLogic to check sheet name

 

Dim oDoc As DrawingDocument:  oDoc = ThisDoc.Document

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

oSheets = oDoc.Sheets
For Each oSheet In oSheets
	oSheet.Activate
	If oSheet.Name.StartsWith("CUT FILES") = False Then 
		oViews = oSheet.DrawingViews
		For Each oView In oViews            
									
				If oView IsNot Nothing Then
				oView.ShowLabel = True
				'format the model iproperties   
				oStringTitle = "<StyleOverride Underline='True' FontSize='1.27'> <Property Document='model' PropertySet='Summary Information' Property='Title' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='2'>TITLE</Property></StyleOverride>"
				oStringDescription = "<Br/><StyleOverride FontSize='1.27'>   <Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
					 
				'add to the view label
				oView.Label.FormattedText = oStringTitle & oStringDescription       
				End If
        	Next
	End If
Next

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 8

LFMarshall
Advocate
Advocate

@marcin_otrębawrote:
as @Anonymous said you shoud use osheet instead active sheet if you want to check names of all sheets and you dont activate it one by one..
 
so this is the code:
 
 

For Each oSheet In oSheets
    If oSheet.Name <>"CUT FILES" Then 'Continue For - you dont need this
        oViews = oSheet.DrawingViews
        For Each oView In oViews            
                      
                If oView IsNot Nothing Then
                oView.ShowLabel = True
                'format the model iproperties   
                oStringTitle = "<StyleOverride Underline='True' FontSize='1.27'> <Property Document='model' PropertySet='Summary Information' Property='Title' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='2'>TITLE</Property></StyleOverride>"
                oStringDescription = "<Br/><StyleOverride FontSize='1.27'>   <Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
                    
                'add to the view label
                oView.Label.FormattedText = oStringTitle & oStringDescription       
                End If
        Next
Next


One of the Ifs, didn't have a terminator and when I added an End If it crashed the program.  When I removed the End If and added the Continue For back to the code it seems to be working as expected.  I don't claim to know why, and maybe I had done something incorrectly, but it seems to be working now.  Thank you for the help.

 

For reference, here is complete code that seems to be working.

 

SyntaxEditor Code Snippet

Dim oDoc As DrawingDocument:  oDoc = ThisDoc.Document

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

oSheets = oDoc.Sheets

For Each oSheet In oSheets
    If oSheet.Name <> "CUT FILES" Then Continue For
		oViews = oSheet.DrawingViews
        For Each oView In oViews            
                      
                If oView IsNot Nothing Then
                oView.ShowLabel = True
                'format the model iproperties   
                oStringTitle = "<StyleOverride Underline='True' FontSize='1.27'> <Property Document='model' PropertySet='Summary Information' Property='Title' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='2'>TITLE</Property></StyleOverride>"
                oStringDescription = "<Br/><StyleOverride FontSize='1.27'>   <Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
                    
                'add to the view label
                oView.Label.FormattedText = oStringTitle & oStringDescription       
                End If
        Next
Next
Larry Marshall
Inventor 2021.2 , AutoCAD 2021, 3DS Max 2021
0 Likes
Message 8 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support

That's nice to hear that it is working.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes