Changing Snaps During Rotate

Discussion in 'AutoCAD' started by mr_nick, May 22, 2004.

  1. mr_nick

    mr_nick Guest

    I'm trying to tweak an insert routine I've been using for a while. As it is, it works OK but one last tweak would make it exactly the way I want it.

    I currently have my snaps set to utilise whatever the user has selected at the time to pick a point to insert a block. The block is then inserted at this point and I then use the rotate command to set it whichever way I require. This has a few glitches depending on whatever snaps a user has preselected, causing misplaced or rotated objects. What I therefore need to be able to do is turn off certain snaps transparently. I know you can do this when using the rotate command but I know it cannot be done in LISP when using 'command "ROTATE" etc, etc...'

    Is there another method I can use for allowing a selectable rotation which will also let me change snap settings halfway through?
     
    mr_nick, May 22, 2004
    #1
  2. mr_nick

    Steve Doman Guest

    I'm not sure I understand your question, but if you trying to turn off
    only certain osnaps without turning off all of them, try using the boole
    function:

    Code:
    
    ;; Save the current osmode setting so that
    ;; it can be restore when your program ends
    (setq osmode (getvar "osmode"))
    
    ;; Turn off endpoint, midpoint, and  center osnap
    (setvar "osmode" (boole 4 (+ 1 2 3) osmode))
    
    ;; Turn on insert, quadrant
    (setvar "osmode" (boole 7 (+ 16 64) osmode))
    
    ;; To change osmode during an interactive command:
    
    (setq ss (ssget))
    (if ss
    (progn (setq osmode (getvar "osmode"))
    (command "._rotate" ss "")
    (setvar "osmode" (boole 7 4 osmode)) ;_ center on
    (command pause)
    (setvar "osmode" (boole 7 1 osmode)) ;_ endpoint on
    (command pause)
    (setvar "osmode" osmode)
    )
    )
    
    
    Does that help?

    Steve Doman
     
    Steve Doman, May 22, 2004
    #2
  3. mr_nick

    mr_nick Guest

    Steve.

    Thanks for the response.

    Your provided code has enabled me to tweak my routine to do just what I
    needed. After doing searches of NGs etc in the past, I had always been led
    to believe that it was not possible to issue transparent commands mid way
    through a command when using LISP so I had not bothered to try this
    approach. It would appear that, in this instance at least, it is possible.
    Just goes to show you shouldn't be believe everything you read!!
     
    mr_nick, May 23, 2004
    #3
  4. mr_nick

    Steve Doman Guest

    Nick,

    You're welcomed. From what I can tell, when AutoLISP code calls the
    command function, you may suspend that called command by not completing
    it. That gives you an opportunity to inject other AutoLISP code between
    prompts of the running command.

    There was an error in the code I posted btw.
    Here is the corrected line, just in case anybody had trouble with it:

    ;; Turn off endpoint, midpoint, and center osnap
    (setvar "osmode" (boole 4 (+ 1 2 ;|3|; 4) osmode)) ; <---

    Steve Doman
     
    Steve Doman, May 24, 2004
    #4
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.