creating a layer using entmake...

Discussion in 'AutoCAD' started by aaron weissner, May 18, 2004.

  1. (entmake '((0 . "table")(2 . "layer")(5 . "2H")(100 . "acdbsymboltable")(70
    .. 100)(100 . "acdbsymboltablerecord")(2 . "test")(62 . 251)(6 .
    "continuous")))

    I thought it would look something like this but all i get is nil... what am
    i doing wrong...
     
    aaron weissner, May 18, 2004
    #1
  2. Run this (entget (tblobjname "layer" "0")) and
    observe the difference in DXF codes.
     
    Jason Piercey, May 18, 2004
    #2
  3. aaron weissner

    Rudy Tovar Guest

    You're defining a handle assoc 5, which autocad assigns.
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, May 18, 2004
    #3
  4. The handle has nothing to do with it. If a
    handle is supplied it is ignored.
     
    Jason Piercey, May 18, 2004
    #4
  5. If you are using AutoCAD 2000 or newer I recommend you use
    an activex method over entmake, as I learned the hard way
    many years ago that layers created via entmake can be flaky
    and can terminally crash your session of AutoCAD.

    If you absolutely must use entmake, entmake a bogus entity
    that references the layer you wish to make and then delete
    the temporary entity.

    e.g.

    Code:
    ....
    (if
    (entmake
    '(
    (0 . "POINT")       ;; believe it or not this
    (8 . "MyNewLayer")  ;; is sufficient dxf data
    (10 0.0 0.0 0.0)    ;; for this entmake call
    )
    )
    (entdel (entlast))
    )
    ....
    
    Of course, if the entmake call fails your code should veer
    accordingly (has never failed for me). Admittedly this is
    very kludgy and yet another reason you should go activex,
    but like I said, if you must use entmake this would be less
    likely to produce an unrecoverable error that is difficult
    to trace; imo.

    FWIW.

    (entmake '((0 . "table")(2 . "layer")(5 . "2H")(100 . "acdbsymboltable")(70
    .. 100)(100 . "acdbsymboltablerecord")(2 . "test")(62 . 251)(6 .
    "continuous")))

    I thought it would look something like this but all i get is nil... what am
    i doing wrong...
     
    michael puckett, May 18, 2004
    #5
  6. aaron weissner

    j.buzbee Guest

    Not what your asking - sorry, I gave up on entmake a while ago - but:
    ;;;whatch for word wrap
    (setq ThisDrawing(vlax-get(vlax-get-acad-object)'ActiveDocument)); gets a
    pointer to the active document

    (setq LayerObj(vla-add(vlax-get ThisDrawing 'Layers) "test")))

    the variable "LayerObj" is a pointer to the new layer created; "test". Now
    add properties like this:
    (vlax-put LayerObj 'color 1)
    (vlax-put LayerObj 'linetype "continuous"); make sure linetype is loaded
    first
    (vlax-put LayerObj 'plotstyle "Black"); make sure plotstyle exists in active
    plotstyle table.
    etc.

    Hope this helps . . .
    jb
     
    j.buzbee, May 19, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.