Are we going to edit the standard AutoCAD commands? No way. Rather we will look how to achieve a similar functionality in a tricky way. We are going to make use of AutoLISP's special ability to work transparently in between commands. Let us see how to utilise this to draw a circle with circumference option.
Add the following lisp routine to your acadDoc.lsp file. If the acaddoc.lsp file does not exist, create a new one.
(defun c:C#() (/ (getreal "\nEnter circumference : ") (* 2 pi)))
Now we can use this circumference option inside the circle command in the following way.
Command: Circle
Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: Pick center point
Specify radius of circle or [Diameter] <5.5>: 'C#
Enter circumference : 100
15.9155
Don't forget to provide the option as transparent using apostrophe ('). It will draw a circle with given circumference. Note that you can use any convenient option name in place of C#. I used the special character '#' in order to distinguish it from the standard command shortcuts. Here goes another sample for creating a circle with 'Area' option. Follow the same procedure you did for the previous option.
(defun c:A#() (sqrt (/ (getreal "\nEnter circle area : ") pi)))
And use it in this way
Command: Circle
Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: Pick center point
Specify radius of circle or [Diameter] <6.8>: 'A#
Enter area : 500
12.6157
If you come up with any other options, feel free to share it here.
Tuesday, October 9, 2007
Subscribe to:
Post Comments (Atom)
1 comment:
Very nice!!!
Post a Comment