Author Topic: Entmake  (Read 1707 times)

0 Members and 1 Guest are viewing this topic.

Jeremy

  • Guest
Entmake
« on: June 05, 2011, 06:44:38 PM »
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

Code: [Select]
; 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:

Code: [Select]
; 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)))

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake
« Reply #1 on: June 05, 2011, 06:55:14 PM »
Thanks for participating Jeremy and Welcome to The Swamp.
Keep up the good work. 8-)


You may find related post here as well
----------  Entmake   ----------------------
http://www.theswamp.org/index.php?topic=31145.0  ENTMAKE function by CAB
http://www.theswamp.org/index.php?topic=4814.msg112107#msg112107 
http://www.theswamp.org/index.php?topic=17445.0  Min codes

More links are found here:
This list...   http://www.theswamp.org/index.php?topic=24700.msg359343#msg359343
and here     http://www.theswamp.org/index.php?topic=24700.msg375229#msg375229


I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.