Drawing View Labels

Drawing View Labels

Anonymous
Not applicable
2,177 Views
7 Replies
Message 1 of 8

Drawing View Labels

Anonymous
Not applicable

Hi, I am using Inventor 2021 and using the ilogic rule below to populate the View Labels on my Drawings as per the View Cube and it works well.

Dim tmpSheet As Sheet = ThisDrawing.ActiveSheet.Sheet
Dim tmpView As DrawingView
For Each tmpView In tmpSheet.DrawingViews
    Dim myDrawingViewName As String = ""
	If tmpView.Type = ObjectTypeEnum.kDrawingViewObject Then
    
        Select Case tmpView.Camera.ViewOrientationType
            Case ViewOrientationTypeEnum.kBackViewOrientation
                myDrawingViewName = "BACK VIEW"
            Case ViewOrientationTypeEnum.kBottomViewOrientation
                myDrawingViewName = "BOTTOM VIEW"
            Case ViewOrientationTypeEnum.kFrontViewOrientation
                myDrawingViewName = "FRONT VIEW"
            Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation
                myDrawingViewName = "ISOMETRIC VIEW"
            Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation
                myDrawingViewName = "ISOMETRIC VIEW"
            Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
                myDrawingViewName = "ISOMETRIC VIEW"
            Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation
                myDrawingViewName = "ISOMETRIC VIEW"
            Case ViewOrientationTypeEnum.kLeftViewOrientation
                myDrawingViewName = "SIDE VIEW"
            Case ViewOrientationTypeEnum.kRightViewOrientation
                myDrawingViewName = "SIDE VIEW"
            Case ViewOrientationTypeEnum.kTopViewOrientation
                myDrawingViewName = "TOP VIEW"
            Case Else
                myDrawingViewName = ""
            End Select        
        If Not myDrawingViewName = "" Then
            tmpView.Name = myDrawingViewName
        End If		
		If tmpView.IsFlatPatternView =True Then
           tmpView.Name = "FLAT PATTERN"
        End If
    End If
    myDrawingViewName = ""

Next

 

The problem I have is if I place a base view in a rotated orientation, it does not  update the View label. See below

Base view on Left in default orientation, Base view on Right Rotated 90deg on view placement.

 

View Labels.JPG

 

Any help with editing this rule to allow for rotated views to populate the view label will be much appreciated. Thanks

 

0 Likes
Accepted solutions (1)
2,178 Views
7 Replies
Replies (7)
Message 2 of 8

Ralf_Krieg
Advisor
Advisor

Hello

 

The tmpView.Camera.ViewOrientationType for rotated views is always kArbitraryViewOrientation. The rotation in radiant of the drawing view is a double value in tmpView.Rotation. If you save this value in a variable and set this value to 0, the Camera.ViewOrientationType is the value you need. Rotate back by assigning the variable value to back to Camera.Rotation property. Or, start a transaction before rotating and abort this transaction after your select case and before assigning myDrawingViewName value to tmpView.Name. The value of variable myDrawingViewName is not deleted on transaction abort.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 8

Anonymous
Not applicable

Hi Thanks for the reply.

I am somewhat new to ilogic and am unsure how to apply what you outlined to the existing rule to allow for the rotated 'FRONT VIEW' drawing view label to be populated as 'FRONT VIEW'.  I understand that rotated views are always kArbitraryViewOrientation & I understand the rotation in radians (eg tmpView.Rotation = 90*PI / 180) but am unsure how to save this value in a variable and set this value to 0?

Any addidtional assistance you can provide would be much appreciated.

 

0 Likes
Message 4 of 8

Ralf_Krieg
Advisor
Advisor

Hello

 

I've added the transaction things I described above to the script. The advantage is, as we abort the transaction later, everything we modified is rolled back automatically by Inventor. It's like nothing of it ever happened. 🙂

 

Dim tmpSheet As Sheet = ThisDrawing.ActiveSheet.Sheet
Dim tmpView As DrawingView
For Each tmpView In tmpSheet.DrawingViews
    Dim myDrawingViewName As String = ""
	If tmpView.Type = ObjectTypeEnum.kDrawingViewObject Then
		'Encapsulat the rotation of drawing view in a transaction
		Dim oTrans As Transaction
		oTrans = ThisApplication.TransactionManager.StartTransaction(ThisDrawing.Document, "Rotate Drawing View temp")
		
		' Set rotation to 0
		If tmpView.Camera.ViewOrientationType = ViewOrientationTypeEnum.kArbitraryViewOrientation Then
			tmpView.Rotation = 0
    	End If
		
        Select Case tmpView.Camera.ViewOrientationType
            Case ViewOrientationTypeEnum.kBackViewOrientation
                myDrawingViewName = "BACK VIEW"
            Case ViewOrientationTypeEnum.kBottomViewOrientation
                myDrawingViewName = "BOTTOM VIEW"
            Case ViewOrientationTypeEnum.kFrontViewOrientation
                myDrawingViewName = "FRONT VIEW"
            Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation
                myDrawingViewName = "ISOMETRIC VIEW"
            Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation
                myDrawingViewName = "ISOMETRIC VIEW"
            Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
                myDrawingViewName = "ISOMETRIC VIEW"
            Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation
                myDrawingViewName = "ISOMETRIC VIEW"
            Case ViewOrientationTypeEnum.kLeftViewOrientation
                myDrawingViewName = "SIDE VIEW"
            Case ViewOrientationTypeEnum.kRightViewOrientation
                myDrawingViewName = "SIDE VIEW"
            Case ViewOrientationTypeEnum.kTopViewOrientation
                myDrawingViewName = "TOP VIEW"
            Case Else
                myDrawingViewName = ""
            End Select
			
		' Abort the transaction so everything is rolled back like before the transaction starts
		oTrans.Abort 
		
        If Not myDrawingViewName = "" Then
            tmpView.Name = myDrawingViewName
        End If		
		If tmpView.IsFlatPatternView =True Then
           tmpView.Name = "FLAT PATTERN"
        End If
    End If
    myDrawingViewName = ""
