Jump to content

lisp for area in square feet


jcalla

Recommended Posts

I am looking for a lisp routine to create an area in a given square feet quantity. Can someone help me out?

 

Thanks,

JPC

Link to comment
Share on other sites

Welcome to CADTutor - In the future, please post your LISP questions in the AutoLISP, Visual LISP & DCL Forum.

 

As for your request... are you looking for a LISP routine to create an object with a specific area, or are you looking to select an object(s) and label the area of said object(s)? :unsure:

Link to comment
Share on other sites

  • 3 weeks later...

The shape of the area would be a rectangle. I have a lisp for a circle. It is as follows:

 

; ----- CTEST.LSP -----

; Draw circles by area (in square yards)

(defun C:CTEST()

(setq ar (getreal "AreaSY? "))

(setq ar (* ar 1296))

(setq pt (getpoint "Centerpoint?"))

(setq rad (sqrt (/ ar pi)))

(command "circle" pt rad)

(princ)

)

Could this be modified for the area of a rectangle?

 

Thanks,

JPC

Link to comment
Share on other sites

If its a rectangle then whats the problem the area= L x W you just have to nominate 1 of them then theres lots of ways to draw a rectang simplest would be use RECTANG.

 

(setq pt1 (getpoint "Left lower corner ?")) the (car pt1) = x (cadr pt1) = y add L & W to these values then make a list for new Pt2 (setq pt2 (list (+ ptx L) (+ pty W)))(command "rectang" pt pt2)

Link to comment
Share on other sites

OK. If the rectang command would prompt me for an area in square feet, then I would be ok. I need a lisp that would prompt me for a start point then ask me for either a lenght or width, then prompt me for the square feet at the given length or width.

 

JPC

Link to comment
Share on other sites

RECTANG
Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]:
Specify other corner point or [Area/Dimensions/Rotation]: A

Link to comment
Share on other sites

I forgot one thing. I use version R14, so I don't have the option of entering the area using the rectang command which is why I am asking about a lisp routine.

 

JPC

Link to comment
Share on other sites

As an imitation of the Rectang command in 2010...

 

(defun c:arec ( / an ar p1 x )
 (if
   (and
     (setq p1 (getpoint "\nSpecify first corner point: "))
     (progn (initget 6)
       (setq ar (getreal "\nSpecify Area for Rectangle: "))
     )
     (progn (initget "Length Width")
       (setq an (getkword "\nCalculate rectangle dimensions based on [Length/Width] <Length>: "))
       (if (eq "Width" an)
         (setq x (getdist "\nSpecify rectangle width: " p1))
         (setq x (getdist "\nSpecify rectangle length: "p1))
       )
     )
   )
   (command "_.rectang" "_non" p1 "_non"
     (polar
       (polar p1 (if (eq "Width" an) 0. (/ pi 2.)) x)
       (if (eq "Width" an) (/ pi 2.) 0.)
       (/ ar x)
     )
   )
 )
 (princ)
)

Link to comment
Share on other sites

Lee Mac

On the right path, however the above routine area defaults in square inches. Could you redo your magic to default in square feet?

JPC

Link to comment
Share on other sites

This?

 

(defun c:arec ( / an ar p1 x )
 (if
   (and
     (setq p1 (getpoint "\nSpecify first corner point: "))
     (progn (initget 6)
       (setq ar (getreal "\nSpecify Area for Rectangle: "))
     )
     (progn (initget "Length Width")
       (setq an (getkword "\nCalculate rectangle dimensions based on [Length/Width] <Length>: "))
       (if (eq "Width" an)
         (setq x (getdist "\nSpecify rectangle width: " p1))
         (setq x (getdist "\nSpecify rectangle length: "p1))
       )
     )
   )
   (command "_.rectang" "_non" p1 "_non"
     (polar
       (polar p1 (if (eq "Width" an) 0. (/ pi 2.)) (* x 12.))
       (if (eq "Width" an) (/ pi 2.) 0.)
       (* 12. (/ ar x))
     )
   )
 )
 (princ)
)

Edit: went the wrong way with the conversion.. :oops:

Link to comment
Share on other sites

Yes sir, I sure did. Your previous code worked fine, but I got the "malformed list "error with this one.

 

JPC

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...