0 Replies Latest reply on Jul 24, 2013 10:59 AM by Greg Lelonek

    Updating Mate Entities Issue

    Greg Lelonek

      I have made a program to replace out components and now I need to update mates that have errors with missing entities.


      I have an issue in replacing out Mate Entities that have a missing Face. I can find the new Face, it shows up Highlighted in the SolidWorks Model, but does not replace out.

      The macro recorder does code as follow:


                public void Main()
                  ModelDoc2 swDoc = null;
                  PartDoc swPart = null;
                  DrawingDoc swDrawing = null;
                  AssemblyDoc swAssembly = null;
                  bool boolstatus = false;
                  int longstatus = 0;
                  int longwarnings = 0;
                  swDoc = ((ModelDoc2)(swApp.ActiveDoc));
                  boolstatus = swDoc.Extension.SelectByID2("Coincident25", "MATE", 0, 0, 0, false, 0, null, 0);
                  boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.94584445977108089, 0.11834318387104759, -0.033980404540841391, true, 1, null, 0);
                  boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.94584445977114617, 0, 0, true, 1, null, 0);
                  boolstatus = swDoc.Extension.SelectByID2("", "FACE", 0.94584445977114628, 0.09778372782389165, -0.036034107499066353, true, 1, null, 0);
                  swAssembly = ((AssemblyDoc)(swDoc));
                  swAssembly.EditMate2(0, 1, false, 0.0452092189206309, 0, 0, 0.0254, 0.0254, 0, 0.5235987755983, 0.5235987755983, out longstatus);
                  boolstatus = swDoc.EditRebuild3();

              /// <summary>
              ///  The SldWorks swApp variable is pre-assigned for you.
              /// </summary>
              public SldWorks swApp;



      The problem with selecting the Faces with this method is my coordinates of the component change. Another possible issue is if there are multiple faces very close together, then it may select the wrong face. I know the Entity:Select4(...) method can select the proper face, but what would need to be done to get the new mate entities to accept the new entities.


      Does anyone have an example of a method to select a face without using coordinates?