Inventor General

Reply
Valued Contributor
waynehelley
Posts: 99
Registered: ‎09-10-2012
Message 1 of 6 (619 Views)
Accepted Solution

ilogic - get model reference

619 Views, 5 Replies
03-08-2013 06:34 AM

Hi there,

 

I was wondering if there was a command that will get the file name of the model referenced in a drawing?

 

The reason I want to do this is because I have various programs to automate drawings, but I have to manually edit the code if i want to switch between using the code on assembly drawings and part drawings.

 

If i can get the model reference, I can then use a bit of extra programming to extract the extension. (i.e. .ipt or .iam)

 

Thanks in advance,

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2013
Windows 7 Enterprise, 64-bit
*Expert Elite*
Curtis_Waguespack
Posts: 2,772
Registered: ‎03-08-2006
Message 2 of 6 (610 Views)

Re: ilogic - get model reference

03-08-2013 06:45 AM in reply to: waynehelley

Hi waynehelley,

 

You can use this:

 

doc = ThisDoc.ModelDocument

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Valued Contributor
waynehelley
Posts: 99
Registered: ‎09-10-2012
Message 3 of 6 (605 Views)

Re: ilogic - get model reference

03-08-2013 07:07 AM in reply to: Curtis_Waguespack

Hi Curtis, I am still having a bit of trouble.  I have tried the following but I can't seem to be able to get the command to give me the document name as text. If I run the following...

 

modeldoc = ThisDoc.ModelDocument

test = modeldoc.FileName(True)'with extension

MessageBox.Show(test, "Title")

 

I get the error...

 

Error in rule: Get Model Reference, in document: Get Model Reference.iLogicVb

Public member 'FileName' on type 'AssemblyDocument' not found.

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2013
Windows 7 Enterprise, 64-bit
Valued Contributor
waynehelley
Posts: 99
Registered: ‎09-10-2012
Message 4 of 6 (603 Views)

Re: ilogic - get model reference

03-08-2013 07:12 AM in reply to: Curtis_Waguespack

I am not sure if I got a bit confused about what your code was intended to be used for.  I will attach my code. You will be able to see that I get to a section where my program replaces the model reference (within a for function) and needs to know the extension

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2013
Windows 7 Enterprise, 64-bit
Valued Contributor
waynehelley
Posts: 99
Registered: ‎09-10-2012
Message 5 of 6 (589 Views)

Re: ilogic - get model reference

03-08-2013 07:33 AM in reply to: waynehelley

Just to clarify, my program is intended to be ran from a drawing, hence I need to know if the drawing is of a part or assembly.

 

I can make do with this for now...

 

extension = InputBox("Please state the file extension. '.ipt' for parts and '.iam' for assemblies", "Drawing Generator",".ipt")

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2013
Windows 7 Enterprise, 64-bit
*Expert Elite*
Curtis_Waguespack
Posts: 2,772
Registered: ‎03-08-2006
Message 6 of 6 (557 Views)

Re: ilogic - get model reference

03-08-2013 01:31 PM in reply to: waynehelley

Hi waynehelley,

 

I think this will work for you to check the file type:

 

doc = ThisDoc.ModelDocument
 'check file type 
If doc.DocumentType = kPartDocumentObject Then
MessageBox.Show("This is a part file.", "iLogic")
Else if doc.DocumentType = kAssemblyDocumentObject Then
MessageBox.Show("This is an assembly file.", "iLogic")
End if

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube