Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Draw boxes and lines

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
194 Views, 2 Replies

Draw boxes and lines

Ok, here's what I'm trying to do, it's fairly simple.. but I keep getting unexpected outputs!!

I want to draw a box outline based with the top left corner specified by the user.

Then the user enters a number of rows to draw in the box. Each row is 0.15625" high (5/32") and there is a 3/4" header at the top.

I attached a picture to clarify.

Here's what I have so far..

The outline box draws fine, but then when it goes to draw the line at where the header ends, it seems to want to always draw it at the midpoint of the box!!



CODE:
(defun FUN-ERROR (ER)
(if (/= ER "Function cancelled")
(princ (strcat "\nError: " ER))
)

;;;--- Turn the command echo off
(setvar "cmdecho" 0)

;;;--- Save the current OSnaps
(setq oldSnap (getvar "osmode"))

;;;--- Turn OSnaps off
(setvar "osmode" 0)

;;;--- Get the drawing scale factor
(setq scl(getvar "dimscale"))
)
;end fun-error


(setq pt1 (getpoint "\nEnter the start point for the panel: "))

(setq rows (getint "\nEnter the number of rows: "))

;;Borders
(setq HeaderHeight 0.75)
(setq FooterHeight 0.5)

(setq RowHeight (* rows 0.15625))
(setq TotalHeight (+ RowHeight 1.25))
(setq TotalWidth 10)

(setq topL pt1)
(setq topR (polar topL 0 TotalWidth))
(setq botL (polar topL (* pi 1.5) TotalHeight))
(setq botR (polar topR (* pi 1.5) TotalHeight))

(setq headL (polar topL (* pi 1.5) 1))
(setq headR (polar topR (* pi 1.5) 1))


(command "line" topL topR botR botL topL "") ;Outline of panel
(command "line" (polar topL (* pi 1.5) 0.75) (polar topR (* pi 1.5) 0.75) "")


(setq index 1)


(while (<= index rows)

(setq distance (* index 0.2))
(command "line"
(polar topL (* pi 1.5) (+ 0.15625 index)) ;Header/Footer
(polar topR (* pi 1.5) (+ 0.15625 index))
""
)
(setq index (1+ index))

)

;;;variables original setting


(princ "\n Lines completed! ")

;;;--- Reset OSnaps
(setvar "osmode" oldSnap)

(princ)
)
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

(defun c:outline ()
(setq pt1 (getpoint "\nEnter the start point for the panel: "))
(setq rows (getint "\nEnter the number of rows: "))
;;Borders
(setq HeaderHeight 0.75)
(setq FooterHeight 0.5)
(setq RowHeight (* rows 0.15625))
(setq TotalHeight (+ RowHeight 1.25))
(setq TotalWidth 10)
(setq topL pt1)
(setq topR (polar topL 0 TotalWidth))
(setq botL (polar topL (* pi 1.5) TotalHeight))
(setq botR (polar topR (* pi 1.5) TotalHeight))
(setq headL (polar topL (* pi 1.5) 1))
(setq headR (polar topR (* pi 1.5) 1))
(command "line" topL topR botR botL topL "") ;Outline of panel
(command "line" (polar topL (* pi 1.5) 0.75) (polar topR (* pi 1.5) 0.75)
"")
(setq index 1)
(while (<= index rows)
(setq distance (* index 0.2))
(command "line"
(polar topL (* pi 1.5) (+ 0.75 (* 0.15625 index))) ;Header/Footer
(polar topR (* pi 1.5) (+ 0.75 (* 0.15625 index)))
""
)
(setq index (1+ index))
)
;;;variables original setting
(princ (strcat "\n" (itoa (1- index)) " Lines completed ! "))
;;;--- Reset OSnaps
;(setvar "osmode" oldSnap)
(princ)
)

wrote in message news:5149109@discussion.autodesk.com...
Ok, here's what I'm trying to do, it's fairly simple.. but I keep getting
unexpected outputs!!

I want to draw a box outline based with the top left corner specified by the
user.

Then the user enters a number of rows to draw in the box. Each row is
0.15625" high (5/32") and there is a 3/4" header at the top.

I attached a picture to clarify.

Here's what I have so far..

The outline box draws fine, but then when it goes to draw the line at where
the header ends, it seems to want to
always draw it at the midpoint of the box!!



CODE:
(defun FUN-ERROR (ER)
(if (/= ER "Function cancelled")
(princ (strcat "\nError: " ER))
)

;;;--- Turn the command echo off
(setvar "cmdecho" 0)

;;;--- Save the current OSnaps
(setq oldSnap (getvar "osmode"))

;;;--- Turn OSnaps off
(setvar "osmode" 0)

;;;--- Get the drawing scale factor
(setq scl(getvar "dimscale"))
)
;end fun-error


(setq pt1 (getpoint "\nEnter the start point for the panel: ")
)

(setq rows (getint "\nEnter the number of rows: "))

;;Borders
(setq HeaderHeight 0.75)
(setq FooterHeight 0.5)

(setq RowHeight (* rows 0.15625))
(setq TotalHeight (+ RowHeight 1.25))
(setq TotalWidth 10)

(setq topL pt1)
(setq topR (polar topL 0 TotalWidth))
(setq botL (polar topL (* pi 1.5) TotalHeight))
(setq botR (polar topR (* pi 1.5) TotalHeight))

(setq headL (polar topL (* pi 1.5) 1))
(setq headR (polar topR (* pi 1.5)
1))


(command "line" topL topR botR botL topL "") ;Outline of panel
(command "line" (polar topL (* pi 1.5) 0.75) (polar topR (* pi 1.5) 0.75)
"")


(setq index 1)


(while (<= index rows)

(setq distance (* index 0.2))
(command "line"
(polar topL (* pi 1.5) (+ 0.15625 index)) ;Header/Footer
(polar topR (* pi 1.5) (+ 0.15625 index))
""
)
(setq index (1+ index))

)

;;;variables original setting


(princ "\n Lines completed
! ")

;;;--- Reset OSnaps
(setvar "osmode" oldSnap)

(princ)
)
Message 3 of 3
Anonymous
in reply to: Anonymous

Thanks, I am new to this and without ANY training.

Much appreciated.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report