TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: KOWBOI on September 01, 2010, 01:37:45 PM

Title: Rectangle - enter inches - draw in MM
Post by: KOWBOI 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))
Title: Re: Rectangle - enter inches - draw in MM
Post by: JC 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)

)
Title: Re: Rectangle - enter inches - draw in MM
Post by: Lee Mac 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

)
Title: Re: Rectangle - enter inches - draw in MM
Post by: JC 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
Title: Re: Rectangle - enter inches - draw in MM
Post by: KOWBOI on September 01, 2010, 02:59:37 PM
Big forhead slap!!! Thanks Lee I was thinking getdist and typing getreal duh ...  :ugly: