Get full filename of inserted model on the current sheet.

Get full filename of inserted model on the current sheet.

C_Haines_ENG
Collaborator Collaborator
576 Views
4 Replies
Message 1 of 5

Get full filename of inserted model on the current sheet.

C_Haines_ENG
Collaborator
Collaborator

I am having a very hard time getting the full file name of the inserted model on the CURRENT SHEET. I have the code for the first model in the entire document. 

oModelDoc = ThisDrawing.ModelDocument
modelName = IO.Path.GetFileName(oModelDoc.FullFileName)

 How do I change this to only select the first model inserted on the current sheet?

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

WCrihfield
Mentor
Mentor
Accepted solution

There are several ways to get there, but here is one way:

oView = ActiveSheet.DrawingViews.NativeEntity.Item(1)
Dim oModelDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
modelName = IO.Path.GetFileName(oModelDoc.FullFileName)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

C_Haines_ENG
Collaborator
Collaborator

Helpful as always! as a Side note is there a way to tell if its a .iam or a .ipt with this code?

0 Likes
Message 4 of 5

JelteDeJong
Mentor
Mentor

Not so much information on how you would like to add the file name on your sheet. but this iLogic rule will show you the file name of the model that belongs to the first view of sheet 3.

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.Sheets.Item(3)
Dim view1 As DrawingView = sheet.DrawingViews.Item(1)
Dim fileName As String = view1.ReferencedFile.FullFileName
MsgBox(fileName)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor

Here is a quickie for checking the DocumentType of a view's model document:

oView = ActiveSheet.DrawingViews.NativeEntity.Item(1)
oRDD = oView.ReferencedDocumentDescriptor
Dim oModelType As String
If oRDD.ReferencedDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
	oModelType = "Assembly"
ElseIf oRDD.ReferencedDocumentType = DocumentTypeEnum.kPartDocumentObject Then
	oModelType = "Part"
End If
MsgBox("The type of Model on this sheet = " & oModelType,,"")

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes