1 Reply Latest reply on Jan 12, 2016 8:41 AM by Alexandre Gragnano

    Create coordinate system

    Alexandre Gragnano

      I am developing a C# standalone application to convert an Excel table (component position & orientation) into a SolidWorks assembly.


      The data gives:

      - Position of component origin with X/Y/Z point

      - Orientation of component origin with X/Y/Z vectors


      I am using a class to manage sketch entities:

      private class InsertPoint
          public SketchPoint Origin;
          public SketchSegment XAxis;
          public SketchSegment YAxis;
          public SketchSegment ZAxis;
          public Feature CoordSystem;


      I create many points with:

      var insertPoints = new List<InsertPoint>();
      insertPoints[i].Origin = skMgr.CreatePoint(...);
      insertPoints[i].XAxis = skMgr.CreateLine(...);
      insertPoints[i].YAxis = skMgr.CreateLine(...);
      insertPoints[i].ZAxis = skMgr.CreateLine(...);


      Screenshot of sketch:



      But when I try to create the coordinate system:

      insertPoints[i].CoordSystem = ftMgr.CreateCoordinateSystem(
          new object[] { insertPoints[i].XAxis },
          new object[] { insertPoints[i].YAxis },
          new object[] { insertPoints[i].ZAxis }


      The coordinate systems has a valid position but not a valid orientation.


      The documentation is light and VBA example not clear.


      Is somebody can see where is my error ?


      Best regards,


        • Re: Create coordinate system
          Alexandre Gragnano

          I can solve the problem with "InsertCoordinateSystem" method but I don't like to work with SelectionManager...

          If someone know how to work with "CreateCoordinateSystem" method, please share your solution.


          selData = selMgr.CreateSelectData();
          selData.Mark = 1;
          insertPoints[i].Origin.Select4(true, selData);
          selData = selMgr.CreateSelectData();
          selData.Mark = 2;
          insertPoints[i].XAxis.Select4(true, selData);
          selData = selMgr.CreateSelectData();
          selData.Mark = 4;
          insertPoints[i].YAxis.Select4(true, selData);
          selData = selMgr.CreateSelectData();
          selData.Mark = 8;
          insertPoints[i].ZAxis.Select4(true, selData);
          insertPoints[i].CoordSystem = ftMgr.InsertCoordinateSystem(false, false, false);