need help with a lsp routine

Discussion in 'AutoCAD' started by jojo, Sep 19, 2006.

  1. jojo

    jojo Guest

    I have written the following maco, but need it in a lisp routine.
    I also need the lisp routine to loop, so that I can continue selecting lines
    till I'm ready to stop.

    [Beams2]^C^C^Po;12;\\;change;l;;p;la;fn-beam;;

    This macro offsets a selected line 12" and changes the new line to a
    specific layer.

    Can someone help me with this?

    Thanks,
    jojo
     
    jojo, Sep 19, 2006
    #1
  2. jojo

    jojo Guest

    ok, why can't it be this easy?

    (defun C:eek:tl ()
    (command "offset" "12")
    (command "chprop" "l" "" "la" "fn-beam" "")
    (princ)
    )
     
    jojo, Sep 19, 2006
    #2
  3. jojo

    jojo Guest

    Can someone help me edit this?
    I need it to offset 12" and I need the layer to be fn-beam, not current.
    Thanks, jojo

    ; From the desk of Paul Standing
    ; Routine will offset set objects to the current layer
    ; Offset_to_layer v 1.0 march 25 1995

    (defun C:Off_to_lay()
    (setvar "cmdecho" 0)
    (setq c_layer (getvar "clayer")
    last (getvar "offsetdist"))
    (prompt "\nOffset distance or through" )
    (setq dist (getdist))
    (if (or (= dist nil)(= dist ""))
    (setq dist last)
    )
    (setq obj (entsel "\nSelect object to offset:"))
    (setq pick_pt (car(cdr obj)))
    (setq ent (car obj))
    (setq side_pt (getpoint "\nside to offset"))
    (command "offset" dist pick_pt side_pt "")
    (setq ent1 (entlast))
    (setq ptlst (entget ent1)
    b (assoc 8 ptlst)
    c (cons 8 c_layer)
    d (subst c b ptlst))
    (entmod d)
    (princ)
    )
     
    jojo, Sep 19, 2006
    #3
  4. Because you want it to loop. You have to set up a WHILE with a criterion
    that will exit when you want to.

    (defun C:eek:tl (/ n)
    (setvar "cmdecho" 1)
    (while (not n)
    (if(eq a nil)(exit))
    (command "OFFSET" 12 pause pause "")
    (setq c (entlast))
    (command "CHPROP" c "" "LA" "1" "")
    )
    (princ)
    )
     
    Michael Bulatovich, Sep 19, 2006
    #4
  5. Ooops. Replace "fn-beam" for "1" in the CHPROP line. I tested it using a
    drawing with a layer "1"....
    If you allowed user input to set the offset, you might get more use out of
    it, jojo.
     
    Michael Bulatovich, Sep 20, 2006
    #5
  6. jojo

    jojo Guest

    Thanks for the tweak...I'm setting this one up for the engineer, who does
    not want options.
    Click and go.

    I really do appreciate your help..My boss is an "instant gratification"
    kinda guy, and I am no "lisp queen".
    ;-)

    jojo
     
    jojo, Sep 20, 2006
    #6
  7. jojo

    jojo Guest

    Micheal...got time to look at this?
    it returns an error. I changed the name, and the layer to fn-beam, and that
    is all.

    I loaded it in appload, then typed "offbeam" but it does not work...any
    ideas?
    Thanks,
    jojo

    (defun C:OFFBEAM (/ n)
    (setvar "cmdecho" 1)
    (while (not n)
    (if(eq a nil)(exit))
    (command "OFFSET" 12 pause pause "")
    (setq c (entlast))
    (command "CHPROP" c "" "LA" "fn-beam" "")
    )
    (princ)
    )



    Command: OFFBEAM
    ; error: quit / exit abort
     
    jojo, Sep 20, 2006
    #7
  8. Sorry just delete the (if(eq a nil)(exit)) line. I should have commented it
    out. It was a leftover from another version.

    MichaelB
    www.michaelbulatovich.ca
     
    Michael Bulatovich, Sep 20, 2006
    #8
  9. jojo

    jojo Guest

    Thank you SO MUCH!!!
    It worked like a charm!

    jojo
     
    jojo, Sep 20, 2006
    #9
  10. Take a penny, leave a penny ; )
     
    Michael Bulatovich, Sep 20, 2006
    #10
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.