Help with reactor

Discussion in 'AutoCAD' started by cadman_meg, Nov 12, 2004.

  1. cadman_meg

    cadman_meg Guest

    I am no good with reactors, but was wondering if someone has something or can throw something together real quick that will automatically detect when the hatch or hatch edit command is called and then when it is done with whatever, automatically send that hatch to the back in the display order. Anyone? Thanks much.
     
    cadman_meg, Nov 12, 2004
    #1
  2. cadman_meg

    LUCAS Guest

    ;;USING vla-sendcommand

    (defun CHECKCOM (REACTOR COMMANDLIST)
    (if (wcmatch (car COMMANDLIST) "*HATCH")
    (if (setq SS (ssget "X" '((0 . "HATCH"))))
    (vla-sendcommand
    (vla-get-activedocument (vlax-get-acad-object))
    "_.DRAWORDER !SS B "
    )
    )
    )
    (princ)
    )

    (if (not #CHECKCOM)
    (setq #CHECKCOM
    (vlr-editor-reactor
    NIL
    '(:)vlr-commandended . CHECKCOM))
    )
    )
    )

    can throw something together real quick that will automatically detect when
    the hatch or hatch edit command is called and then when it is done with
    whatever, automatically send that hatch to the back in the display order.
    Anyone? Thanks much.
     
    LUCAS, Nov 12, 2004
    #2
  3. cadman_meg

    Jürg Menzi Guest

    Hi Nickname

    This should do what you want:
    Code:
    ; - Initialize ActiveX support
    (vl-load-com)
    
    ; - Reactors ------------------------------------------------------------------
    ; - If not set, initialize DocManager-Reactor
    (or Me:ReaDma
    (setq Me:ReaDma (VLR-DocManager-Reactor
    nil
    '(
    (:VLR-documentToBeDestroyed . MeDocToBeDestroyedCallbacks)
    )
    )
    )
    )
    ; - If not set, initialize Command-Reactor
    (or Me:ReaCom
    (setq Me:ReaCom (VLR-Command-Reactor
    nil
    '(
    (:VLR-commandEnded . MeCommandEndedCallbacks)
    )
    )
    )
    )
    
    ; - Notifications -------------------------------------------------------------
    ; - CommandWillStart notifications
    ; - CommandEnded notifications
    (defun MeCommandEndedCallbacks (Rea Arg)
    (MeDoCmdEndStuff Arg)
    (princ)
    )
    ; - DocToBeDestroyed notifications
    (defun MeDocToBeDestroyedCallbacks (Rea Arg)
    (MeDoCloseStuff)
    (princ)
    )
    
    ; - Subs ----------------------------------------------------------------------
    ; - Command end function
    (defun MeDoCmdEndStuff (Arg / CurCmd TmpObj)
    (setq CurCmd (strcase (car Arg)))
    (cond
    ((wcmatch CurCmd "*HATCH")
    (setq TmpObj (vlax-ename->vla-object (entlast)))
    (if (eq (vla-get-ObjectName TmpObj) "AcDbHatch")
    (MeSetDrawOrder (list TmpObj) 'MoveToBottom)
    )
    )
    ;;; other command dependent functions
    )
    (princ)
    )
    ; - Reactor cleanup function
    (defun MeDoCloseStuff ( / VarLst)
    (setq VarLst (MeGetReaVars))
    (mapcar 'VLR-remove (mapcar 'eval VarLst))
    (mapcar '(lambda (l) (set l nil)) VarLst)
    (princ)
    )
    ; - Collect global reactor variables
    (defun MeGetReaVars ( / RetVal)
    (foreach memb (atoms-family 1)
    (if (wcmatch (strcase memb) "ME:REA*")
    (setq RetVal (cons memb RetVal))
    )
    )
    (mapcar 'read RetVal)
    )
    ; - Set entity draw order
    (defun MeSetDrawOrder (Obl Mde / AcaDoc ExtDic SrtTbl)
    (setq AcaDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    ExtDic (vla-GetExtensionDictionary (vla-get-ModelSpace AcaDoc))
    )
    (if (vl-catch-all-error-p
    (setq SrtTbl (vl-catch-all-apply
    'vla-Item (list ExtDic "ACAD_SORTENTS")
    )
    )
    )
    (setq SrtTbl (vla-AddObject "ACAD_SORTENTS" "AcDbSortentsTable"))
    )
    (vlax-Invoke SrtTbl Mde Obl)
    (princ)
    )
    
    (princ)
    
    Cheers
     
    Jürg Menzi, Nov 12, 2004
    #3
  4. cadman_meg

    Jürg Menzi Guest

    Hi Nickname

    If you are on 2k5, you can also set the sysvar 'HPDRAWORDER' to '1'.

    Cheers
     
    Jürg Menzi, Nov 12, 2004
    #4
  5. cadman_meg

    Mark G. Guest

    So would I save this is a .dvb file? Thanks much.

     
    Mark G., Nov 12, 2004
    #5
  6. cadman_meg

    Jürg Menzi Guest

    No, normally in AcadDoc.lsp or in YourMenuFileName.mnl

    Cheers
     
    Jürg Menzi, Nov 13, 2004
    #6
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.