Lisp improvement needs a litle help please

Discussion in 'AutoCAD' started by John Crocco, Feb 17, 2004.

  1. John Crocco

    John Crocco Guest

    I have the below lost that inserts a cw symbol on a horizontal line with 1
    click. I have another for a verticle line. Is there a way (Theres always a
    way) that with this lisp modified and 1 pick I can have it go onto a line in
    any direction or angle? I kinda have an idea, but cant seem to get it to
    work. I use a similar one to insert a "G" for gas piping, and could modify
    it then to do that as well.

    I think if I have it get the line information (could it also be a polyline?)
    it can then get the angle of the start and end points, and insert it in the
    middle and rotated by the angle.

    Any help would be appreciated.

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;Custom commands by John Crocco
    ;breaks horizontal line and inserts CW symbol (1 dash).
    (DEFUN C:CWH (/ pt1 pt2 sc len os *Error*)
    ;;;;;;;;; Application error handler
    (defun *Error* (Msg)
    (command "._Undo" "_End") ; end undo group
    (cond
    ((not Msg)) ; no error, do nothing
    ((member (strcase Msg T) ; cancel, do undo
    '("console break"
    "function cancelled"
    "quit / exit abort"))
    (command "._U")
    (setvar "cmdecho" cecho)
    (command "osmode" os);UNDO COMMANDS HERE
    ;
    ;
    ;
    );END OF MEMBER
    ((princ (strcat "\nError: " Msg)))
    ) ; END OF COND
    (princ)
    ); END OF DEFUN ERROR
    (setq cecho (getvar "cmdecho"))
    (setvar "CmdEcho" 0) ; turn echo off
    (command "._Undo" "_End") ; close any open group
    (command "._Undo" "_BEgin") ; start new group
    ;;;;;;;;;;;;;;;;;;;;;;
    (setq os (getvar "osmode"))
    (command "osmode" "512")
    (setq pt1 (getpoint "\nInsertion Point: "))
    (setq sc (getvar "userr1"))
    (setq pt2 (* 24.0 sc))
    (setq len (polar pt1 0.0 pt2))
    (command "BREAK" pt1 len)
    (command "INSERT" "cwpipe" pt1 sc sc 0)
    (command "osmode" os)
    (setvar "cmdecho" cecho)
    (*Error* nil) ;call error handler w/no error
    )
     
    John Crocco, Feb 17, 2004
    #1
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.