Access Drawing view by View name with iLogic

Access Drawing view by View name with iLogic

jpchaisson
Advocate Advocate
4,111 Views
5 Replies
Message 1 of 6

Access Drawing view by View name with iLogic

jpchaisson
Advocate
Advocate

im hoping someone can help out with this because im stuck,

 

So there is tons of iLogic code out there for iLogic doing things to Drawing views but you have to select 

a view first so the code can execute. 

 

i have 4 views on a drawing that are always the same

VIEW1 - Front View

VIEW2 - Top View

VIEW3 - Side View

VIEW4 - Isometric View

 

i have been trying for what seems like forever to figure out how to access the Drawing View by name and 

have iLogic make the View label visible for each view and add the correct label per view. has anyone done this or knows how to access a view by name?

 

Thanks,

Jeremy 

0 Likes
Accepted solutions (1)
4,112 Views
5 Replies
Replies (5)
Message 2 of 6

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, this is a code by way of example, for your particular case you can adapt the idea. This code recognizes the view and places the type of view as the view name. I hope it will help you solve your problem. regards

 

Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet
For Each oSheet In oDrawingDoc.Sheets
	oViews = oSheet.DrawingViews
	Dim oView As DrawingView
	For Each oView In oViews
				oView.ShowLabel = True
				Dim orientype As ViewOrientationTypeEnum
 				orientype = oView.Camera.ViewOrientationType
				If orientype = 10763 Then
				oView.Label.FormattedText = "Arbitrary View"
				End If
				If orientype = 10756 Then
				oView.Label.FormattedText = "Back View"
				End If
				If orientype = 10757  Then
				oView.Label.FormattedText = "Bottom View"
				End If
				If orientype = 10765  Then
				oView.Label.FormattedText = "Current View"
				End If
				If orientype = 10753 Then
				oView.Label.FormattedText = "Specifies the Default setting To use. Inquiry methods/properties always Return the more strongly typed values"
				End If
				If orientype = 10773  Then
				oView.Label.FormattedText = "Sheet metal flat pattern backside pivot 180 degrees"
				End If
				If orientype = 10772  Then
				oView.Label.FormattedText = "Sheet metal flat pattern backside pivot left"
				End If
				If orientype = 10770  Then
				oView.Label.FormattedText = "Sheet metal flat pattern backside"
				End If
				If orientype = 10769  Then
				oView.Label.FormattedText = "Sheet metal flat pattern pivot 180 degrees"
				End If
				If orientype = 10768  Then
				oView.Label.FormattedText = "Sheet metal flat pattern pivot left"
				End If
				If orientype =10767  Then
				oView.Label.FormattedText = "Sheet metal flat pattern pivot right"
				End If
				If orientype = 10764  Then
				oView.Label.FormattedText = "Front View"
				End If
				If orientype = 10762  Then
				oView.Label.FormattedText = "Isometric -- Bottom Left View"
				End If
				If orientype = 10761  Then
				oView.Label.FormattedText = "Isometric -- Bottom Right View"
				End If
				If orientype = 10760  Then
				oView.Label.FormattedText = "Isometric -- Top Left View"
				End If
				If orientype = 10759   Then
				oView.Label.FormattedText = "Isometric -- Top Right View"
				End If
				If orientype = 10758   Then
				oView.Label.FormattedText = "Left View"
				End If
				If orientype = 10755   Then
				oView.Label.FormattedText = "Right View"
				End If
				If orientype = 10766   Then
				oView.Label.FormattedText = "Saved camera View"
				End If
				If orientype = 10754   Then
				oView.Label.FormattedText = "Top View"
				End If		
	Next
Next

view.jpg

 

 


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

Message 3 of 6

jpchaisson
Advocate
Advocate

Yuvilo,

 

Thank you, one question since you are accessing "TypeEnum" all the codes i see are Inventor internal

identifiers correct? im assuming you got this from some sort of documention, if so can you tell me where

i can find this info?

 

Thanks,

Jeremy

0 Likes
Message 4 of 6

Sergio.D.Suárez
Mentor
Mentor

The volumes are precisely the help of Api programming, as you well suppose. Once I wanted to do something similar to your initial proposal. and my codes sometimes failed at the beginning, this recognition was not enough, at the same time we combined with the sight identification, if it was the type of base view or projected type of view, and in some cases comparing the alignments of two views for example loaded as an ilogic subroutine

Sub Vis_Id_Vista' Visualiza el identificador de Vista 
	' trata de realizarlo en la vista principal, comparando las vistas de la misma hoja y sus alineaciones
On Error Resume Next
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
Dim oSheets As Sheets
Dim oViews As DrawingViews
oSheets =  oDrawingDoc.Sheets
For Each oSheet In oSheets
	oViews = oSheet.DrawingViews
	Dim v1 As DrawingView  'Define la vista 1
	Dim v2 As DrawingView  'Define la vista 2
	For Each v1 In oViews
		Y1=v1.position.y
		For Each v2 In oViews
			Y2=v2.position.y
			If v1.ViewType = 10501 AndAlso _
			v2.ViewType = 10504 AndAlso _
			y1=Y2  Then
			v1.ShowLabel = True
			End If
		Next
	Next
Next
End Sub

 I think that combined methods you could get your proper rules. I hope you have good luck!


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
Message 5 of 6

jpchaisson
Advocate
Advocate

Yuvilo,

 

Not all of the identifiers work right. for instance a top view and Iso View both show as an Arbitrary View.

 

Thanks,

Jeremy 

0 Likes
Message 6 of 6

Anonymous
Not applicable

I love the code but, is there any way for the rule to skip section and detail views?

0 Likes