Hi Gang, I'm new to the board. I can see there is a lot of neat stuff going on here. I thought I would post something useful that I haven't seen on here yet. I have always found the ENTMAKE function to be a bit on the cluttery side. I therefore wrote this handy bit of code
; simplified entmake
(defun emake (typ lst)
(entmake (cons
(cons 0 typ)
(mapcar '(lambda (x)(cons (car x)(cadr x)))
(pairs lst))
))
(princ))
; Break a list into pairs of elements
(defun pairs (lst / nlst cnt cnt2)
(setq cnt 0 cnt2 1)
(repeat (/ (length lst) 2)
(setq nlst (cons (list (nth cnt lst)(nth cnt2 lst)) nlst)
cnt (+ 2 cnt)
cnt2 (+ 2 cnt2)
)
)
(reverse nlst)
)
Using EMAKE we can now write some very simple functions for drawing entitities:
; draw a point
(defun draw-pt (p)
(emake "POINT" (list 10 p)))
; draw a line
(defun draw-line (sp ep)
(emake "LINE" (list 10 sp 11 ep)))
; draw a circle
(defun draw-circle (cp r)
(emake "CIRCLE" (list 10 cp 40 r)))