Print Page | Close Window

Getpolar function

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DXF formats, Design Review, AutoCAD web, Drive, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=11655
Printed Date: 03.Sep.2026 at 19:46


Topic: Getpolar function
Posted By: lucasugar
Subject: Getpolar function
Date Posted: 22.Feb.2016 at 20:36
Hello to everybody,
I'd like to create a lisp function which waits for the user to specify a point which lies on a straight line passing through a specified point and inclined of a specified angle. It's not difficult to code but the function must show a rubber-line which moves only along the specified angle.
I already coded such a function. Here it is:

(defun getpolar (pt ang msg / r)
  (vl-cmdf "_line" pt (strcat "<" (angtos ang (getvar "AUNITS"))))
  (prompt msg)
  (command pause)
  (command)
  (setq r (getvar "LASTPOINT"))
  (entdel (entlast))
  (polarp pt ang (* (distance r pt) (cos (- (angle pt r) ang))))
)

Try it like this:

(getpolar '(0 0 0) 30 "Specifiy end point: ")


But I want the function not to create a line entity and then delete it.

Is there a simpler way?

For example, if from command-line I enter:

(getpoint '(0 0 0) "Specifiy end point: ")

and then:

<45

a rubber-line which moves only along an angle of 45° appears.

But how do I put it in a lisp function?

Thanks to all.




Print Page | Close Window