Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
721 Views, 4 Replies

How to access to a certain drawing view

Hi all,

 

I would like to access to the detail view B (in green circle). To access "VISTA1", I know that I have to write the come something like..

 

Dim oDoc As Inventor.DrawingDocument

Dim oViewA As DrawingView
oViewA = oDoc.ActiveSheet.DrawingViews.Item(1)

 

But I cannot find how to access to a child view of drawing view. Can anyone help me out?

 

And, in the code below, what's the meaning of "1" in the part "Item(1)"? It sounds stupid but I tried Item(B), Item(2.B) etc etc and obviously didn't work at all....

oViewA = oDoc.ActiveSheet.DrawingViews.Item(1)

 

 

Untitled.png

Labels (2)
robertast
in reply to: Anonymous

@Anonymous 

Are you working for 2021 inventory? Try this button it tells the way

Bandymas.jpg

ckeveryga
in reply to: Anonymous

If you know the name of the view, you could do this

If ThisApplication.ActiveDocumentType <> kdrawingdocumentobject Then
	MessageBox.Show("Only works for drawings")
	Exit Sub
End If

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Inventor.Sheet
oSheet = oDrawDoc.Sheets.Item(1)

Dim oDetailView As DrawingView

For Each oView As DrawingView In oSheet.DrawingViews
	If oView.Name = "B" Then
		oDetailView = oView
	End If
Next
WCrihfield
in reply to: Anonymous

Here is one way of getting that view.

And by the way, any time your iterating through members of a collection, there are "Item"s.  And they are indexed by Integers.  Even though, it doesn't say so in the clues, you can also enter a "quoted" string, instead of an Integer, that represents the name of the object (or view in your case).

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oDView As DetailDrawingView
For Each oSheet As Sheet In oDDoc.Sheets
	For Each oView As DrawingView In oSheet.DrawingViews
		If oView.ViewType = DrawingViewTypeEnum.kDetailDrawingViewType Then
			oDView = oView
		End If
	Next
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Anonymous
in reply to: WCrihfield

@WCrihfield  Super! It works!! Thank you so much!!! :grinning_face_with_smiling_eyes: