jpsheader.jpg (29354 bytes)

Back to AutoLisp Tutorial Homepage

Back to AutoLisp Homepage

Back to /













The AutoLisp Tutorial - Extreme

  Well you made it.  You've read the Beginners, Intermediate, and Expert's tutorials and now you want to apply your knowledge in real world situations.  I believe the best way to approach this is to read through commented code and follow what is going on.   It would be even better if you had the programmers thoughts before starting the program.  So, we will do that.  But what code?  This I will leave up to you.  If you have read all of the tutorials and still can't get the code to do what you want, click <here> to suggest a program for the Extreme section.   I'll start it with a couple of problems I've encountered in the last year or so.  Placing vertices along a polyline bulge and figuring the angle of an  arc.  I know, seems simple.  But what happens when your start angle is around 350 degrees and your end angle is around 30 degrees.  You can't subtract the end angle from the start angle can you?

Placing vertices along a PolyLine Bulge

Figuring the Angle of an Arc















PolyLine Bulge

  Have you ever tried to recreate a polyline by drawing lines from vertex to vertex only to find out it doesn't work if you have a polyline bulge?  (ARC) Aggravating isn't it.  Well, I've found a method to insert vertex points along the polyline bulge area to recreate a bulge effect and get you closer to what you need.  I'm looking for this code....

Arc Angle

  Have you ever tried to figure the angle of an arc only to be fustrated by the fact the angle cannot be simply subtracted?  It's true because an arc's angle is always measured counter clock-wise so you could have a starting angle of 350 degrees and an ending angle of 30 degrees.  Can't subtract the end angle from the start angle can you?  When it crosses zero, there are problems.  (Angle could also be set to clock-wise instead of counter clock-wise)

  The first method I used was to begin at the starting angle and increment the angle by one until I reached the end angle or I crossed the zero angle.  This works but it is a little goofy.

  The second method I've seen (sent to me by a visitor) was to reset the UCS to the center point with an angle that matched the starting angle.   Then simply get the ending angle.  Not bad.  Not bad at all.

  The shortest method I've found was to use the built in geometry calculator:

EXT01.JPG (10893 bytes)

  The calculator function we will use is called ANG.  The syntax is ANG(apex, endPt1, endPt2).  In the illustration above the apex is P1, the first point is P2, and the third point is P3.  You can also do this on the command line.   Type CAL and press enter.  Then type ang(cur,cur,cur) and press enter.   Now pick the three points.

  To do this in first need to make sure the calculator is loaded:

     (if (not c:cal)(arxload "geomcal"))

  Then send your points to the calculator: 

  (setq myAng (cal "ang(p1,p2,p3)")

  This should set variable myAng to 51.9180

  Anyone else have a shorter answer?  <click>

AutoLisp Tutorial Home

AutoLisp Home


All questions/complaints/suggestions should be sent to /

Last Updated April 1st, 2013

Copyright 2002-2013 /. All rights reserved.