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
Solved! Go to Solution.
Solved by Frederick_Law. Go to Solution.
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
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
This add iAssembly to assembly:
https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-09855FE4-D659-4F67-9DDA-7F733D800134
https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-729F272D-821C-4DFF-B604-8C89035D6D88
This add part:
https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-9B88A5A9-E7C8-4D44-B192-B711161F6A34
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!
@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.
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.