- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I posted this in the wrong forum yesterday so reposting here hoping someone can help.
I've just started experimenting with ilogic and I would like to understand how to perform the following task.
I have a master assembly called PS07-01 and multiple parts in the assembly called PS07-01-01, PS07-01-02 etc..
I would like to save a version of the assembly as a different name e.g. PS07-02 and when I do, the associated parts would also save with a new name PS07-02-01, PS07-02-02 etc..
I have looked through the forum and the closest code I could find was the one below by @CurtisWaguespack . However, this code only worked if I selected the parts, I would rather it was automated.
Any help would be gratefully appreciated.
Graeme
On Error Resume Next
oSelect = ThisDoc.Document.SelectSet.Item(1)
'catch an empty string in the imput
If Err.Number <> 0 Then
MessageBox.Show("Please select a component before running this rule.", "iLogic")
Return
End If
' get a component by name.
Dim compOcc = Component.InventorComponent(oSelect.name)
'define document
oDoc = compOcc.Definition.Document
'create a file dialog box
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
'check file type and set dialog filter
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"
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 = System.IO.Path.GetFileName(oDoc.FullFileName)
'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
End If
Graeme
Solved! Go to Solution.