Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JhoelForshav
in reply to: mikejones

Hi @mikejones 

The document will save with the assembly as long as it has a filename. Since you haven't specified a filename for it yet, Inventor wouldn't know where to save it. You can just add a filepath to the document:

Dim oTemplate As String = "C:\Users\Public\Documents\Templates\Master Hopper.ipt"
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oDocumentDefinition As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oMatrix As Matrix = oTG.CreateMatrix
Dim pDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, oTemplate, False)
pDoc.FullFileName = ThisDoc.Path & "\some name.ipt" 'Add a filepath
oDocumentDefinition.Occurrences.AddByComponentDefinition(pDoc.ComponentDefinition, oMatrix)
oDoc.Save

Of course, the assembly has to have a filepath aswell for the save command to work. But I'm assuming in this case it has already been saved at some time :slightly_smiling_face:

If you want to use SaveAs on the assembly that would work too anyways, but then you cannot use ThisDoc.Path before as in the example above, becase if the assembly hasn't been saved ThisDoc.Path is nothing.