Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
tmathieson
526 Views, 7 Replies

ilogic code to copy and replace in ana ssembly

Hello All,

 

i am working on a piece of code that will insert components into an assembly and mate to each other accordingly.  i have this working fine, but i want to take all the component and save them with new names and replace the ones in the assembly, basically  the "Productivity> Save and Replace" command. searching thru the forms her, it seems like the

 

 (component name).SaveAs (new filename, false)

 

should save the component with the new name in the same directory as the assembly file, and replace the original part with the newly saved one....

 

so that is what i am trying to code here, but i keep getting errors like "parameter is incorrect".... on the SaveAs line

 

	If i = 1 Then
			GROUND = True
			Dim componentB = Components.Add(PLATE_PRE & i, "SC-H-2R-P1.ipt", position := Nothing, grounded := GROUND, visible := True, appearance := asgreen)
			Dim doc As Document = Component.InventorComponent(PLATE_PRE & i).Definition.Document
			
			File_new_name = "help-" & i
			Logger.Debug(File_new_name)
			doc.SaveAs(File_new_name , False)
			GROUND=False
			GoTo JUMP_NEXT

 its probably something to do with how i am defining the doc variable, but not sure.... any help, as always, would be greatly appreciated.