Save As change in all open files

Save As change in all open files

jurgenvoorspoels
Observer Observer
301 Views
1 Reply
Message 1 of 2

Save As change in all open files

jurgenvoorspoels
Observer
Observer

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 

Accepted solutions (1)
302 Views
1 Reply
Reply (1)
Message 2 of 2

bradeneuropeArthur
Mentor
Mentor
Accepted solution
This is default behavior.
Use save copy as and replace the file afterwards.

Regards,

Arthur Knoors

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature