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: 

how to get modeldocument name for a drawingdocument?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
shirazbj
720 Views, 4 Replies

how to get modeldocument name for a drawingdocument?

Hi,

 

I tried to print thisdrawing.modeldocument in a vba sub, but it doesn't work.

 

Thanks

 

Peter

4 REPLIES 4
Message 2 of 5
matt_jlt
in reply to: shirazbj

Hi Peter,

 

I'm not sure if you want to print the document name or the actual model document.

 

To get the model name (from a drawing) the code is as follows:

 

VBA

Public Sub GetDrawingModelName()

    ' Get reference to the first referenced document
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument.ReferencedDocuments.Item(1)
    
    ' Get file system object
    Dim Fso As New FileSystemObject
    Debug.Print Fso.GetFileName(oDoc.FullFileName)
    
    ' Change Debug.Print to be a msgbox or any variable if you want
End Sub

  If you want to print the actual document let me know an i'll write up something for you.

 

Regards, Matt.

Message 3 of 5
shirazbj
in reply to: matt_jlt

Hi Matt,

 

thanks for your quick reply. It's just what I need.

 

 

MsgBox ThisApplication.ActiveDocument.ReferencedDocuments.Item(1).FullFileName

 
   

Regards

 

Peter

Message 4 of 5
Gruff
in reply to: shirazbj

Be aware that drawing documents can have many separate documents driving difference drawing views.

Offset 1 is just the first view the user created.  It may not be the primary document you desire.

Message 5 of 5
shirazbj
in reply to: Gruff

Thanks Gruff.

 

I am getting iPropeties from ipt file and table it on the drawing.I'll check there is only one ipt file referenced.

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

Post to forums  

Autodesk Design & Make Report