How to access to a certain drawing view

How to access to a certain drawing view

Anonymous
Not applicable
817 Views
4 Replies
Message 1 of 5

How to access to a certain drawing view

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
818 Views
4 Replies
Replies (4)
Message 2 of 5

robertast
Collaborator
Collaborator

@Anonymous 

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

Bandymas.jpg

Message 3 of 5

ckeveryga
Advocate
Advocate

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

WCrihfield
Mentor
Mentor
Accepted solution

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)

Message 5 of 5

Anonymous
Not applicable

@WCrihfield  Super! It works!! Thank you so much!!! 😄

0 Likes