- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have found two codes for Save As. One code will rename my assembly and two parts to new names in the current folder. I have created a template .iam and named the customizable parts named XXXX WHEEL TEMPLATE and XXXX AXLE TEMPLATE. The other code allows me to Save As assembly file to a specified folder location using the File Dialog Box. This will allow me to save the assembly as a specified file name. This works well but I'm having trouble combining the two codes into one. My goal is to select folder destination to save as, specified file name, and rename the two customizable parts and save as to the same destination folder. These two codes together are creating four file names, two .iam's and two .ipt's. It should only be one .iam and two .ipt's. Also the file name specified in the first code XXXX Z10 1234AB is not carried over to the second code where I need it to properly rename the two .ipt files. Goal is to open a template, trigger iLogic, specify destination, give assembly name, and carry over assembly name as prefix for the two parts.
Thank you,
Samantha
Here is the first code,
oDoc = ThisDoc.Document Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) If oDoc.DocumentType = kPartDocumentObject Then oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt" Else If oDoc.DocumentType = kAssemblyDocumentObject Then oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam" Else If oDoc.DocumentType = kDrawingDocumentObject Then oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw" End If oFileDlg.InitialDirectory = ThisDoc.WorkspacePath() oFileDlg.FileName = iProperties.Value("Project", "Part Number") oFileDlg.CancelError = True On Error Resume Next oFileDlg.ShowSave() If Err.Number <> 0 Then MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled") ElseIf oFileDlg.FileName <> "" Then MyFile = oFileDlg.FileName oDoc.SaveAs(MyFile, False) 'True = Save As Copy & False = Save As End If
Second code,
'Save As new Assembly File and Save As new Wheel and Axle Files Dim Path As String = ThisDoc.Path & "\" InvDoc = ThisDoc.Document Dim refDocs As DocumentsEnumerator = InvDoc.AllReferencedDocuments Dim refDoc As Document Dim PartN As String = "XXXX Z10 1234AB" For Each refDoc In refDocs 'MessageBox.Show(refDoc.DisplayName) If refDoc.DisplayName.EndsWith("WHEEL TEMPLATE.ipt")= True Then 'MessageBox.Show("found2") NewFileName = PartN & " WHEEL.ipt" refDoc.SaveAs(Path & NewFileName, False) ElseIf refDoc.DisplayName.EndsWith("STUB AXLE TEMPLATE.ipt")= True Then 'MessageBox.Show("found1") NewFileName = PartN & " AXLE.ipt" refDoc.SaveAs(Path & NewFileName, False) End If Next ThisDoc.Document.SaveAs(Path & PartN & ".iam", False) iLogicVb.UpdateWhenDone = True
Inventor Pro 2022, WIN10 Pro, Beginner of iLogic
Solved! Go to Solution.