EditPart2 can only be used in an assembly with pieces create in context (ex."Part1^Assem2-1@assem2")?
It should work with any components whether internal or external. The only thing is that it will edit the components within the assembly mode (same as when you click on a component and select edit component)
I have an assembly, inside that assembly exits other assemblies and parts. I want to edit a part contained in one of assemblies, then inside of the principal assembly I select a part, and use EditPart2 as follows but returns -1.
CurrentModel.Extension.SelectByID2("Part1@Assembly1", "COMPONENT", 0, 0, 0, false, 0, null, 0);
SelectionMgr selMgr = (SelectionMgr)CurrentModel.SelectionManager;
IComponent2 component = (IComponent2)selMgr.GetSelectedObject6(1, 0);
int infOut = 0;
((AssemblyDoc)this.CurrentModel).EditPart2(true, true, ref infOut);
What's the error? Am I missing some step?
I used this code in a C# macro on components within a sub-assembly and it worked fine:
public partial class SolidWorksMacro
public void Main()
ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;
AssemblyDoc swAssy = (AssemblyDoc)swModel;
int info = 0;
swAssy.EditPart2(true, false, ref info);
public SldWorks swApp;
SolidWorks API Tutorials
Retrieving data ...