Reactor Help

Discussion in 'AutoCAD' started by bmossman, Sep 9, 2004.

  1. bmossman

    bmossman Guest

    How can i modify the the following reactor to change the color of the crosshairs from red (when in pspace) to white (when in active viewport)?

    (vl-load-reactors)
    (vlr-miscellaneous-reactor
    nil '(:)vlr-layoutSwitched . ChangeLayoutCrosshairColor-Red)))
    (defun ChangeLayoutCrosshairColor-Red (calling-reactor info /)
    (if (not (eq (car info) "Model"))
    (vla-put-LayoutCrosshairColor
    (vla-get-Display (vla-get-Preferences (vlax-get-acad-object)))
    (vlax-make-variant 255 vlax-vbLong))))
     
    bmossman, Sep 9, 2004
    #1
  2. bmossman

    Jürg Menzi Guest

    Hi bmossman

    A 'VLR-SysVar-Reactor' can do that. Add the following code to your
    AcadDoc.lsp or, if you don't have one, create a file with this name in the
    AutoCAD support environment.
    Code:
    (vl-load-com)
    
    (or Me:Svr
    (setq Me:Svr (VLR-SysVar-Reactor
    nil
    '((:VLR-sysVarChanged . MeChangeCrosshairColor))
    )
    )
    )
    (or Me:Dmr
    (setq Me:Dmr (vlr-DocManager-reactor
    nil
    '((:VLR-documentToBeDestroyed . MeDoCloseStuff))
    )
    )
    )
    
    (defun MeDoCloseStuff (Rea Arg)
    (mapcar 'VLR-remove (list Me:Svr Me:Dmr))
    (setq Me:Dmr nil
    Me:Svr nil
    )
    (princ)
    )
    
    (defun MeChangeCrosshairColor (Rea Arg / AcaDsp AcaDoc AcaObj LayBco ModBco)
    (if (vl-position (car Arg) '("SNAPMODE" "CVPORT"))
    (progn
    (setq AcaObj (vlax-get-acad-object)
    AcaDoc (vla-get-ActiveDocument AcaObj)
    AcaDsp (vla-get-Display (vla-get-Preferences AcaObj))
    LayBco (vlax-variant-value
    (vlax-variant-change-type
    (vla-get-GraphicsWinLayoutBackgrndColor AcaDsp)
    vlax-vbLong
    )
    )
    ModBco (vlax-variant-value
    (vlax-variant-change-type
    (vla-get-GraphicsWinModelBackgrndColor AcaDsp)
    vlax-vbLong
    )
    )
    )
    ;
    ; Set the cursor color to the appropriate value.
    ; Color list:
    ;        0 = Black
    ;      255 = Red
    ;    65535 = Yellow
    ;    65280 = Green
    ; 16776960 = Cyan
    ; 16711680 = Blue
    ; 16711935 = Magenta
    ; 16777215 = White
    ;
    (if (= (getvar "TILEMODE") 0)
    (vla-put-LayoutCrosshairColor
    AcaDsp
    (if (= (vlax-get (vla-get-ActivePViewport AcaDoc) 'SnapOn) 0)
    (MeInvGreyCol LayBco)
    255	;Cursor color by Snap on (Layout)
    )
    )
    (vla-put-ModelCrosshairColor
    AcaDsp
    (if (= (getvar "SNAPMODE") 0)
    (MeInvGreyCol ModBco)
    255	;Cursor color by Snap on (Model)
    )
    )
    )
    )
    )
    (princ)
    )
    
    (defun MeInvGreyCol (Col)
    (boole 6
    (*
    (*
    (/
    (/
    (+ (logand Col 255) (logand (/ Col 256) 255) (logand (/ Col 65536) 255))
    3
    )
    128
    )
    255
    )
    65793
    )
    16777215
    )
    )
    
    (princ)
    
    Cheers
     
    Jürg Menzi, Sep 9, 2004
    #2
  3. bmossman

    bmossman Guest

    Thanks Jurg.
    I created the acaddoc.lsp, added the code & restarted Acad but the crosshairs are continuously white when switching from pspace to active vport.
     
    bmossman, Sep 9, 2004
    #3
  4. bmossman

    Jürg Menzi Guest

    bmossman

    Sorry missread your post... the reactor changes crosshair colors on switching
    SNAPMODE on/off. Replace 'MeChangeCrosshairColor' by this edition:
    Code:
    (defun MeChangeCrosshairColor (Rea Arg / AcaDsp AcaObj LayBco)
    (if (vl-position (car Arg) '("CVPORT"))
    (progn
    (setq AcaObj (vlax-get-acad-object)
    AcaDsp (vla-get-Display (vla-get-Preferences AcaObj))
    LayBco (vlax-variant-value
    (vlax-variant-change-type
    (vla-get-GraphicsWinLayoutBackgrndColor AcaDsp)
    vlax-vbLong
    )
    )
    )
    ;
    ; Color list:
    ;        0 = Black
    ;      255 = Red
    ;    65535 = Yellow
    ;    65280 = Green
    ; 16776960 = Cyan
    ; 16711680 = Blue
    ; 16711935 = Magenta
    ; 16777215 = White
    ; Set the cursor color to the appropriate value:
    ;
    (vla-put-LayoutCrosshairColor
    AcaDsp
    (if (= (getvar "CVPORT") 1)
    255	;Cursor color in Paperspace
    (MeInvGreyCol LayBco)
    )
    )
    )
    )
    (princ)
    )
    
    Cheers
     
    Jürg Menzi, Sep 9, 2004
    #4
  5. bmossman

    bmossman Guest

    Thanks man that's awesome!!!!
     
    bmossman, Sep 9, 2004
    #5
  6. bmossman

    Jürg Menzi Guest

    Glad to help you...¦-)

    Cheers
     
    Jürg Menzi, Sep 9, 2004
    #6
  7. bmossman

    bmossman Guest

    Jurg - I've noticed since loading this reactor I'm no longer able to execute the zoom command when in Modespace...it just keeps cancelling. Is there a way around this?
     
    bmossman, Sep 15, 2004
    #7
  8. bmossman

    Jürg Menzi Guest

    Hi bmossman

    I've tested the reactor system with A2k2, A2k4 and A2k5, no probs. To see
    what's happen, remove the reactor system (AcadDoc.lsp) and start AutoCAD
    (same drawing) without reactor system.

    Cheers
     
    Jürg Menzi, Sep 16, 2004
    #8
  9. bmossman

    Ricardo Guest

    [ (Viewport Properties / Display locked / Yes) & (Modespace) & (Zoom
    Dynamic) ] => cancelling zoom

    Un saludo
     
    Ricardo, Sep 17, 2004
    #9
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.