OSNAP in Lisp Help

Discussion in 'AutoCAD' started by :, Jul 31, 2003.

  1. :

    : Guest

    Okay.... I am having trouble with the following lisp to copy with an
    endpont snap on (then restore snaps at the end):

    (DEFUN C:CE ()
    (SETQ OS (GETVAR "OSMODE"))
    (SETVAR "OSMODE" 1)
    (COMMAND "COPY")
    (WHILE (= 1 (LOGAND (GETVAR "CMDACTIVE") 1)) (COMMAND PAUSE))
    (SETVAR "OSMODE" OS))

    The problem is that the command only allows for the individual selection of
    entities, they cannot be selected with a window. I suspect this is from the
    while statement, but without it, the osnaps are restored to "OS" immediatey,
    and the lisp does not work as intended.

    I am sure there is an easy fix to this, I just have no idea what it would
    be... Any help would be appreciated. Also, I would like to add an error
    handler so that if the command is ESCaped out of, the osnaps will still be
    restored to the "OS" variable.

    Thanks,
    Graham
     
    :, Jul 31, 2003
    #1
  2. :

    Paul Turvill Guest

    Works fine for me ... just type 'w' for a window selection, 'c' for a
    crossing box, even 'f' for a fence selection.
    ___
     
    Paul Turvill, Jul 31, 2003
    #2
  3. :

    : Guest

    Hmmm... I see what you mean, but you wouldn't have to do that if you just
    typed "copy", as it would allow for window selection or entity selection
    automatically...

    I could modify the lisp to invoke "copy" "w", but then I have to drag a
    window before I select individual entities, or type w again to draw a second
    window... I know this seems trivial, but it would drive me absolutely nuts
    in no time =)

    Is there a better solution than using the "pause" (which I think is what is
    causing the problem)?

    Thanks,
    Graham
     
    :, Jul 31, 2003
    #3
  4. :

    Joe Becker Guest

    The attached function uses ssget as Ken has suggested. By using ssget
    before actually doing the copy you can select with window, crossing or
    individually at any point in time. The attached command does not turn on
    running osnaps, instead it enters "endpoint" at the command prompt for you.
    Give it a try.
     
    Joe Becker, Jul 31, 2003
    #4
  5. :

    : Guest

    Ken,

    That works great! That is exactly what I was looking for. I knew there had
    to be a way =)

    Thanks again,
    Graham
     
    :, Jul 31, 2003
    #5
  6. :

    : Guest

    Joe,

    That is really great! I like the fact that it doesn't even use running
    osnaps... Very cool!

    Thanks!

    Graham


    ----------------------------------------------------------------------------
    ----


    ;------------------------------------------------------------------------
    ; These functions allow the user to use the three letter copy shortcuts
    ; with the capability of making multiple copies.
    ;------------------------------------------------------------------------

    (defun C:ce () (setq COPYSNAP1 "endpoint" COPYSNAP2 "")
    (copysub))
    (defun C:cee () (setq COPYSNAP1 "endpoint" COPYSNAP2 "endpoint")
    (copysub))
    (defun C:cep () (setq COPYSNAP1 "endpoint" COPYSNAP2 "perpendicular")
    (copysub))
    (defun C:cex () (setq COPYSNAP1 "endpoint" COPYSNAP2 "intersection")
    (copysub))
    (defun C:cen () (setq COPYSNAP1 "endpoint" COPYSNAP2 "nearest")
    (copysub))
    (defun C:cec () (setq COPYSNAP1 "endpoint" COPYSNAP2 "center")
    (copysub))
    (defun C:ceq () (setq COPYSNAP1 "endpoint" COPYSNAP2 "quadrant")
    (copysub))
    (defun C:cem () (setq COPYSNAP1 "endpoint" COPYSNAP2 "midpoint")
    (copysub))
    (defun C:cei () (setq COPYSNAP1 "endpoint" COPYSNAP2 "inser")
    (copysub))
    (defun C:cea () (setq COPYSNAP1 "endpoint" COPYSNAP2 "_appint")
    (copysub))

    (defun C:cx () (setq COPYSNAP1 "intersection" COPYSNAP2 "")
    (copysub))
    (defun C:cxe () (setq COPYSNAP1 "intersection" COPYSNAP2 "endpoint")
    (copysub))
    (defun C:cxp () (setq COPYSNAP1 "intersection" COPYSNAP2 "perpendicular")
    (copysub))
    (defun C:cxx () (setq COPYSNAP1 "intersection" COPYSNAP2 "intersection")
    (copysub))
    (defun C:cxn () (setq COPYSNAP1 "intersection" COPYSNAP2 "nearest")
    (copysub))
    (defun C:cxc () (setq COPYSNAP1 "intersection" COPYSNAP2 "center")
    (copysub))
    (defun C:cxq () (setq COPYSNAP1 "intersection" COPYSNAP2 "quadrant")
    (copysub))
    (defun C:cxm () (setq COPYSNAP1 "intersection" COPYSNAP2 "midpoint")
    (copysub))
    (defun C:cxi () (setq COPYSNAP1 "intersection" COPYSNAP2 "inser")
    (copysub))
    (defun C:cxa () (setq COPYSNAP1 "intersection" COPYSNAP2 "_appint")
    (copysub))

    (defun C:cn () (setq COPYSNAP1 "nearest" COPYSNAP2 "") (copysub))
    (defun C:cne () (setq COPYSNAP1 "nearest" COPYSNAP2 "endpoint")
    (copysub))
    (defun C:cnp () (setq COPYSNAP1 "nearest" COPYSNAP2 "perpendicular")
    (copysub))
    (defun C:cnx () (setq COPYSNAP1 "nearest" COPYSNAP2 "intersection")
    (copysub))
    (defun C:cnn () (setq COPYSNAP1 "nearest" COPYSNAP2 "nearest")
    (copysub))
    (defun C:cnc () (setq COPYSNAP1 "nearest" COPYSNAP2 "center")
    (copysub))
    (defun C:cnq () (setq COPYSNAP1 "nearest" COPYSNAP2 "quadrant")
    (copysub))
    (defun C:cnm () (setq COPYSNAP1 "nearest" COPYSNAP2 "midpoint")
    (copysub))
    (defun C:cni () (setq COPYSNAP1 "nearest" COPYSNAP2 "inser")
    (copysub))
    (defun C:cna () (setq COPYSNAP1 "nearest" COPYSNAP2 "_appint")
    (copysub))

    (defun C:cc () (setq COPYSNAP1 "center" COPYSNAP2 "") (copysub))
    (defun C:cce () (setq COPYSNAP1 "center" COPYSNAP2 "endpoint")
    (copysub))
    (defun C:ccp () (setq COPYSNAP1 "center" COPYSNAP2 "perpendicular")
    (copysub))
    (defun C:ccx () (setq COPYSNAP1 "center" COPYSNAP2 "intersection")
    (copysub))
    (defun C:ccn () (setq COPYSNAP1 "center" COPYSNAP2 "nearest")
    (copysub))
    (defun C:ccc () (setq COPYSNAP1 "center" COPYSNAP2 "center")
    (copysub))
    (defun C:ccq () (setq COPYSNAP1 "center" COPYSNAP2 "quadrant")
    (copysub))
    (defun C:ccm () (setq COPYSNAP1 "center" COPYSNAP2 "midpoint")
    (copysub))
    (defun C:cci () (setq COPYSNAP1 "center" COPYSNAP2 "inser")
    (copysub))
    (defun C:cca () (setq COPYSNAP1 "center" COPYSNAP2 "_appint")
    (copysub))

    (defun C:cq () (setq COPYSNAP1 "quadrant" COPYSNAP2 "")
    (copysub))
    (defun C:cqe () (setq COPYSNAP1 "quadrant" COPYSNAP2 "endpoint")
    (copysub))
    (defun C:cqp () (setq COPYSNAP1 "quadrant" COPYSNAP2 "perpendicular")
    (copysub))
    (defun C:cqx () (setq COPYSNAP1 "quadrant" COPYSNAP2 "intersection")
    (copysub))
    (defun C:cqn () (setq COPYSNAP1 "quadrant" COPYSNAP2 "nearest")
    (copysub))
    (defun C:cqc () (setq COPYSNAP1 "quadrant" COPYSNAP2 "center")
    (copysub))
    (defun C:cqq () (setq COPYSNAP1 "quadrant" COPYSNAP2 "quadrant")
    (copysub))
    (defun C:cqm () (setq COPYSNAP1 "quadrant" COPYSNAP2 "midpoint")
    (copysub))
    (defun C:cqi () (setq COPYSNAP1 "quadrant" COPYSNAP2 "inser")
    (copysub))
    (defun C:cqa () (setq COPYSNAP1 "quadrant" COPYSNAP2 "_appint")
    (copysub))

    (defun C:cm () (setq COPYSNAP1 "midpoint" COPYSNAP2 "")
    (copysub))
    (defun C:cme () (setq COPYSNAP1 "midpoint" COPYSNAP2 "endpoint")
    (copysub))
    (defun C:cmp () (setq COPYSNAP1 "midpoint" COPYSNAP2 "perpendicular")
    (copysub))
    (defun C:cmx () (setq COPYSNAP1 "midpoint" COPYSNAP2 "intersection")
    (copysub))
    (defun C:cmn () (setq COPYSNAP1 "midpoint" COPYSNAP2 "nearest")
    (copysub))
    (defun C:cmc () (setq COPYSNAP1 "midpoint" COPYSNAP2 "center")
    (copysub))
    (defun C:cmq () (setq COPYSNAP1 "midpoint" COPYSNAP2 "quadrant")
    (copysub))
    (defun C:cmm () (setq COPYSNAP1 "midpoint" COPYSNAP2 "midpoint")
    (copysub))
    (defun C:cmi () (setq COPYSNAP1 "midpoint" COPYSNAP2 "inser")
    (copysub))
    (defun C:cma () (setq COPYSNAP1 "midpoint" COPYSNAP2 "_appint")
    (copysub))

    (defun C:ci () (setq COPYSNAP1 "inser" COPYSNAP2 "") (copysub))
    (defun C:cie () (setq COPYSNAP1 "inser" COPYSNAP2 "endpoint")
    (copysub))
    (defun C:cip () (setq COPYSNAP1 "inser" COPYSNAP2 "perpendicular")
    (copysub))
    (defun C:cix () (setq COPYSNAP1 "inser" COPYSNAP2 "intersection")
    (copysub))
    (defun C:cin () (setq COPYSNAP1 "inser" COPYSNAP2 "nearest")
    (copysub))
    (defun C:cic () (setq COPYSNAP1 "inser" COPYSNAP2 "center")
    (copysub))
    (defun C:ciq () (setq COPYSNAP1 "inser" COPYSNAP2 "quadrant")
    (copysub))
    (defun C:cim () (setq COPYSNAP1 "inser" COPYSNAP2 "midpoint")
    (copysub))
    (defun C:cii () (setq COPYSNAP1 "inser" COPYSNAP2 "inser")
    (copysub))
    (defun C:cia () (setq COPYSNAP1 "inser" COPYSNAP2 "_appint")
    (copysub))

    (defun copysub ()

    ;informing what type of copy is being performed

    (if (/= COPYSNAP1 "inser")(setq from_point (strcase COPYSNAP1))
    (setq from_point "INSERTION"))
    (if (= COPYSNAP2 "") (setq to_point ""))
    (if (= COPYSNAP2 "inser") (setq to_point "INSERTION")
    (setq to_point (strcase COPYSNAP2)))
    (princ (strcat "COPY: From " from_point " to " to_point ))

    ;getting objects and number of copies

    (ssget)

    ;performing the copy

    (command "copy" "p" "" "m" COPYSNAP1 pause)
    (while (= (logand (getvar "cmdactive") 1) 1)
    (if (/= COPYSNAP2 "")
    (command COPYSNAP2 pause)
    (command pause)
    )
    )
    ) ;end of defun


    ; Written by Joe Becker August 1997
    ; Modified by Joe Becker May 2002
     
    :, Jul 31, 2003
    #6
  7. :

    Scot-65 Guest

    Ghram,

    Try this:

    (while (> (getvar "CMDACTIVE") 0) (command pause) )

    LOGAND may be the item that gets in the way.
    I have seen many values for the CMDACTIVE variable
    whick typically indicates what pop is open, what dialog box is showing, etc...
    so the value of CMDACTIVE is not fixed to 1.

    Scot-65
     
    Scot-65, Aug 1, 2003
    #7
  8. :

    Scot-65 Guest

    Paul,

    Tough crowd!!!!

    Did not have my reference material at time of posting.
    Did the CMDACTIVE unit about 10 yrs. ago, GRREAD about two tears later.
    Got a little confused...

    Anyway, variable CMDACTIVE is a integer and it is non zero and a positive value when
    a command is active. He does not need the LOGAND as part of his equation.
    No part of his equation needs to reference the value of LOGAND.

    I am still sticking to my posted equation.


    Erroneous selections are another problem with his endpoint turned on; weather the line
    or arc segment (etc...) is "T"eed or "Cornered" to another segment. I found out the hard
    way back in release 10. The only open-end (line) segments allowed here is for arrow
    leader (text items) and dimension items. Exceptions are ground and ceiling lines
    for two dimensional "Elevation" type drawings.


    Scot-65
     
    Scot-65, Aug 5, 2003
    #8
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.