ReplaceComponents Macro
ReplaceComponents Macro
(OP)
I am simply trying to write a macro that will replace components in an assembly. I tried recording a macro and doing some 'reverse engineering' on it but I keep on getting an error. Here is the code I am using:
Set Part = swApp.OpenDoc4("C:\Program Files\SolidWorks\data\Templates\DMAssembly.sldasm", 2, 0, "", longstatus)
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID("DM1-1@DMAssembly", "COMPONENT", 0, 0, 0, False, 0, Nothing)
Part.ClearSelection
Part.ReplaceComponents "Some File Name", "", False, 0, True
Thanks in advance for any help.
Set Part = swApp.OpenDoc4("C:\Program Files\SolidWorks\data\Templates\DMAssembly.sldasm", 2, 0, "", longstatus)
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID("DM1-1@DMAssembly", "COMPONENT", 0, 0, 0, False, 0, Nothing)
Part.ClearSelection
Part.ReplaceComponents "Some File Name", "", False, 0, True
Thanks in advance for any help.






RE: ReplaceComponents Macro
No need to "Set Part = swApp.ActiveDoc" is you already have the part object from using OpenDoc6
Try selecting using AssemblyDoc::FeatureByName
RE: ReplaceComponents Macro
RE: ReplaceComponents Macro
retval = AssemblyDoc.ReplaceComponents ( fileName, configName, replaceAllInstance, reAttachMates )
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: ReplaceComponents Macro