Anybody have ideas on how to pull the path & file name of an IPT from within an IDW?
If I use this line from within an IDW:
ModelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
it will simply return the file name of the corresponding IPT.
I want to be able return the path for the IPT from within the IDW as well.
Solved! Go to Solution.
Solved by MjDeck. Go to Solution.
Here's some sample code:
modelFullFileName = ThisDrawing.ModelDocument.FullFileName
modelDirectoryName = IO.Path.GetDirectoryName(modelFullFileName)
modelFileName = IO.Path.GetFileName(modelFullFileName)
The IO.Path functions are described here
@m.joudivand , here's a VBA sample that will get the document from the first view that refers to a document. If your drawing refers to more than one, you can change this to use a particular view.
Sub TestDrawingModelDocument()
Dim modelDoc As Document
Set modelDoc = GetModelDocument(ThisApplication.ActiveDocument)
If Not modelDoc Is Nothing Then
Debug.Print "model file name = " & modelDoc.FullFileName
End If
End Sub
Function GetModelDocument(drawingDoc As DrawingDocument) As Document
Dim sheetX As Sheet
For Each sheetX In drawingDoc.Sheets
Dim view As DrawingView
For Each view In sheetX.DrawingViews
If Not view.ReferencedDocumentDescriptor Is Nothing Then
Set GetModelDocument = view.ReferencedDocumentDescriptor.ReferencedDocument
Exit Function
End If
Next
Next
Set GetModelDocument = Nothing
End Function