a little help..?

Discussion in 'AutoCAD' started by C Witt, Jun 1, 2004.

  1. C Witt

    C Witt Guest

    this is the lisp i want to use..

    (while (/= nlayn "text")
    (foreach newlayername'("pl"
    "contours"
    "el"
    "ant"
    "steel"
    "eq"
    "ha"
    "grid"
    "tray"
    "gnd"
    "power"
    "bolts"
    "fence"
    "vp"
    "text"
    )
    (setq nlayn newlayername)
    (foreach newlayercolor'("red"
    "9"
    "red"
    "magenta"
    "cyan"
    "123"
    "9"
    "9"
    "blue"
    "72"
    "140"
    "yellow"
    "cyan"
    "vp"
    "yellow"
    )
    (setq nlayc newlayercolor)
    (foreach newlayertype'("Continuous"
    "hidden"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    )
    (setq nlayt newlayertype)
    (command "layer" "make" nlayn "color" nlayc "lt" nlayt "")
    )
    )
    )
    )


    but the layer command won't allow it.. my only other option that i can
    see (and don't like).. is

    (command "layer" "make" "pl" "color" "red" "" "make" "contours"........)

    that approach gets way to long..


    TIA.

    (btw, if i can do this via entmake or the like then great)
     
    C Witt, Jun 1, 2004
    #1
  2. C Witt

    ECCAD Guest

    I am not sure, you could try:

    (command "layer" "_m" (eval nlayn) "_c" (eval nlayc) "_lt" (eval nlayt) "")

    Bob
     
    ECCAD, Jun 1, 2004
    #2
  3. C Witt

    C Witt Guest

    Invalid option keyword.
    error: Function cancelled

    same as before..
     
    C Witt, Jun 1, 2004
    #3
  4. C Witt

    Jeff Mishler Guest

    Here's an approach that uses mapcar (which essentially foreach's any number
    of lists...) that does this. And yours probably didn't work due to 1: the
    color "vp" is invalid, and 2. after entering the color and linetype for the
    layers an additional call to the layer name is needed.....

    Jeff

    (setq newlayername
    '("pl" "contours" "el" "ant" "steel"
    "eq" "ha" "grid" "tray" "gnd" "power"
    "bolts" "fence" "vp" "text"
    )
    )
    (setq newlayercolor
    '("red" "9" "red" "magenta" "cyan"
    "123" "9" "9" "blue" "72" "140"
    "yellow" "cyan" "white" "yellow"
    )
    )
    (setq newlayertype
    '("Continuous" "hidden" "Continuous"
    "Continuous" "Continuous" "Continuous"
    "Continuous" "Continuous" "Continuous"
    "Continuous" "Continuous" "Continuous"
    "Continuous" "Continuous" "Continuous"
    )
    )
    (mapcar '(lambda (nlayn nlayc nlayt)
    (command "layer" "make" nlayn "color" nlayc nlayn "lt" nlayt nlayn "")
    )
    newlayername
    newlayercolor
    newlayertype
    )
     
    Jeff Mishler, Jun 1, 2004
    #4
  5. C Witt

    ECCAD Guest

    This gets a little closer:

    (command "layer" "_m" nlayn "")
    (command "layer" "_c" nlayc nlayn "")
    (command "layer" "_lt" nlayt nlayn "")

    Bob
     
    ECCAD, Jun 1, 2004
    #5
  6. C Witt

    ECCAD Guest

    'vp' is not a valid color either.
    Bob
     
    ECCAD, Jun 1, 2004
    #6
  7. FWIW,

    Why not use the power of LISP? Make those lists better formed, so that they
    are easier to maintain. Imagine trying to figure out why the 12th layer in
    your separate lists is coming up with the wrong color (or linetype).

    (setq myLayers
    (list
    (list "pl" "red" "Continuous")
    (list "contours" "9" "Hidden")
    (list "el" "red" "Continuous")))

    _$ myLayers
    (("pl" "red" "Continuous") ("contours" "9" "Hidden") ("el" "red"
    "Continuous"))
    _$ (assoc "pl" myLayers)
    ("pl" "red" "Continuous")
    _$ (car (assoc "pl" myLayers))
    "pl"
    _$ (cadr (assoc "pl" myLayers))
    "red"
    _$ (caddr (assoc "pl" myLayers))
    "Continuous"



    --
    R. Robert Bell


    this is the lisp i want to use..

    (while (/= nlayn "text")
    (foreach newlayername'("pl"
    "contours"
    "el"
    "ant"
    "steel"
    "eq"
    "ha"
    "grid"
    "tray"
    "gnd"
    "power"
    "bolts"
    "fence"
    "vp"
    "text"
    )
    (setq nlayn newlayername)
    (foreach newlayercolor'("red"
    "9"
    "red"
    "magenta"
    "cyan"
    "123"
    "9"
    "9"
    "blue"
    "72"
    "140"
    "yellow"
    "cyan"
    "vp"
    "yellow"
    )
    (setq nlayc newlayercolor)
    (foreach newlayertype'("Continuous"
    "hidden"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    "Continuous"
    )
    (setq nlayt newlayertype)
    (command "layer" "make" nlayn "color" nlayc "lt" nlayt "")
    )
    )
    )
    )


    but the layer command won't allow it.. my only other option that i can
    see (and don't like).. is

    (command "layer" "make" "pl" "color" "red" "" "make" "contours"........)

    that approach gets way to long..


    TIA.

    (btw, if i can do this via entmake or the like then great)
     
    R. Robert Bell, Jun 1, 2004
    #7
  8. C Witt

    C Witt Guest

    the extra layer name call is not required.. as it is the defualt layer
    name .. a "" would sufice (though i did forget to enter even that).

    the "vp" color was a typo.. should have been "white".

    but since it never got past the first layer in the list.. that had no
    effect on it.
     
    C Witt, Jun 1, 2004
    #8
  9. C Witt

    C Witt Guest

    the extra layer name call is not required.. as it is the defualt layer
    name .. a "" would sufice (though i did forget to enter even that).

    the "vp" color was a typo.. should have been "white".

    but since it never got past the first layer in the list.. that had no
    effect on it.
     
    C Witt, Jun 1, 2004
    #9
  10. C Witt

    C Witt Guest

    worked wonders.

    new code (alot faster than before):
    (setq myLayers
    (list
    (list "pl" "red" "Continuous")
    (list "contours" "9" "hidden")
    (list "el" "red" "Continuous")
    (list "ant" "magenta" "Continuous")
    (list "steel" "cyan" "Continuous")
    (list "eq" "123" "Continuous")
    (list "ha" "9" "Continuous")
    (list "grid" "9" "Continuous")
    (list "tray" "blue" "Continuous")
    (list "gnd" "72" "Continuous")
    (list "power" "140" "Continuous")
    (list "bolts" "yellow" "Continuous")
    (list "fence" "cyan" "Continuous")
    (list "vp" "white" "Continuous")
    (list "tree" "green" "Continuous")
    (list "text" "yellow" "Continuous")
    )
    )
    (foreach laydata'("pl" "contours" "el" "ant" "steel" "eq" "ha" "grid"
    "tray" "gnd" "power" "bolts" "fence" "vp" "tree" "text")
    (command "_layer" "_make" (car (assoc laydata myLayers)) "_color" (cadr
    (assoc laydata myLayers)) "" "_lt" (caddr (assoc laydata myLayers)) "" "")
    )
     
    C Witt, Jun 2, 2004
    #10
  11. C Witt

    Jeff Mishler Guest

    Mr./Ms. C,
    It's not polite to snap at the hand that is trying to help you. Bob & I
    merely pointed out a few things that would make your routine bomb.

    As for not needing the "extra" layer name callout....it IS required...either
    by a call to the actual name OR by accepting the default with an enter, but
    required nonetheless and THAT is why your routine failed to get past the
    first layer......

    The "vp" for a color was undoubtedly a typo, we merely showed it to you.

    Jeff
     
    Jeff Mishler, Jun 2, 2004
    #11
  12. C Witt

    Jeff Mishler Guest

    why not just this?:
    (foreach laydata myLayers
    (command "_layer" "_make" (car laydata) "_color" (cadr laydata) ""
    "_lt" (caddr laydata) "" "")
    )


    Jeff
     
    Jeff Mishler, Jun 2, 2004
    #12
  13. C Witt

    C Witt Guest

    "It's not polite to snap at the hand that is trying to help you"..

    I wasn't.. or atleast didn't think I was. I was just filling in the
    "questions" I thoguht you (and ECCAD) were asking..

    Sorry.
     
    C Witt, Jun 2, 2004
    #13
  14. C Witt

    C Witt Guest

    even better, thank you.

     
    C Witt, Jun 2, 2004
    #14
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.