Inventor Customization

Inventor Customization

Reply
Active Contributor
shirazbj
Posts: 46
Registered: ‎02-25-2007
Message 1 of 5 (178 Views)
Accepted Solution

how to get modeldocument name for a drawingdocument?

178 Views, 4 Replies
02-11-2013 03:51 PM

Hi,

 

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

 

Thanks

 

Peter

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.

Mentor
matt_jlt
Posts: 218
Registered: ‎07-28-2007
Message 2 of 5 (173 Views)

Re: how to get modeldocument name for a drawingdocument?

02-11-2013 05:28 PM 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.

Active Contributor
shirazbj
Posts: 46
Registered: ‎02-25-2007
Message 3 of 5 (166 Views)

Re: how to get modeldocument name for a drawingdocument?

02-11-2013 06:04 PM 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

Valued Mentor
Gruff
Posts: 440
Registered: ‎11-24-2003
Message 4 of 5 (150 Views)

Re: how to get modeldocument name for a drawingdocument?

02-12-2013 11:44 AM 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.

Active Contributor
shirazbj
Posts: 46
Registered: ‎02-25-2007
Message 5 of 5 (140 Views)

Re: how to get modeldocument name for a drawingdocument?

02-12-2013 02:52 PM 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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!