Author Topic: Entmake Functions  (Read 14569 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Entmake Functions
« on: February 12, 2010, 01:22:20 PM »
I got a bit of inspiration from this, and I thought I'd write a bunch of functions that use the minimum requirements to generate an entity, mainly for those who want to quickly produce an entity, without having to look up which codes are needed, and which aren't.

Of course, the list is a working progress, but this is what I have so far:

Code: [Select]
(defun 3DFace (p1 p2 p3 p4)
  (entmakex (list (cons 0 "3DFACE")
                  (cons 10 p1)
                  (cons 11 p2)
                  (cons 12 p3)
                  (cons 13 p4))))


(defun Arc (cen rad sAng eAng)
  (entmakex (list (cons 0 "ARC")
                  (cons 10  cen)
                  (cons 40  rad)
                  (cons 50 sAng)
                  (cons 51 eAng))))


(defun AttDef (tag prmpt def pt hgt flag)
  (entmakex (list (cons 0 "ATTDEF")
                  (cons 10   pt)
                  (cons 40  hgt)
                  (cons 1   def)
                  (cons 3 prmpt)
                  (cons 2   tag)
                  (cons 70 flag))))


(defun Circle (cen rad)
  (entmakex (list (cons 0 "CIRCLE")
                  (cons 10 cen)
                  (cons 40 rad))))


(defun Ellipse (cen maj ratio)
  (entmakex (list (cons 0 "ELLIPSE")
                  (cons 100 "AcDbEntity")
                  (cons 100 "AcDbEllipse")
                  (cons 10 cen)
                  (cons 11 maj)
                  (cons 40 ratio)
                  (cons 41 0)
                  (cons 42 (* 2 pi)))))


(defun Insert (pt Nme)
  (entmakex (list (cons 0 "INSERT")
                  (cons 2 Nme)
                  (cons 10 pt))))


(defun Line (p1 p2)
  (entmakex (list (cons 0 "LINE")
                  (cons 10 p1)
                  (cons 11 p2))))


(defun LWPoly (lst cls)
  (entmakex (append (list (cons 0 "LWPOLYLINE")
                          (cons 100 "AcDbEntity")
                          (cons 100 "AcDbPolyline")
                          (cons 90 (length lst))
                          (cons 70 cls))
                    (mapcar (function (lambda (p) (cons 10 p))) lst))))


(defun M-Text (pt str)
  (entmakex (list (cons 0 "MTEXT")         
                  (cons 100 "AcDbEntity")
                  (cons 100 "AcDbMText")
                  (cons 10 pt)
                  (cons 1 str))))


(defun Point (pt)
  (entmakex (list (cons 0 "POINT")
                  (cons 10 pt))))


(defun Polyline (lst)
  (entmakex (list (cons 0 "POLYLINE")
                  (cons 10 '(0 0 0))))
  (mapcar
    (function (lambda (p)
                (entmake (list (cons 0 "VERTEX") (cons 10 p))))) lst)
  (entmakex (list (cons 0 "SEQEND"))))


(defun Solid (p1 p2 p3 p4)
  (entmakex (list (cons 0 "SOLID")
                  (cons 10 p1)
                  (cons 11 p2)
                  (cons 12 p3)
                  (cons 13 p4))))               


(defun Text (pt hgt str)
  (entmakex (list (cons 0 "TEXT")
                  (cons 10  pt)
                  (cons 40 hgt)
                  (cons 1  str))))
 

(defun Trce (p1 p2 p3 p4)
  (entmakex (list (cons 0 "TRACE")
                  (cons 10 p1)
                  (cons 11 p2)
                  (cons 12 p3)
                  (cons 13 p4))))

(defun xLine (pt vec)
  (entmakex (list (cons 0 "XLINE")
                  (cons 100 "AcDbEntity")
                  (cons 100 "AcDbXline")
                  (cons 10 pt)
                  (cons 11 vec))))


(defun Layer (Nme)
  (entmake (list (cons 0 "LAYER")
                 (cons 100 "AcDbSymbolTableRecord")
                 (cons 100 "AcDbLayerTableRecord")
                 (cons 2 Nme)
                 (cons 70 0))))


(defun Layer (Nme Col Ltyp LWgt Plt)
  (entmake (list (cons 0 "LAYER")
                 (cons 100 "AcDbSymbolTableRecord")
                 (cons 100 "AcDbLayerTableRecord")
                 (cons 2  Nme)
                 (cons 70 0)
                 (cons 62 Col)
                 (cons 6 Ltyp)
                 (cons 290 Plt)
                 (cons 370 LWgt))))
« Last Edit: February 13, 2010, 01:16:07 PM by Lee Mac »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Entmake Functions
« Reply #1 on: February 12, 2010, 01:26:38 PM »
Maybe this will help you also.
[ http://www.theswamp.org/index.php?topic=17445.0 ]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Entmake Functions
« Reply #2 on: February 12, 2010, 01:29:05 PM »
Maybe this will help you also.
[ http://www.theswamp.org/index.php?topic=17445.0 ]

Wow - I see great minds think alike Tim  :wink:

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Entmake Functions
« Reply #3 on: February 12, 2010, 01:33:37 PM »
Maybe this will help you also.
[ http://www.theswamp.org/index.php?topic=17445.0 ]

Wow - I see great minds think alike Tim  :wink:

Yea.  I think entmake is faster on some items, and sometimes you just need to use entmake, so I wanted to know what was the minimum dxf codes.  Forget if it states it in that thread, but you have to watch out for the order of the dxf codes in later versions.  When I moved to '09 I had to change some of my codes that used entmake to comply with the order listed with entget.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Entmake Functions
« Reply #4 on: February 12, 2010, 01:36:48 PM »
Maybe this will help you also.
[ http://www.theswamp.org/index.php?topic=17445.0 ]

Wow - I see great minds think alike Tim  :wink:

Yea.  I think entmake is faster on some items, and sometimes you just need to use entmake, so I wanted to know what was the minimum dxf codes.  Forget if it states it in that thread, but you have to watch out for the order of the dxf codes in later versions.  When I moved to '09 I had to change some of my codes that used entmake to comply with the order listed with entget.

Yeah, I've noticed that with a few objects - can't remember exactly which - but I remember having to nose around with entget to get it right.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake Functions
« Reply #5 on: February 12, 2010, 02:25:16 PM »
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.

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: Entmake Functions
« Reply #6 on: February 12, 2010, 02:28:25 PM »
kinda more flexible :)
Code: [Select]
(defun Circle (cen rad ext)
  (entmakex (append (list (cons 0 "CIRCLE") (cons 10 cen) (cons 40 rad)) ext))
)
;;;(Circle '(0 0) 10 nil)
;;;(Circle '(0 0) 10 '((62 . 5) (8 . "TEST")))

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Entmake Functions
« Reply #7 on: February 12, 2010, 02:30:13 PM »
kinda more flexible :)
Code: [Select]
(defun Circle (cen rad ext)
  (entmakex (append (list (cons 0 "CIRCLE") (cons 10 cen) (cons 40 rad)) ext))
)
;;;(Circle '(0 0) 10 nil)
;;;(Circle '(0 0) 10 '((62 . 5) (8 . "TEST")))

Nice idea VovKa!  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake Functions
« Reply #8 on: February 12, 2010, 02:31:44 PM »
Here is a file I have been adding to over the years. The original parts was not my work.
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.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Entmake Functions
« Reply #9 on: February 12, 2010, 02:50:52 PM »
Nice CAB,

I recognise a bit of that from David Bethel  :wink: A great reference - certainly much easier than the reference that ACAD provides.

rhino

  • Guest
Re: Entmake Functions
« Reply #10 on: February 19, 2010, 10:58:41 AM »
Re: the entity name.

I'm using the functions as sub functions in the main routine - how do i get the entity name once its created for reference/modifications later?

would I need to set a variable calling entlast after running each function?
« Last Edit: February 19, 2010, 11:04:40 AM by rhino »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake Functions
« Reply #11 on: February 19, 2010, 11:30:00 AM »
The entmakex returns the entity name so
Code: [Select]
(setq ent (entmakex (append (list (cons 0 "CIRCLE") (cons 10 cen) (cons 40 rad)) ext)))
gets the entity name.

And
Code: [Select]
(defun Circle (cen rad ext)
  (entmakex (append (list (cons 0 "CIRCLE") (cons 10 cen) (cons 40 rad)) ext))
)


 (setq ent (Circle '(0 0) 10 '((62 . 5) (8 . "TEST"))))

gets the entity name.
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.

rhino

  • Guest
Re: Entmake Functions
« Reply #12 on: February 19, 2010, 11:33:55 AM »
got it  :ugly: thanks!