AutoLISP.10: Using entmake function to add entities to drawing
Print This Post
![]() |
Author | Orhan Toker |
| Profession | Architect M.Sc. | |
| Autodesk Authorized Consultant | ||
| Database Specialist | ||
All AutoLISP versions
Hello dailyautocad readers,
In the past, we used to use command function in order to draw entities in AutoCAD. For example, to draw a circle, we use the following command:
(command "_.circle" "15,7" "1")
However, this command line makes AutoCAD slower and also we cannot draw the circle in another layer. For this reason, in professional AutoLISP applications, entmake function is used to add entities to the drawing. I will explain this function by giving some examples.
You have to pass entity list to entmake function as parameters. In previous lesson, Managing Lists in AutoLISP (List Handling), I have explained about entity lists. You will also do management of lists, as you do the example that I will give for entmake function below.
Drawing LINE by using entmake

Fig.1
Drawing CIRCLE by using entmake

Fig.2
Creating MTEXT by using entmake

Fig.3
Creating a LWPOLYLINE by using entmake

Fig.4
Adding a new LAYER into the LAYER table by using entmake

Fig.5
DXF Group Codes
As it can be seen, use of entmake function requires advanced AutoCAD knowledge. Because, it you know about the structure of AutoCAD entities and you are well aware of drawing database, then only you can use entmake function efficiently. If you are going to use entmake function, then the most important thing that you will need to know about is DXF group codes. We have explained this lesson previously in detail.
Drawing Database
AutoCAD drawing database includes information for definition tables of layers, line type, blocks etc. in addition to all of the entities that are kept within the drawing file (DWG) and background. You can examine this database by using only the entget function. I will explain this topic in detail when we come to the professional lessons.
Have a nice day,
Technorati Tags: AutoCAD, AutoLISP, creating entities
Similar Posts
Rate this article:


April 25th, 2007 18:52
Thank You
August 3rd, 2007 11:40
I think the only benefit of using entmake to create entity is the speed, but it makes things difficult and complicated, so we need evaluating which is most important.
January 1st, 2008 17:47
Dear Mr. Orhan Toker
I found out that, “a new LAYER” didn’t work, so I changed alittle the order of the lines; it worked after that. So I send You the new one as bellow :
”
;;*
(setq #MakeLAYER
(list
(cons 0 “LAYER”) ; name of entity
(cons 100 “AcDbLayerTableRecord”); Locate layer table
(cons 2 “TAL”) ; Layer name
(cons 70 0) ; State
(cons 62 5) ; Color - Blue is 5
(cons 6 “Continuous”) ; Linetype
(cons 290 1) ; 1 = plot ; 0 = Don’t plot
(cons 370 0) ; Line weight
) ; End of LIST
) ; End of SETQ
(entmake #MakeLAYER) ; Greate the layer
;;*
”
Br. Kalle Salonen
January 2nd, 2008 14:42
Thanks for your attention.
Bye
February 19th, 2008 17:13
On making layers: How would the code (chiefly parenthesis) appear when making more than one layer?
Thanks,
Clint
February 20th, 2008 09:40
I never tried making multiple layers. I’ll try and answer asap.
February 20th, 2008 22:38
(defun c:storm (/ basethk baseext wallthk walla wallb tvcli1 tvcli2 tvcli3 tvcli4 tvcli5 tvcli6
tvclo1 tvclo2 tvclo3 tvclo4 tvclo5 tvclo6 basel1 basel2 basel3 basel4 basel5)
(progn
(initget (+ 1 4))
(setq basethk (getint “How thick is base? : “))
(initget (+ 1 4))
(setq baseext (getint “What is base ext? : “))
(initget (+ 1 4))
(setq wallthk (getint “How thick are walls? : “))
(initget (+ 1 4))
(setq walla (getint “Approximate length of 1st wall? : “))
(initget (+ 1 4))
(setq wallb (getint “Approximate length of 2nd wall? : “))
(setq tvcli1 (/ 2 walla))
(setq tvcli2 (/ 2 wallb))
(setq tvcli3 walla)
(setq tvcli4 wallb)
(setq tvcli5 walla)
(setq tvcli6 wallb)
(setq tvclo1 (+ wallthk (/ 2 walla)))
(setq tvclo2 (+ wallthk (/ 2 wallb)))
(setq tvclo3 (+ walla (* 2 wallthk)))
(setq tvclo4 (+ wallb (* 2 wallthk)))
(setq tvclo5 (+ walla (* 2 wallthk)))
(setq tvclo6 (+ wallb (* 2 wallthk)))
(setq basel1 (+ (/ 2 wallb) wallthk baseext))
(setq basel2 baseext)
(setq basel3 (+ wallb (* 2 wallthk)(* 2 baseext)))
(setq basel4 baseext)
(setq basel5 (+ wallb (* 2 wallthk)(* 2 baseext)))
(command “-layer” “m” “const” “s” “const” “c” “2″ “const” “”)
(command “_line” “113.0461,312.1419,0″ @ tvcli1 0 “”)
(princ)
)
)
I am trying to figure out a way to draw a line from a given point, to a distance calculated above. I know my problem is in the line command, but I am not sure how to tell autocad line from coor–> dist—–> angle.
any suggestions?
March 21st, 2008 06:12
Hi,
I am looking for some code that would create an arc of a given radius starting from a given point and tangent to a line.
Please help me.
Thanks
Alan
June 1st, 2008 15:34
Who i can make a 3d polyline using entmake.I understand i must change the coordinate systme from OCS to WCS.PLESE HELP ME
June 3rd, 2008 16:54
When I run the (entmake #makelayer) I get a nil.
I was trying to just run the -layer command to make new layers and the nil at the end of that kept getting me stopped so I thought I would try the entity making idea I read above and still crashes out.
I’m using Autocad 2008 is that an issue in this?
June 19th, 2008 19:29
How do I set the lineweight to Default using the entmake for layer in Lisp???
Thanks.
B