Drawing view identifier: automatically detect and label from view cube

Drawing view identifier: automatically detect and label from view cube

jmvanstaden29RJF
Contributor Contributor
910 Views
5 Replies
Message 1 of 6

Drawing view identifier: automatically detect and label from view cube

jmvanstaden29RJF
Contributor
Contributor

Hi Guys, 

 

I would like to automate our drawing process as much as possible. I am looking for a way to get the view name ("LEFT") in the figure below, and automatically set it to the view identifier, so that when a view is placed it already has a label instead of "VIEW 1"

 

INVENTOR FORUM 0001.PNG

0 Likes
Accepted solutions (2)
911 Views
5 Replies
Replies (5)
Message 2 of 6

Gabriel_Watson
Mentor
Mentor
Accepted solution
Perhaps this was a post best served at the iLogic/VBA forum for Inventor.

Anyhow, here's what I found there that might work for you:
https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/base-and-projected-view-label-name-t...
Or:
https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/drawing-view-labels/td-p/10094985
And more stuff possibly still useful here:
https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/automatic-drawing-view-label/td-p/91...

I'd try all three and variations of those solutions.
Message 3 of 6

jmvanstaden29RJF
Contributor
Contributor

Hi Gabriel, 

 

Thank you! 

 

I found the following code from @Peter.PopovskiYNYN8 :

 

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

 

This works perfectly. I set the rule to run after a save.

 

One flaw: it does not update when an already placed view is modified (if a "FRONT" is rotated to a "LEFT" it still shows "FRONT"

 

But I can live with this. 

 

Thanks!

Message 4 of 6

jmvanstaden29RJF
Contributor
Contributor

INVENTOR FORUM 0002.PNG

0 Likes
Message 5 of 6

jmvanstaden29RJF
Contributor
Contributor
Accepted solution

Seems like I jumped to a conclusion a little too quickly. The code from @Peter.PopovskiYNYN8 overrides all drawing views (detail views, section etc.) so when you save you get "TOP-TOP (1:3)" Instead of "A-A (1:3)"

 

The code from Ralf_Krieg works much better, since it does not override ALL the views. 

 

This is the code:

 

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

 

Message 6 of 6

jmvanstaden29RJF
Contributor
Contributor

INVENTOR FORUM 0003.PNG

0 Likes