<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating a polyline using distances between points. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/creating-a-polyline-using-distances-between-points/m-p/3633244#M53136</link>
    <description>&lt;P&gt;Here's a few C# extension methods for Point3d that compute polar and spherical points relative to a given Point3d.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Autodesk.AutoCAD.Geometry
{
   public static class AcGeExtensions
   {
      /// 2D Polar specificiation (distance/angle)

      public static Point3d GetPointAt( this Point3d basepoint, double distance, double AngleInXYPlane )
      {
         return new Point3d(
            basepoint.X + ( distance * Math.Cos( AngleInXYPlane ) ),
            basepoint.Y + ( distance * Math.Sin( AngleInXYPlane ) ),
            basepoint.Z );
      }

      /// Spherical Coordinate (radius/phi/theta)
   
      public static Point3d GetPointAt( this Point3d center, double radius, double phi, double theta )
      {
         double phicos = Math.Cos( phi );
         return new Point3d(
            center.X + ( radius * phicos * Math.Cos( theta ) ),
            center.Y + ( radius * phicos * Math.Sin( theta ) ),
            center.Z + ( radius * Math.Sin( phi ) ) );
      }
   }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Sep 2012 16:42:01 GMT</pubDate>
    <dc:creator>DiningPhilosopher</dc:creator>
    <dc:date>2012-09-25T16:42:01Z</dc:date>
    <item>
      <title>Creating a polyline using distances between points.</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-a-polyline-using-distances-between-points/m-p/3633100#M53135</link>
      <description>&lt;P&gt;Hello I am new to the .Net api. I am aware of creating a polyline and using .AddVertexAt() to give the points, my question is if I want to create a polyline in acad I generally will pick a point and then type out @10.5&amp;lt;0 or something similar of that nature to pick my next point. Is it possible to add vertices to a polyline in .Net giving it the distance and angle of one point2d to the next point2d?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;acPoly.AddVertexAt(0, New Point2d(0,0),0,0,0)&lt;/P&gt;&lt;P&gt;acPoly.AddvertexAt(0, New Point2d(1,0),0,0,0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;acPoly.AddVertexAt(0, New Point2d(0,0),0,0,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;acPoly.AddVertex ( use code equivalent of &amp;nbsp;New Point2d = @10.5&amp;lt;0 from point at 0 index)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2012 15:42:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-a-polyline-using-distances-between-points/m-p/3633100#M53135</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-25T15:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a polyline using distances between points.</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-a-polyline-using-distances-between-points/m-p/3633244#M53136</link>
      <description>&lt;P&gt;Here's a few C# extension methods for Point3d that compute polar and spherical points relative to a given Point3d.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Autodesk.AutoCAD.Geometry
{
   public static class AcGeExtensions
   {
      /// 2D Polar specificiation (distance/angle)

      public static Point3d GetPointAt( this Point3d basepoint, double distance, double AngleInXYPlane )
      {
         return new Point3d(
            basepoint.X + ( distance * Math.Cos( AngleInXYPlane ) ),
            basepoint.Y + ( distance * Math.Sin( AngleInXYPlane ) ),
            basepoint.Z );
      }

      /// Spherical Coordinate (radius/phi/theta)
   
      public static Point3d GetPointAt( this Point3d center, double radius, double phi, double theta )
      {
         double phicos = Math.Cos( phi );
         return new Point3d(
            center.X + ( radius * phicos * Math.Cos( theta ) ),
            center.Y + ( radius * phicos * Math.Sin( theta ) ),
            center.Z + ( radius * Math.Sin( phi ) ) );
      }
   }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2012 16:42:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-a-polyline-using-distances-between-points/m-p/3633244#M53136</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2012-09-25T16:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a polyline using distances between points.</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-a-polyline-using-distances-between-points/m-p/3633280#M53137</link>
      <description>&lt;P&gt;It will depend on how you collect user input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you write code to get user input as a text string like "@10&amp;lt;0", then you have to first validate the text string to make sure it is in expected format and then you need to parse it into a number as distance and a number as angle. Then you can calculate the point, based on previous point, as shown in the other reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, AutoCAD .NET API provides a built-in way to get point, which allows user to pick point, or enter point iin the standard AutoCAD input format (i.e. like "@10&amp;lt;0"). You do not need to do anything, the method returns the point. What the the magic method? it is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Editor.GetPoint(PromptPointOptions options)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you call this method with UseBasePoint option&amp;nbsp;being true and BasePoint being specified,&amp;nbsp;user can either pick a point or enter "@10&amp;lt;0" at command line. The method will give you a point back, spare you from doing geometric calculation.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2012 16:56:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-a-polyline-using-distances-between-points/m-p/3633280#M53137</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2012-09-25T16:56:34Z</dc:date>
    </item>
  </channel>
</rss>