Next

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 5 of 8

WCrihfield
Mentor
Mentor

Hi @Anonymous .

I worked on a very similar post before, a couple years ago I think, and I created a very short iLogic rule to rename all drawing views according to their view orientation type.  It basically used the ViewOrientationTypeEnum's string value and got rid of the starting "k" and the ending "ViewOrientation" text, and used the remaining descriptive text to name the view, all in upper case.  Although it doesn't attempt to solve your problem, I thought you might find it interesting, since it is related, and very efficient.

Here's the code:

Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oViews As DrawingViews
Dim oOrientType As ViewOrientationTypeEnum
Dim oOrigViewName As String
Dim oNewViewName As String
For Each oSheet As Sheet In oDoc.Sheets
	oViews = oSheet.DrawingViews
	For Each oView As DrawingView In oViews
		oOrientType = oView.Camera.ViewOrientationType
		oOrigViewName = oView.Name
		oNewViewName = Mid(oOrientType.ToString, 2, Len(oOrientType.ToString) -16)
		oView.ShowLabel = True
		oView.Name = oNewViewName.ToUpper
	Next
Next

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 8

Anonymous
Not applicable

Hi, thanks for writing that into the script. I tested it and it works for a view rotated after placement but does not work for a view that is placed in a rotated orientation. Is there a way to make it work for both types of rotated views?

Also I got an error in the rule when I had an Auxiliary View that had the alignment broken. Any idea why that would be? See below image.

 

Capture20.JPG

0 Likes
Message 7 of 8

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

I found no solution to rotate back base views that are rotatet on placement. Maybe it's possible to rotate this drawing views stepwise 90° and check drawingviewtype after each step. This would only work if the user has not rotate a free angle or rotate free in orbit. I think we've nearly reached the limit of automation.

 

I think the error message appears as we try to rotate back a not rotated view. I've modified the code to rotate onle if drawingview rotation is not 0.

 

Dim tmpSheet As Sheet = ThisDrawing.ActiveSheet.Sheet
Dim tmpView As DrawingView
For Each tmpView In tmpSheet.DrawingViews
		Dim myDrawingViewName As String = ""
		If tmpView.Type = ObjectTypeEnum.kDrawingViewObject Then
			'Encapsulat the rotation of drawing view in a transaction
			Dim oTrans As Transaction
			oTrans = ThisApplication.TransactionManager.StartTransaction(ThisDrawing.Document, "Rotate Drawing View temp")
			
			' Set rotation to 0
			If tmpView.Camera.ViewOrientationType = ViewOrientationTypeEnum.kArbitraryViewOrientation Then
				If tmpView.Rotation<>0 Then
					tmpView.Rotation = 0
				End If
	    	End If
			
	        Select Case tmpView.Camera.ViewOrientationType
	            Case ViewOrientationTypeEnum.kBackViewOrientation
	                myDrawingViewName = "BACK VIEW"
	            Case ViewOrientationTypeEnum.kBottomViewOrientation
	                myDrawingViewName = "BOTTOM VIEW"
	            Case ViewOrientationTypeEnum.kFrontViewOrientation
	                myDrawingViewName = "FRONT VIEW"
	            Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation
	                myDrawingViewName = "ISOMETRIC VIEW"
	            Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation
	                myDrawingViewName = "ISOMETRIC VIEW"
	            Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
	                myDrawingViewName = "ISOMETRIC VIEW"
	            Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation
	                myDrawingViewName = "ISOMETRIC VIEW"
	            Case ViewOrientationTypeEnum.kLeftViewOrientation
	                myDrawingViewName = "SIDE VIEW"
	            Case ViewOrientationTypeEnum.kRightViewOrientation
	                myDrawingViewName = "SIDE VIEW"
	            Case ViewOrientationTypeEnum.kTopViewOrientation
	                myDrawingViewName = "TOP VIEW"
	            Case Else
	                myDrawingViewName = ""
	            End Select
				
			' Abort the transaction so everything is rolled back like before the transaction starts
			oTrans.Abort 
			
	        If Not myDrawingViewName = "" Then
	            tmpView.Name = myDrawingViewName
	        End If		
			If tmpView.IsFlatPatternView =True Then
	           tmpView.Name = "FLAT PATTERN"
	        End If
	    End If
	    myDrawingViewName = ""
Next

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 8 of 8

Anonymous
Not applicable

No worries at all, I can definitely live with it the way it works now. Your efforts in helping me make it work better are very much appreciated.

0 Likes