Author Topic: Rectangle - enter inches - draw in MM  (Read 1661 times)

0 Members and 1 Guest are viewing this topic.

KOWBOI

  • Guest
Rectangle - enter inches - draw in MM
« on: September 01, 2010, 01:37:45 PM »
I'm trying to write an very simple function to let me draw a rectangle in MM's by entering Inches. The rectangle command keeps asking for a 2D point for rotation and errors out. I know I'm missing something very basic and could use a little help. I feel a forehead slap coming on, thanks in advance. Oh yeah, this is what I have so far:

Code: [Select]
(defun C:REMM (/ ROT SPOINT RLENGTH RWIDTH )

(setq ROT "0")

(setq SPOINT (getpoint "\Pick rectangle start point."))(princ)

(setq RLENGTH (getreal"\Length in INCHES to be drawn in MM - "))(princ)

(setq RWIDTH (getreal"\Width in INCHES to be drawn in MM - "))(princ)

(command "rectangle" SPOINT "D" RLENGTH RWIDTH ROT))

JC

  • Guest
Re: Rectangle - enter inches - draw in MM
« Reply #1 on: September 01, 2010, 02:11:12 PM »
Here, try this:

Code: [Select]
(defun C:REMM (/ SP LEN WID AT)

(setq SP (getpoint "\Pick rectangle start point."))(princ)

(setq LEN (getreal"\Length in INCHES to be drawn in MM - "))(princ)

(setq WID (getreal"\Width in INCHES to be drawn in MM - "))(princ)

(setq AT (strcat "@"(rtos LEN) "," (rtos WID)))

(command "rectangle" SP AT)

)
« Last Edit: September 01, 2010, 02:43:18 PM by JC »

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Rectangle - enter inches - draw in MM
« Reply #2 on: September 01, 2010, 02:17:21 PM »
Perhaps this will help you undestand:

Code: [Select]
(defun c:remm ( / p1 rl rw )

  (if (and  ;; If ALL the following conditions are met...

        (setq p1 (getpoint "\nPick Corner Point: "))
        (setq rl (getdist  "\nLength in Inches:  " p1))
        (setq rw (getdist  "\nWidth in Inches:   " p1))
       
      ) ; End AND

    ;; All conditions met, party time...

    (command "_.rectangle" p1 "D" (* 25.4 rl) (* 25.4 rw) pause)

  ) ; End IF

  (princ) ; Exit Quietly

)

JC

  • Guest
Re: Rectangle - enter inches - draw in MM
« Reply #3 on: September 01, 2010, 02:35:35 PM »
There are so many different roads we can take that all get us to the same place.
Pretty cool HUH!? :-D

KOWBOI

  • Guest
Re: Rectangle - enter inches - draw in MM
« Reply #4 on: September 01, 2010, 02:59:37 PM »
Big forhead slap!!! Thanks Lee I was thinking getdist and typing getreal duh ...  :ugly: