JPC
; ----- CTEST.LSP -----
; Draw circles by area
(defun C:CTEST()
(setq ar (getreal "Area? "))
(setq pt (getpoint "Centerpoint?"))
(setq rad (sqrt (/ ar pi)))
(command "circle" pt rad)
(princ)
)
Rectangles are a little trickier. Do you have some way of relating the
length of the rectangle to its width?
JPC
> Is there a lisp routine available to draw either a circle or rectangle
> with a known square yard area?
You can do that with Geomcal in AutoCAD or with BricsCAD with my Geomcal
compatible CADCAL application. Geomcal.arx is part of the AutoCAD
distribution, simply type 'CAL a�t the command prompt or when asked top
enter a point inside a command.
CAL (either from Geomcal or from CADCAL) let's you enter mathematical
expressions that can be used as input to commands. When your area is 123,
then you could draw a rectangle from any startpoint, and when asked for the
opposite point you could enter:
'CAL
>> expression: @+[sqrt(123),sqrt(123)]
In this expression '@' stands for the last entered point, in this case this
is the first point of your rectangle. And the rest is self explaining, as I
hope.
You can also use Lisp variables in your expressions:
(setq ar 123)
'CAL
>> expression: @+[sqrt(ar),sqrt(ar)]
If you are working with BricsCAD then you can download CADCAL from
http://www.archtools.de/cadcal.des
--
ArchTools: Architektur-Werkzeuge f�r AutoCAD (TM)
ArchDIM - Architekturbema�ung und H�henkoten
ArchAREA - Fl�chenermittlung und Raumbuch nach DIN 277
Info und Demo unter http://www.archtools.de
Hi John,
Try to avoid top-posting. My provider handles it OK but it drives some
people around here absolutely bananas.
You don't really need to set your units 'to' anything. Although
AutoCAD supports conventions for inputting measurements like [ ' ] for
feet and [ " ] for inches, don't be fooled, AutoCAD really has no
interest in what your preferred units are. The issue only arises when
working with data provided by others. In your case, it seems like
you're working on a drawing drawn in 'feet'. Because there are 3 feet
in a yard just scale the drawing by 1/3rd. If the drawing's in inches
just scale it by 1/(3*12) = 1/36. When you're done using the lisp
command, just scale it back again - or at least make it very apparent
in the drawing that that's what you've done!
Also, I forgot to mention that AutoCAD's RECTANGLE command has of
course already got a feature built-in for drawing rectangles based
upon their area and a known length or width.
Strawberry,
I posted this below your message, I didn't realize it made any
difference and do apologize. Your lisp works fine. Would it be
possible to tweak it?
2 issues
1) Could you explain further how I can insert a known area in square
yards when I use the rectang command?
2) Since I know what my area is in square yards and there are 1296 sq
inches in a square yard, could you modify the lisp you sent to prompt
for an "area SY"?
JPC
1.
; ----- RECTEST.LSP -----
; Draw rectangles by area (in square yards) and one known length (in
yards)
(defun C:RECTEST()
(setq ar (getreal "AreaSY? "))
(setq ar (* ar 1296))
(setq len (getreal "LengthY? "))
(setq len (* len 36))
(setq pt (getpoint "Cornerpoint?"))
(command "rectangle" pt "a" ar "l" len )
(princ)
)
2.
; ----- CTEST.LSP -----
; Draw circles by area (in square yards)
(defun C:CTEST()
(setq ar (getreal "AreaSY? "))
(setq ar (* ar 1296))
BTW, although I'm not the world's worst lisp programmer, I'm
definitely a contender for that prize, so feel free to have a go at
this stuff yourself! :-)
>> Thanks, that is good for a circle area. I tried to set my units to 9'
>> (ddunits) so I can get square yards when I run your lisp, but I am
>> having problems. Can you guide me how to set my units to 9'?
>
> Try to avoid top-posting.
And please try to remove everything from the original posting that is not
necessary for your reply :-)
Citing parts of the posting to which you reply is only necessary for one
thing: to enable the reader of your posting to understand your reply.
The circSY lisp works great! However I have trouble with the
rectangSY lisp. Is there a way to just have the prompt ask only for
the Square Yards? When I enter the sy it then asks for one corner then
another which then will not be the square yards I entered.
I cleaned out the rest of the thread to improve my protocol.
JPC
It works fine on my machine (XP running AutoCAD2008). Your version
must be a little different.
Run through the rectang command (using the area option - and not using
my rectest routine) and post the results here, e.g.:
Command: rec RECTANG
Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/
Width]: [User clicks point on screen]
Specify other corner point or [Area/Dimensions/Rotation]: a
Enter area of rectangle in current units <129600.0000>: 100
Calculate rectangle dimensions based on [Length/Width] <Length>: l
Enter rectangle length <360.0000>: 10
Strawberry,
I should have stated before, I am running Version R14. There
is no area option for the second corner.
JPC
14!?!? That's from 12 years ago! Pause while I get doey-eyed and
misty. Still, it was an excellent program and, unless you plan to work
in 3d, probably the only version you'd ever need.
The lisp can still be adjusted to work. I just need to remember how to
do vector maths in lisp. It would still be useful to see what the
command 'looks' like though. Is it just "select first corner, select
second corner' or is/was there more to it than that?
Also, can you define the relationship between the length of the
rectangle and its width, or is its width, say, a constant?
Strawberry,
The following is from my R14
Command: rectest
AreaSY? 1052
LengthY? 100
Cornerpoint?rectangle
Chamfer/Elevation/Fillet/Thickness/Width/<First corner>:
Other corner: a
Invalid 2D point.
error: Function cancelled
(COMMAND "rectangle" PT "a" AR "l" LEN)
(C:RECTEST)
Other corner:
The lisp creates a rectangle but I have no control over the SY
even though it first asks for Area SY input. It continues on to ask
for both corner points which essentially negates the first Area SY
input. If it only asked me for the SY area and then created the
rectangle using one corner, it would be fine.
Lengths & widths are not factors at all. All I need is to be
able to plug in a known SY quantity. I am converting existing
contracts to a different format using different unit factors. The
circle lisp has helped greatly. It would be perfect if I could also
use the rectang lisp to create a retangle with a known quantity of
square yards.
JPC
!?!
So you'd be just as happy with a square?
>> � � � � Lengths & widths are not �factors at all.
>
>!?!
>
>So you'd be just as happy with a square?
I never really thought about that, but yes, that is correct.
; ----- SQUARETEST.LSP -----
; Draw rectangles by area
(defun C:SQUARETEST()
; Degrees to Radians
(defun dtr (a)(* pi (/ a 180)) )
; Get area in square yards
(setq ar (getreal "AreaSY? "))
; Convert to square inches
(setq ar (* ar 1296))
; Get first point (bottom left-hand corner of square)
(setq p1 (getpoint "\nfirst corner of square: "))
; Calculate second point (top right-hand corner of square)
(setq p2 (polar p1 (dtr 45.0) (sqrt (+ ar ar))))
; Execute
(command "rectangle" p1 p2)
; Exit quietly
(princ)
)
Hm, this solution is subject to floating point errors. It will perform
oddly when drawing far from 0,0
(defun C:SQUARETEST()
; Degrees to Radians
(defun dtr (a)(* pi (/ a 180.0)) )
(defun C:SQUARETEST()
; Degrees to Radians
(defun dtr (a)(* pi (/ a 180.0)) )
Sincerely,
John P. Callaway