- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a sub assembly inside my template assembly which needs to be save as'd every time the template is saved, because of the use of parameters to make a new set of tooling every time. I have 4 instants of one of the parts inside this sub assembly. Its part file is named Pouch with the respective names in the model tree, Pouch:1, Pouch:2, Pouch:3, and Pouch:4.
Here is my code, in my top level assembly.
iLogicVb.RunRule("Kanga Tooling Template:1", "Save As Rule") iLogicVb.RunRule("Kanga Tooling Gasket Template:1", "Save As Rule") iLogicVb.RunRule("Kanga Tooling Template Gasket Side:1", "Save As Rule") iLogicVb.RunRule("Pouch:???????", "Save As Rule") iLogicVb.RunRule("Tooling Assembly:1", "Save As Rule")
Each of these 4 parts and 1 Assembly contain this same snippet of code as seen below which is a Save As command,
'define the active document oDoc = ThisDoc.Document CurrentFileName = ThisDoc.PathAndFileName(False) 'create a file dialog box Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) Dim Filetype As String 'check file type and set dialog filter If oDoc.DocumentType = kPartDocumentObject Then oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt" Filetype = ".ipt" ElseIf oDoc.DocumentType = kAssemblyDocumentObject Then oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam" Filetype = ".iam" ElseIf oDoc.DocumentType = kDrawingDocumentObject Then oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw" Filetype = ".idw" End If 'set the directory to open the dialog at oFileDlg.InitialDirectory = ThisDoc.WorkspacePath() 'set the file name string to use in the input box oFileDlg.FileName = ThisDoc.FileName(False) 'without extension 'work with an error created by the user backing out of the save oFileDlg.CancelError = True On Error Resume Next 'specify the file dialog as a save dialog (rather than a open dialog) oFileDlg.ShowSave() 'catch an empty string in the imput If Err.Number <> 0 Then 'MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled") ElseIf oFileDlg.FileName <> "" Then MyFile = oFileDlg.FileName 'save the file oDoc.SaveAs(MyFile, False) 'True = Save As Copy & False = Save As NewDocPathName = ThisDoc.PathAndFileName(False) 'open original drawing oDestinationDoc = ThisApplication.Documents.Open(CurrentFileName & ".idw") oDestinationDoc.saveas(NewDocPathName & ".idw",False) oDestinationDoc.Close 'open new drawing oDestinationDoc = ThisApplication.Documents.Open(NewDocPathName & ".idw") Dim oDocDescriptor As DocumentDescriptor oDocDescriptor = oDestinationDoc.ReferencedDocumentDescriptors.Item(1) Dim oFileDescriptor As FileDescriptor oFileDescriptor = oDocDescriptor.ReferencedFileDescriptor oFileDescriptor.ReplaceReference(NewDocPathName & Filetype) oDestinationDoc.Update() oDestinationDoc.Save End If
What can I put in the ??????? section next to pouch to run the code for the Pouch Part File instead of having to save it 4 times.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
you can try this:
iLogicVb.RunRule("Kanga Tooling Template:1", "Save As Rule") iLogicVb.RunRule("Kanga Tooling Gasket Template:1", "Save As Rule") iLogicVb.RunRule("Kanga Tooling Template Gasket Side:1", "Save As Rule") For i = 1 To 4 iLogicVb.RunRule("Pouch:" & i, "Save As Rule") Next iLogicVb.RunRule("Tooling Assembly:1", "Save As Rule")
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com