3 Replies Latest reply on Apr 19, 2018 10:24 PM by David King

    Align Axes on CoordinateSystem C#

    David King

      I’m working on Solidworks 2014 and am trying to make a mate between a component and a coordinate system within an assembly.

       

      The manual way to do it is to select the origin on the component and the coordinate system and click mate, then ensure Align Axes is selected.

       

      When I create the mate programmatically in C# after selection (using 1 as the mark) does not select Align Axes:

      int error;

      swModel.OOGetAssemblyDoc().AddMate4((int) swMateType_e.swMateCOINCIDENT, -1, false, 0, 0, 0, 0, 0, 0, 0, 0, false, true, out error);

      if ((swAddMateError_e)error != swAddMateError_e.swAddMateError_NoError) {

           throw new Exception("Failed to add mate.  swAddMateError_e: " + (swAddMateError_e)error);

      }

       

      Any version of the align type:

      swMateAlign_e.swMateAlignANTI_ALIGNED

      swMateAlign_e.swMateAlignALIGNED

      swMateAlign_e.swMateAlignCLOSEST

       

      or switching flip does not select align axes.

       

      I tried to change the mate type to coordinate system however it gives an invalid selection error.

       

      The documentation does not help with this:

      http://help.solidworks.com/2014/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.iassemblydoc~addmate4.html

       

      I tried recording a macro while doing it manually however it didn’t produce something that worked while playing it back.

       

      Does anyone know how to select the Align Axes box on mate programmatically.

       

      Align Axes.png