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

Close

.NET

- Autodesk Community
- >
- AutoCAD Customization
- >
- .NET
- >
- Internal angles of a polyline

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

411 Views, 2 Replies

02-26-2013 09:37 AM

Hi:

I have created the following code in VB.NET that i allows you to

calculate the internal angle of a polyline. First delivery getting the angle of

deflection, a ves obtained 180 you rest this and get the inner corner. All fine, as long as the polyline is the image-1.png. Otherwise, if the polyline is as in the image-2.png there is an error in the

vertex B.

That algorithm could follow in order to comply with the correct value. Since

later this data i presented it in a table of AutoCAD.

thanks for your help.

Public Shared Function AngleDeflection(ByVal pto3d As Point3dCollection) As ArrayList Dim anguloM As Double = 0 Dim vangl As ArrayList = New ArrayList For i As Integer = 0 To pto3d.Count - 2 Dim V As Integer = pto3d.Count - 2 If i = 0 Then anguloM = Math.Atan2(pto3d.Item(i).Y - pto3d.Item(V).Y, pto3d.Item(i).X - pto3d.Item(V).X) - Math.Atan2(pto3d.Item(i + 1).Y - pto3d.Item(i).Y, pto3d.Item(i + 1).X - pto3d.Item(i).X) vangl.Add(anguloM) Else anguloM = Math.Atan2(pto3d.Item((i - 1) + 1).Y - pto3d.Item(i - 1).Y, pto3d.Item((i - 1) + 1).X - pto3d.Item(i - 1).X) - Math.Atan2(pto3d.Item((i - 1) + 2).Y - pto3d.Item((i - 1) + 1).Y, pto3d.Item((i - 1) + 2).X - pto3d.Item((i - 1) + 1).X) vangl.Add(anguloM) End If Next Return vangl End Function

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

02-28-2013 11:35 AM in reply to:
ccalvo12

Hello,

Here is a thread that might give you some ideas to solve the issue :

I havent tried the code that Gilles Chanteau has suggested in that thread.

I also have a more complicated way to solve this problem

It works for both the kind of closed polylines that you have mentioned about.

The idea is the almost the same as Gilles suggests. Use the "GetAngleTo" method to determine the angle which will always lie between 0 and PI. But there is also an additional check to see if that angle is an interior angle of the closed polyline.

I have attached the source code in case you wish to try.

Developer Technical Services

Autodesk Developer Network

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

03-01-2013 07:42 AM in reply to:
Balaji_Ram

Hello:

thank you very much for the reply, I reviewed the code and definitely is going to help me in solving the problem.

Greetings

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.