add a layer directly to the table..?

Discussion in 'AutoCAD' started by C Witt, Jul 13, 2004.

  1. C Witt

    C Witt Guest

    ok.. you can use..
    (TBLSEARCH "LAYER" "TEXT")
    to see the xdata of a layer.. but how can i add a layer to the table?..
    (without using core cad commands ie:layer)

    I know it must be possible.. but how? (the cad help only details vba,
    and i'm basic/moderate lisp)

    TIA
     
    C Witt, Jul 13, 2004
    #1
  2. C Witt

    BillZ Guest

    (setq mylayer (vla-add (vla-get-layers (vla-get-activeDocument (vlax-get-acad-object))) "layername"))



    Bill
     
    BillZ, Jul 13, 2004
    #2
  3. C Witt

    C Witt Guest

    ok.. few questions..

    1) why setq mylayer?
    2) how do I set the layer properties this way?
     
    C Witt, Jul 13, 2004
    #3
  4. You can add a new object to the layer collection
    with something like this.

    (setq
    object
    (vla-add
    (vla-get-layers
    (vla-get-activedocument
    (vlax-get-acad-object)))
    "MyNewLayer"
    )
    )

    (vlax-put object 'color 6)
    (vlax-put object 'linetype "Hidden")
    (vlax-put object ......)


    Of course, if you are adding multiple layers
    you should assign the layer collection to a
    variable, rather than access each time you
    add a layer.
     
    Jason Piercey, Jul 13, 2004
    #4
  5. C Witt

    C Witt Guest

    "Of course, if you are adding multiple layers
    you should assign the layer collection to a
    variable, rather than access each time you
    add a layer."

    and how would I do that? (I'm thinking that this is the easy part, but I
    can't figure out how..)
     
    C Witt, Jul 13, 2004
    #5
  6. C Witt

    BillZ Guest

    1.) mylayer is the variable that holds the object.

    Hence: #2

    (vla-put-color mylayer "30")
    (vla-put-lineweight mylayer acLnWt018)
    (vla-put-plotstyleName mylayer "Screening 100%.ctb")

    etc.


    Bill
     
    BillZ, Jul 13, 2004
    #6
  7. (setq
    layerCollection
    (vla-get-layers
    (vla-get-activedocument
    (vlax-get-acad-object))) )


    (setq object (vla-add layerCollection) "MyNewLayer")
     
    Jason Piercey, Jul 13, 2004
    #7
  8. Typo alert

    (setq object (vla-add layerCollection "MyNewLayer"))
     
    Jason Piercey, Jul 13, 2004
    #8
  9. C Witt

    C Witt Guest

    thank you, that should work.
     
    C Witt, Jul 13, 2004
    #9
  10. C Witt

    C Witt Guest

    thanks
     
    C Witt, Jul 13, 2004
    #10
  11. C Witt

    Walt Engle Guest

    If you're using lsp, and have acad.lsp, then use something like the following:

    (if (not (tblsearch "layer" "1"))
    (command "layer" "M" "1" "c" "red" "1" "L" "continuous" "1" ""))
     
    Walt Engle, Jul 14, 2004
    #11
  12. C Witt

    C Witt Guest

    that is the way i was doing it. now doing it without using a "cad command".
     
    C Witt, Jul 14, 2004
    #12
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.