Our Friends: Leaflet Printing , Presented by: Talia Cad Software

Sign In

Subscribe

Subscribe to Daily Autocad.


Apr 13
Monday
AutoLISP, Programming
AutoLISP.10: Using entmake function to add entities to drawing

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
Fig.1

Drawing CIRCLE by using entmake

Fig.2
Fig.2

Creating MTEXT by using entmake

fig.3
Fig.3

Creating a LWPOLYLINE by using entmake

Fig.4
Fig.4

Adding a new LAYER into the LAYER table by using entmake

Fig.5
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,

Viewed 10,975 times so far... This week: 87 Today: 4 Latest: 5 July 2009, 1:14

Post Tags:

14 Responses to “ AutoLISP.10: Using entmake function to add entities to drawing ”
  1. Thank You

  2. 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.

  3. Kalle Salonen

    Jan 1, 2008
    Reply

    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

  4. Thanks for your attention.

    Bye

  5. Clint Hill

    Feb 19, 2008
    Reply

    On making layers: How would the code (chiefly parenthesis) appear when making more than one layer?

    Thanks,

    Clint

  6. I never tried making multiple layers. I’ll try and answer asap.

  7. Troy Jones

    Feb 20, 2008
    Reply

    (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?

  8. 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

  9. Who i can make a 3d polyline using entmake.I understand i must change the coordinate systme from OCS to WCS.PLESE HELP ME

  10. Jeff Collins

    Jun 3, 2008
    Reply

    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?

  11. How do I set the lineweight to Default using the entmake for layer in Lisp???

    Thanks.
    B

  12. Now, I’d like to add some arcs to polyline using the same technique.
    Please advise.

  13. Timothy Corey

    Nov 6, 2008
    Reply

    I was having trouble plugging variables I retrieved from other objects to create my new objects. Then I saw your post and making the dxfcode list first was the trick. Thanks thanks thanks!

    Tim Corey
    Redding, CA

  14. You’re very wellcome..

    Reagards


Post a Comment



All content and source © 2008 Daily Autocad | News Plus wordpress theme brought to you by Zidalgo.