Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ben.young
4714 Views, 4 Replies

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

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.

4 REPLIES 4
Message 2 of 5
MjDeck
in reply to: ben.young

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
in reply to: MjDeck

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

 

Message 4 of 5
MjDeck
in reply to: m.joudivand

@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.

Message 5 of 5
m.joudivand
in reply to: MjDeck

Dear @MjDeck 

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

Thank you for the support

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums