- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey,
i have a assembly with some parts, i have made a Form where we make choise that depents witch parts need to be save as ( and replace). the assembly runs this rule in de parts to be save as where is automaticly replace it in the assembly. the problem is that is change the parts in all open files.
so i have assembly 1 with :
part 1
part 2
part 3
and also assembly 2 with
part 1
part 2
part 3
i want to save and replace part 1 in assembly 2 to part 1B
it works fine, but in assembly 1 ,part 1 changes also to part 1B
code in assembly:
Sub main() Dim oDoc As Document oDoc = ThisDoc.Document Dim laatsteNaam = "" If Wijzigt_lengte = "Ja" Then ' Save As bovenkoker laatsteNaam = LastName(oDoc,"Bovenkoker_leuning") Try iLogicVb.RunRule(laatsteNaam, "save") Catch End Try ' Save As tussenkoker laatsteNaam = LastName(oDoc,"Tussenkoker_leuning") Try iLogicVb.RunRule(laatsteNaam, "save") Catch End Try ' Save As stootplint laatsteNaam = LastName(oDoc,"Stootplint_leuning") Try iLogicVb.RunRule(laatsteNaam, "save") Catch End Try End If If Wijzigt_hoogte = "Ja" Then ' Save As verticale koker laatsteNaam = LastName(oDoc,"Verticale_koker_leuning") Try iLogicVb.RunRule(laatsteNaam, "save") Catch End Try End If End Sub Function LastName(ByVal d As Document, ByVal search As String) As String Dim temp As ComponentOccurrence For Each oOcc In d.ComponentDefinition.Occurrences.AllLeafOccurrences If oOcc.Name.Contains(search) Then temp = oOcc Dim words As String() = temp.Name.Split(New Char(){":"c}) Return words(0) & ".ipt" Exit For End If Next Return "" End Function
code(Save) is part
Sub main() 'start save copy as icoon met keuze waar en met welke naam 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 End If NewDocPathName = ThisDoc.PathAndFileName(False) End Sub
i have got this code from here, it works fin but is change the part in all open files. This is not what i want.
This code is a rule that is in all of my parts, from a assembly is rune the rule in some parts ( it depent of a choice true a form) so sometimes it needs to
Solved! Go to Solution.