Jump to content

lisp for area in square feet again


jcalla

Recommended Posts

I know this is my second time I posted this request, but I really could use some help if possible. Lee Mac almost got me where I needed to be on my last post however I didn't quite make it. I would like a routine that would prompt me for an area in square feet of a rectangle with a know length or width. 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. Can anyone help me?

 

JPC

Link to comment
Share on other sites

It just first principles you need to change Lee's code where he calls the _rectang command how do you draw a rectang answer join 4 points with lines.

 

So you have point1 the pick point just use the polar command to work out pts 2 3 4 then it becomes (command "line" pt1 pt2 pt3 pt4 "C" "") Lee uses polar in his code just put command after working out extra points all done.

Link to comment
Share on other sites

Lee Mac,

The code you sent the first time works but it gives me the area in square inches. The second code you sent gives me an error and I cannot run it. I did not see any link for any other code. What I would like is code that gives me area of a rectanle in square feet. I do appreciate your help and hope you will excuse my ignorance in lisp routines.

 

JPC

Link to comment
Share on other sites

To put a halt to my puzzlement could try this code again, as I cannot get it to fail... the error you report indicates that part of the code is missing (a missing ')' ).

Link to comment
Share on other sites

You mean you need the cvunit function. You draw in inches, but you want to input the are in sqf. So (without looking at LM's code) say it asked for the area through a getreal like so:

(setq area (getreal "Area of rectangle: "))

Then you can convert it to square inches so it works with Lee's code by doing this:

(setq area (cvunit area "sq feet" "sq inch"))

Link to comment
Share on other sites

Lee Mac,

I got the code to work, however when it prompts me for either length or width it will not accept (ie) 45' but I continue with 45 and it does complete the routine with the correct total square footage. The problem is that the dimensions that I need are not accurate. I need to know the remaining dimension after I input either the length or width. It will not accept input with a foot symbol.

 

JPC

Link to comment
Share on other sites

OK, it works when I input 45 in width only, not length. Bottom line is it works! Thanks Lee Mac for sticking with me.

 

JPC

Link to comment
Share on other sites

OK, it works when I input 45 in width only, not length. Bottom line is it works! Thanks Lee Mac for sticking with me.

 

What goes wrong with the length option? Everything works for me - there isn't too much that can go wrong, its quite simple code.

Link to comment
Share on other sites

Ok, I changed my LUNITS setting to see if I could emulate your problems and I believe I know what the problem is.

 

Are you entering your area in Sq.Ft or Sq.In?

 

EDIT: Just re-read your first post, SQFT I see.

Link to comment
Share on other sites

Try 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 [in SQFT]: "))
     )
     (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 144.) x)
     )
   )
 )
 (princ)
)

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...