Hello Guys!
Bummer... I`m trying to replace part in the assembly with same part with a different name. The idea is:
1. open Assembly document - works
2. save it as with a new name - works
' opening assembly
swModel = swApp.OpenDoc6(".....path.....PLENUMASSY.SLDASM", swDocumentTypes_e.swDocASSEMBLY,
swOpenDocOptions_e.swOpenDocOptions_ReadOnly, "", fileerror, filewarning)
swModel = swApp.ActiveDoc
' saving Assembly model AS new A#
boolstatus = swModel.Extension.SaveAs(My.Settings.LastSaveADir + txt_AssNum.Text.Trim + ".sldasm", 0, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, fileerror, filewarning)
3. assembly has 4 parts, so I`m trying to open first part - works
'opening top plenum part
swPartModel = swApp.OpenDoc6(".....path....PLTRIMTOP.SLDPRT", swDocumentTypes_e.swDocPART,
swOpenDocOptions_e.swOpenDocOptions_ReadOnly, "", fileerror, filewarning) 'open part file as read only
swPartModel = swApp.ActiveDoc
' saving files
boolstatus = swPartModel.Extension.SaveAs(My.Settings.LastSaveMDir + txt_Part1.Text.Trim + ".sldprt", 0, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, fileerror, filewarning) ' saves assembly
So its saves the part in the directory but it doesn replaces it in the active assembly.... Like if you do it manually in SW you click save as and you choose to replace all parts in all open assemblies.... is there a way to do that programmatically?
I guess the other question if this is not possible, can someone give me an example of the code that chooses certain part (lets say PLTRIMTOP.SLDPRT) in the active assembly and replaces it with a different part? I know how to replace
boolstatus = swAssy.ReplaceComponents(My.Settings.LastSaveMDir + txt_Part1.Text.Trim + ".sldprt", "", True, True)
but I`ve no idea how to choose specific part.
Any help is appreciated.
Thanks,
Alex
SolidworksApi macros