Layers Lisp Needed

Discussion in 'AutoCAD' started by jojo, May 9, 2004.

  1. jojo

    Jamie Duncan Guest

    ssget() user selects
    I really don't know why anyone would do such a thing. but I offer the
    following advise.

    Create an association as each layer is first addressed. so for the first
    entity if (assoc layername the_list) yields nil, then this is a new layer
    and:

    set counter to 1 and

    (append (list (cons layername counter)) the_list)

    (set newlayer to (setanumber layername counter 3))
    make said layer (command ".layer" "m" (setanumber layername counter 3) "c"
    whatevercoloryouwant "")
    move entity to that layer.

    if (assoc layername the_list)) then
    (setq counter (+ 1 (cdr (assoc layername the_list)))
    the_list (subst (cons layername counter)(assoc layername the_list)
    the_list);;;yada yada (typical subst thingy for association lists)

    (set newlayer to (setanumber layername counter 3));; 3 for 001 to 999, 4 for
    four digits etc
    ..I would set numdigits to be relevant to the nymber of layers, ie 10^5
    entites, set numdigits to at least 5 for example.

    (set newlayer to (setanumber layername counter 3))
    make said layer (command ".layer" "m" (setanumber layername counter 3) "c"
    whatevercoloryouwant "")
    move entity to that layer.


    now for this is one I use for all kinds of numbering schemes:

    (defun setanumber ( theprefix thenumber numdigits /)
    (if (< (strlen (itoa thenumber)) numdigits)
    (strcat theprefix (substr "00000000" 1 (- numdigits (strlen (itoa
    thenumber))))(itoa thenumber))
    (strcat theprefix (itoa thenumber))
    )
    )

    or in the code above use:

    (command ".layer" "m" (setanumber layername counter 3) "c"
    whatevercoloryouwant "")

    you don't need subsets or anything like that just grab the entities and go
    to town.


    Jamie Duncan
     
    Jamie Duncan, May 11, 2004
    #21
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.