09-05-2020
02:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-05-2020
02:41 PM
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 ![]()
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.
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website