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: 

Create Assembly and Insert Part

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
e_frissell
223 Views, 6 Replies

Create Assembly and Insert Part

Spent a while looking to see if something for this exists however I can't find anyone who's asked this

 

Let's say I have just made a part or assembly, saved it, and I want to insert this part into a new assembly.  What's the iLogic to get there?

 

Dim invapp As Inventor.Application
'Dim oPartDoc As Document = invapp.ActiveDocument
Dim oPartDoc As Document = ThisDoc.Document
Dim oPartFile As String = oPartDoc.FullFileName
Dim newAsmDoc As AssemblyDocument
Dim oAsmTemplate = "P:\CAD\Inventor\Templates\Link\Assembly.iam"

'invApp.Documents.Open - doesn't work 'invapp.Documents.Add - also doesn't work

I feel like you should be able to create a new assembly document using iLogic and then insert the part into that document however the internet has me wondering if that's possible, and I can't find any other iLogic references to opening or creating documents than the Open or Add document methods

6 REPLIES 6
Message 2 of 7
Frederick_Law
in reply to: e_frissell

I use this to open a template file then SaveAs:

	oIDWFile = TryCast(ThisApplication.Documents.Open(oPathName + oIDWTemplate + ".idw", True), DrawingDocument)
	oIDWFile.SaveAs(oPathName + oFileName + ".idw", True)
	oIDWFile.Close
	oIDWFile = TryCast(ThisApplication.Documents.Open(oPathName + oFileName + ".idw", True), DrawingDocument)

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-A1536C12-5AD5-4BA7-9391-2AB32C9B03C7

Message 3 of 7
e_frissell
in reply to: Frederick_Law

hey, to open an assembly document, that worked!  Kind of weird that using invApp.Documents.Open didn't work as I would have thought that was the same thing except it continually threw the error "Object reference not set to an instance of an object"

 

So next step is to find the method that allows me to add oPartDoc into the newAsmDoc, so I don't have to copy and paste or drag and drop... it doesn't look like the documents.Add method is the right one, and the iLogic helper Components.Add seems to need a component occurrence that's already in the assembly to start off with?  I could be reading that wrong

Message 5 of 7
e_frissell
in reply to: e_frissell

Nice, got that to work!  You're pretty quick with the inventor code samples - I've found the help hard to get through


Thanks for the suggestions!

Message 6 of 7
Frederick_Law
in reply to: e_frissell


@e_frissell wrote:

Nice, got that to work!  You're pretty quick with the inventor code samples - I've found the help hard to get through


Thanks for the suggestions!


It take some time to learn how the help works LOL

Notice the actual part sample got bury deep.

 

API help show pure VB code.

iLogic has a different syntax.

Mixing them will cause more confusion.

Message 7 of 7
e_frissell
in reply to: e_frissell

No problem!

 

Thanks for the tips, thank God the vb.net syntax that iLogic runs off of is similar to the VBA or yeah that would have been a big headache

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

Post to forums  

Autodesk Design & Make Report