5 Replies Latest reply on Oct 27, 2016 7:45 AM by Crys Marye

    Get point entity of Helix

    Cedric Lahouste

      Hi,

       

      I would like to create a plane at end of an helix.

      Is there a way to select the end point entity of a existing helix feature?

      This point is selectable in Solidworks but I cant find a way to get it though the API.

      The point retrieved from the ReferenceCurve(ReferenceCurve::GetFirstSegment and CurveParamData::EndPoint) is just array of double. I would like to get the point entity to have my plane following the helix end if the helix change.

      Let me know if you have some idea.

       

      Thanks and regards,

       

      Cedric

        • Re: Get point entity of Helix
          Artem Taturevych

          How did you retrieved the ReferenceCurve from Helix? If you get reference curve you can use the following sequence of methods:

           

          ReferenceCurve::GetFirstSegment->IEdge::GetEndVertex/IEdge::GetStartVertex
            • Re: Get point entity of Helix
              Cedric Lahouste

              You can retrieve it with Feature::GetSpecificFeature2().

               

              Your solution is less steps than mine but also give an array of double.

               

              I finally succeeded to select it with the SelectById2() with the array of double; I dont like that but it is the only solution I found. (I highly prefer Select2() )

               

              Here is the sequence:

              Feature::GetSpecificFeature2()

              ReferenceCurve::GetFirstSegment()

              Edge::GetFirstSegment()

              vEndPoint = Vertex::GetPoint()

              ModelDoc2.Extension.SelectByID2("Unknown", "POINTREF", vEndPoint(0), vEndPoint(1), vEndPoint(2), false, 0, Nothing, 0)

               

              Regards,

            • Re: Get point entity of Helix
              Crys Marye

              try this

              I'm attempting to create a helix programmatically, but it doesn't work.  Half the time it crashes autocad, and half the time it draws a helix that doesn't follow the parameters I set.  Can someone tell me what I'm doing wrong?  Here is the code:

               

              public static ObjectId DrawHelix(Transaction transaction, Point3d startPoint, Vector3d axis, double radius, double height, double numberOfTurns, bool isLeft)

              {
                try
                {
                // Open the Block table for read
                using (BlockTable _blockTable = transaction.GetObject(Utils.ActiveDatabase.BlockTableId, OpenMode.ForRead) as BlockTable)
                {
                  // Open the Block table record Model space for write
                  using (BlockTableRecord _blockTableRecord = transaction.GetObject(_blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord)
                  {
                     using (Helix _helix = new Helix())
                     {
                        _helix.BaseRadius = radius;
                        _helix.TopRadius = radius;
                        _helix.StartPoint = startPoint;
                        //_helix.EndPoint = endPoint; not implemented exception?
                        _helix.Height = height;
                        _helix.Turns = numberOfTurns;
                        _helix.Twist = isLeft;
                        //_helix.AxisVector = axis;

                       _blockTableRecord.AppendEntity(_helix);
                       transaction.AddNewlyCreatedDBObject(_helix, true);

                       return _helix.Id;
                     }
                  }
                }
              }
              catch
              {
              throw new System.Exception();
              }
              }

               

               

              Specific questions:

              1) Do I have to set the properties of the helix in a particular order?

              2) Does the StartPoint property actually control the start of the helix?  On the occasions when this function works, the resulting helix is never drawn anywhere near the given start point.

              3) Autocad's HELIX command asks the user to select a center point, but the Helix class doesn't have a CenterPoint property.  Is there a way to set the center point programmatically?

              4) What is the AxisVector supposed to control?  I commented it out because it never seemed to affect anything.

              5) If I later want to sweep a rectangle along the helix object, can I use the helix directly, or do I need to cast it to another type?

              source: