iLogic - Path & File name of model from within an IDW

iLogic - Path & File name of model from within an IDW

Anonymous
Not applicable
5,085 Views
4 Replies
Message 1 of 5

iLogic - Path & File name of model from within an IDW

Anonymous
Not applicable

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.

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

MjDeck
Autodesk
Autodesk
Accepted 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


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 5

m.joudivand
Enthusiast
Enthusiast

@MjDeck could you also please provide the VBA code that we may use to retrieve the part file name in inventor drawing.

 

0 Likes
Message 4 of 5

MjDeck
Autodesk
Autodesk

@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

Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 5

m.joudivand
Enthusiast
Enthusiast

Dear @MjDeck 

Thanks a lot, I tried the code and properly worked,

Thank you for the support

0 Likes