AutoLISP: Point Circle

This routine lets you create a circle that is made of AutoCAD Point entities. A great feature of this routine is that it lets you determine the starting point where the first point will be placed.

Here’s how:

Set the Point Type to a points size and type that is visible by using the DDPTYPE command.

  • PCIRC <enter> to start
  • Specify the center point for the circle
  • Specify the radius (note: there is NO option to specify a diameter…)
  • Specify the Starting Point. This is where the first point will be placed
  • Specify the number of points that you want the “circle” to be made of.

(vl-load-com)
(defun c:pcirc (/ p r u n c lst param delta)
(if
(and
(setq p (getpoint "\nCenter point: "))
(setq r (getdist p "\nRadius: "))
(setq u (getangle p "\nStart angle: "))
(setq n (getint "\nNumber of points: "))
(setq c (entmakex (list '(0 . "CIRCLE") (cons 10 p) (cons 40 r)))
)
)
(progn
(setq lst
(mapcar
'(lambda (x) (vlax-curve-getPointAtParam c x))
(repeat n
(setq param
(cons
(+ (cond ((car param))
((- u (setq delta (/ (* 2. pi) n))))
)
delta
)
param
)
)
)
)
)
(entdel c)
(mapcar '(lambda (x) (entmakex (list '(0 . "POINT") (cons 10 x)))) lst)
)
)
(princ)
)
Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, AutoLISP: Creating. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s