Layers Lisp Needed

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

  1. jojo

    jojo Guest

    I need a routine that will go through my entire drawing, and create a separate layer for each object in the drawing based on the layer each item is currenty on.

    So if I have layers called : WALLS, GLASS, ROOF

    and each layer has 3 item on it,

    the new layers would be

    WALLS1, WALLS2, WALLS3
    GLASS1, GLASS2, GLASS3
    ROOF1,ROOF2,ROOF3

    can anyone help me with this? I am pretty good at lisp, but cannot deal with selection sets and those (0.Layer) things to save my life...and I can't figure how to do this with normal commands and such...

    thanks!
    JoJo
     
    jojo, May 9, 2004
    #1
  2. jojo

    jojo Guest

    Also if padding could be built into the layer names that would help a lot too...

    so if there are 120 items on layer WALL,
    the first would be WALL001...

    thanks!
     
    jojo, May 9, 2004
    #2
  3. jojo

    Jamie Duncan Guest

    I think this NG is for people who are trying to customize acad and need a
    little help with lisp or whatever. It's not an 'on-demand' someone will do
    your work for you and build you an application to your specifications. If
    you want such a service there are many who will do it for a small fee...


    Jamie Duncan
     
    Jamie Duncan, May 9, 2004
    #3
  4. jojo

    TCEBob Guest

    I have to say, that's a lotta layers! By "each object in the drawing," I
    assume you mean each physical object and not each line, text, dimension,
    hatch, etc. Are these things, say the Roof over room C-13, identifiable
    as a unit, either as a block or a group? Best if it were a group, then
    we could identify the relevant groups and change the layers of the
    constituent objects. This is not a trivial programming exercise.

    rs

    separate layer for each object in the drawing based on the layer each
    item is currenty on.
    deal with selection sets and those (0.Layer) things to save my
    life...and I can't figure how to do this with normal commands and
    such...
     
    TCEBob, May 9, 2004
    #4
  5. jojo

    bob.at Guest

    Jojo,

    the best would be, if you learn to deal with selection sets etc. Its not so difficult if you know the principles of lisp. Try the follwonig:
    - select the whole drawing using (ssget "_X")
    - step through the selection set with (ssname ss n), using n as counter in a while loop
    - get the entity list of one element using (entget e)
    - change the layer group (group code 8) to the new one, using cons, assoc and subst. I think you also must build a list with the original layernames and the counter for the actual index: ((wall 1) (anysecondlayer 7) (anyotherlayer 4)) etc.
    - update the element in the database using entmod

    bob.at
     
    bob.at, May 10, 2004
    #5
  6. jojo

    ECCAD Guest

    Maximum Layer(s) is 256 .. You will run into trouble
    for drawings with more items than 255.

    Bob
     
    ECCAD, May 10, 2004
    #6
  7. I believe the limit is actually somewhere around
    65,000 (plus or minus a few) layers. I recall
    some discussion about this, but can't seem to
    locate the thread I was thinking of.
     
    Jason Piercey, May 10, 2004
    #7
  8. PS: Not sure where the bottleneck was/is with
    the number of layers, wondering if the new 2005
    layer box makes things any different?
     
    Jason Piercey, May 10, 2004
    #8
  9. jojo

    Paul Turvill Guest

    Sorry, but I must ask: WHY?
    ___

    separate layer for each object in the drawing based on the layer each item
    is currenty on.
     
    Paul Turvill, May 10, 2004
    #9
  10. jojo

    ECCAD Guest

    Oh,
    I didn't realize the max was 64k, when did that happen ?
    Bob
     
    ECCAD, May 10, 2004
    #10
  11. I don't know when it changed (or what it chanded
    from, for that matter). I still can't seem to find the
    exact thread I was thinking of. Perhaps you might
    have been thinking of the maximum number of tabs
    that can be displayed?
     
    Jason Piercey, May 10, 2004
    #11
  12. Actually, with the last couple releases I think it's
    a lot higher than 65k (I vaguely recall doing a test
    a couple years ago and stopping it after a couple
    hundred thousand layers were created).

    However (with my horse blinders on) I cannot, for the
    life of me, figure out what kind of problem is remedied
    by a "solution" like this. Given the scant details
    provided, it remains a mystery. Maybe if a psychic
    were consulted ...

    I don't know when it changed (or what it chanded
    from, for that matter). I still can't seem to find the
    exact thread I was thinking of. Perhaps you might
    have been thinking of the maximum number of tabs
    that can be displayed?
     
    michael puckett, May 10, 2004
    #12
  13. I believe I am thinking about the same test.
    I know there was a thread here that discussed
    it just don't remember the exact details.

    I am slightly lost as well with regards to what
    the problem is and how this will make things
    better.
     
    Jason Piercey, May 10, 2004
    #13
  14. jojo

    TCEBob Guest

    Look in 2004, April 3 "layer list," wherein I posted the following test:

    I tested it out to 5000. Worked. Here's the lisp:

    (defun c:layrs() ; maximum?
    (setq maxi(getint "\nMaximum: "))
    (setq counter 0)
    (while (< counter maxi)
    (setq counter (1+ counter))
    (Command "layer" "n" (strcat "XX" (itoa counter)) "")
    )
    (princ (strcat (itoa counter) " created."))
    (princ))

    when you are done be sure to purge before doing it again or there will
    be an infinite loop of error comments. Use the command line thus:

    -PURGE LA XX*

    RS
     
    TCEBob, May 10, 2004
    #14
  15. jojo

    TCEBob Guest

    We can only await more info from jojo. But I can't believe he wants a
    separate layer for every single object. He must be thinking of
    meta-objects, like walls. My current drawing has 13,335 objects. Anyhow,
    a layer called "walls3" or "glass2469" doesn't seem real helpful to me.

    Would all those layers slow down the regens?

    rs
     
    TCEBob, May 10, 2004
    #15
  16. jojo

    jojo Guest

    Thanks for the suggestions everyone. And thanks for the script, I will test it out today!
     
    jojo, May 10, 2004
    #16
  17. jojo

    jojo Guest

    when I am stepping through, I got the new layer created, but I cannot seem to figure out how to assign the nth object to the new layer i just created???

    right now I am using
    (command "change" tempselect "p" "la" templayer "")
    but that gives me an error cuz i assigned tempselect to be the ssname of the nth object
     
    jojo, May 10, 2004
    #17
  18. jojo

    jojo Guest

    it gets complicated too, cuz I want the numbers to be sequential by layer so I will need to somehow create a selection set for each layer...I know this is possible, but its really confusing to me...
     
    jojo, May 10, 2004
    #18
  19. jojo

    CAB2k Guest

    Sounds like what you wan to do is this:

    Make a list of all existing layers
    Step through each existing layer
    Do an ssget (ssget "X" '((8 . layername))))
    Set counter based on sslength & padd out like 001
    ..Step through the objects in the selection set
    ...Create a new layer based on counter layername001
    ...change object to that new layer
    ..next object in sel set
    next layer in list
    done.
     
    CAB2k, May 10, 2004
    #19
  20. jojo

    jojo Guest

    basically, but what i need is

    ssget() user selects
    then it takes that ss and divides it up into a selection set for each layer
    then it goes through each ss, creates the layer, assigns the layer
    goes to next ss
    does the same thing...
     
    jojo, May 10, 2004
    #20
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.