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

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

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

372 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.

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

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

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements

Start with some of our most frequented solutions to get help installing your software.

Upgrading to a 2015 product? Make sure to check these out 1st!

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