Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Close

.NET

- Autodesk Community
- >
- AutoCAD Customization
- >
- .NET
- >
- Re: Creating a polyline using distances between po...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

Active Member

6 Posts

0 Kudos

Registered:
09-25-2012

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

389 Views, 2 Replies

09-25-2012 08:42 AM

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<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?

Example:

acPoly.AddVertexAt(0, New Point2d(0,0),0,0,0)

acPoly.AddvertexAt(0, New Point2d(1,0),0,0,0)

but instead?

acPoly.AddVertexAt(0, New Point2d(0,0),0,0,0)

acPoly.AddVertex ( use code equivalent of New Point2d = @10.5<0 from point at 0 index)

Solved! Go to Solution.

Solved! by DiningPhilosopher. See the answer in context.

Here's a few C# extension methods for Point3d that compute polar and spherical points relative to a given Point3d.

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 ) ) ); } } }

Valued Mentor

370 Posts

175 Kudos

Registered:
05-06-2012

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-25-2012 09:42 AM in reply to:
baw6718

Here's a few C# extension methods for Point3d that compute polar and spherical points relative to a given Point3d.

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 ) ) ); } } }

*Expert Elite*

1,084 Posts

215 Kudos

Registered:
04-27-2009

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-25-2012 09:56 AM in reply to:
baw6718

It will depend on how you collect user input.

If you write code to get user input as a text string like "@10<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.

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<0"). You do not need to do anything, the method returns the point. What the the magic method? it is:

Editor.GetPoint(PromptPointOptions options)

When you call this method with UseBasePoint option being true and BasePoint being specified, user can either pick a point or enter "@10<0" at command line. The method will give you a point back, spare you from doing geometric calculation.

Search This Board

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Post to the Community

Have questions about Autodesk products? Ask the community.

The Knowledge Network

Access a broad range of knowledge to help get the most out of your products and services.

Download & Installation

Getting your Software

Downloads & Upgrades

Serial Numbers & Product Keys

Installation & Licensing

Activation & Registration

Network License Administration

Subscription Management

Sign In / Create Account

Maintenance Subscription Help

Desktop Subscription Help

Cloud Service Subscription FAQ

- Privacy | Legal Notices & Trademarks | Report Noncompliance | Site map | © Copyright 2014 Autodesk Inc. All rights reserved

Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see the Autodesk Creative Commons FAQ for more information.