Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic - get model reference

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
waynehelley
3187 Views, 5 Replies

ilogic - get model reference

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 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Tags (1)
5 REPLIES 5
Message 2 of 6

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

Message 3 of 6

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 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 4 of 6

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 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 5 of 6
waynehelley
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 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 6 of 6

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

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

Post to forums  

Autodesk Design & Make Report