3 Replies Latest reply on Apr 23, 2015 4:18 PM by Keith Rice

    EditPart2

    Erika Gómez

      EditPart2 can only be used in an assembly with pieces create in context (ex."Part1^Assem2-1@assem2")?

        • Re: EditPart2
          Deepak Gupta

          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)

            • Re: EditPart2
              Erika Gómez

              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?

                • Re: EditPart2
                  Keith Rice

                  I used this code in a C# macro on components within a sub-assembly and it worked fine:

                   

                  using SolidWorks.Interop.sldworks;
                  using SolidWorks.Interop.swconst;
                  using System.Runtime.InteropServices;
                  using System;
                  
                  namespace Macro1.csproj
                  {
                      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;
                      }
                  }
                  

                   

                  Keith

                  SolidWorks API Tutorials