• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Distinguished Contributor
    Posts: 108
    Registered: ‎07-05-2004

    "Hatch to back" reactor

    340 Views, 12 Replies
    06-01-2006 06:55 PM
    Hi all!
    Does anyone have a reactor or something that ensures all hatch is "sent to back"?
    If so, is there any chance of sharing please??

    I know nothing of reactors. I do have a routine to send all hatch to back on demand, but would really like something that does it automatically.

    Many thanks in advance
    HOLLY Message was edited by: Holly
    Attrocious spelling!
    Please use plain text.
    *Ian Nelson

    Re: "Hatch to back" reactor

    06-01-2006 09:41 PM in reply to: kieren.aubrey
    ... are you aware of the system variable HPDRAWORDER ? This variable has 5
    options, one of which forces all new hatches to the back.

    But of course if you are looking at changing existing hatches in existing
    drawings... ignore the above!

    Ian



    wrote in message news:5193269@discussion.autodesk.com...
    Hi all!
    Does anyone have a reactor or something that ensures all hatch is "sent to
    back"?
    If so, is there any chance of sharing please??

    I know nothing of reactors. I do have a routine to send all hatch to back on
    demand, but would really like something that does it automatically.

    Many thanks in advance
    HOLLY

    Message was edited by: Holly
    Attrocious spelling!
    Please use plain text.
    Distinguished Contributor
    Posts: 108
    Registered: ‎07-05-2004

    Re: "Hatch to back" reactor

    06-01-2006 11:22 PM in reply to: kieren.aubrey
    Hi Ian,
    Wasn't aware of HPDRAWORDER - ansd so it seems neither is my version of AutoCAD!!! 2004.0.0

    Copy of command line below:
    -----------------------------------------------------------------------
    Command: hpdraworder
    Unknown command "HPDRAWORDER". Press F1 for help.
    Command: setvar
    Enter variable name or [?] : hpdraworder
    Unknown variable name. Type SETVAR ? for a list of variables.
    -----------------------------------------------------------------------

    Cheers,
    HOLLY
    Please use plain text.
    *Bruno Toniutti

    Re: "Hatch to back" reactor

    06-02-2006 01:55 AM in reply to: kieren.aubrey
    > I know nothing of reactors. I do have a routine to send all hatch to back
    > on demand, but would really like something that does it automatically.

    In real time or when you do a specific action ? In real time, on all hatchs
    of a drawing, I'm septic that it's possible.

    Bruno Toniutti
    (sorry for my english level)
    Please use plain text.
    *Matt W

    Re: "Hatch to back" reactor

    06-02-2006 10:12 AM in reply to: kieren.aubrey
    Give this a shot.

    ; - 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 -------------------------------------------------------------
    ;
    ; - CommandEnded notifications
    (defun MeCommandEndedCallbacks (Rea Arg)
    (MeDoCmdEndedStuff Arg)
    (princ)
    )
    ; - DocToBeDestroyed notifications
    (defun MeDocToBeDestroyedCallbacks (Rea Arg)
    (MeDoCloseStuff)
    (princ)
    )
    ;
    ; - Subs ----------------------------------------------------------------------
    ;
    ; - Command ended function
    (defun MeDoCmdEndedStuff (Arg / CurCmd ObjNme TmpObj)
    (setq CurCmd (strcase (car Arg)))
    (cond
    ((vl-position CurCmd '("BHATCH" "HATCH" "IMAGEATTACH" "SOLID"))
    (setq TmpObj (vlax-ename->vla-object (entlast))
    ObjNme (vla-get-ObjectName TmpObj)
    )
    (if (vl-position ObjNme '("AcDbHatch" "AcDbRasterImage" "AcDbSolid"))
    (MeSetDrawOrder (list TmpObj) nil 'MoveToBottom)
    )
    )
    ;;; other command ended 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 object draw order
    (defun MeSetDrawOrder (Obl Tob Mde / AcaDoc ExtDic SreTbl)
    (setq AcaDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    ExtDic (vla-GetExtensionDictionary (vla-get-ModelSpace AcaDoc))
    )
    (if (vl-catch-all-error-p
    (setq SreTbl (vl-catch-all-apply
    'vla-Item (list ExtDic "ACAD_SORTENTS")
    )
    )
    )
    (setq SreTbl (vla-AddObject ExtDic "ACAD_SORTENTS" "AcDbSortentsTable"))
    )
    (cond
    ((vl-position Mde '(MoveToTop MoveToBottom))
    (not (vlax-Invoke SreTbl Mde Obl))
    )
    (Tob
    (not (vlax-Invoke SreTbl Mde Obl Tob))
    )
    )
    )
    ; - Set hatch/image draw order on startup
    (defun MeSendRasterAndImageToBottom ( / CurEnt CurSet ObjLst)
    (if (setq CurSet (ssget "X" '((0 . "HATCH"))))
    (progn
    (while (setq CurEnt (ssname CurSet 0))
    (setq ObjLst (cons (vlax-ename->vla-object CurEnt) ObjLst))
    (ssdel CurEnt CurSet)
    )
    (MeSetDrawOrder ObjLst nil 'MoveToBottom)
    )
    )
    (setq ObjLst '())
    (if (setq CurSet (ssget "X" '((0 . "SOLID"))))
    (progn
    (while (setq CurEnt (ssname CurSet 0))
    (setq ObjLst (cons (vlax-ename->vla-object CurEnt) ObjLst))
    (ssdel CurEnt CurSet)
    )
    (MeSetDrawOrder ObjLst nil 'MoveToBottom)
    )
    )
    (setq ObjLst '())
    (if (setq CurSet (ssget "X" '((0 . "IMAGE"))))
    (progn
    (while (setq CurEnt (ssname CurSet 0))
    (setq ObjLst (cons (vlax-ename->vla-object CurEnt) ObjLst))
    (ssdel CurEnt CurSet)
    )
    (MeSetDrawOrder ObjLst nil 'MoveToBottom)
    )
    )
    (princ)
    )
    ;
    ; - Startup functions ---------------------------------------------------------
    ;
    ;(MeSendRasterAndImageToBottom)
    ;
    ; == Copyright - Note (May be never deleted) ==================================
    ;
    ; ©2005 MENZI ENGINEERING GmbH, Switzerland
    ; -----------------------------------------------------------------------------
    ;


    And here's a little something to force all hatch that isn't already, to the back.

    (defun C:HATCHBACK ( / hss cmd)
    (setq cmd (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (setq hss (ssget "X" (list (cons 0 "HATCH"))))
    (command "_.draworder" "p" "" "back")
    (setvar "cmdecho" 1)
    (princ)
    )

    --
    Matt W
    "What the flip was Grandma doing at the sand dunes?"
    Please use plain text.
    Distinguished Contributor
    Posts: 108
    Registered: ‎07-05-2004

    Re: "Hatch to back" reactor

    06-05-2006 06:56 PM in reply to: kieren.aubrey
    Thanks Matt,
    That works a dream!
    I already had a lisp routine that moves all existing hatch to back, but this reactor thingy(!) does just what I want - puts hatch to back straight away when hatching.

    Cheers guys, thanks for the help.
    HOLLY

    ps. I think you need to keep a closer eye on Grandma by the sounds of things!
    Please use plain text.
    Valued Contributor
    msarqui
    Posts: 87
    Registered: ‎09-14-2010

    Re: "Hatch to back" reactor

    02-15-2013 08:58 AM in reply to: *Matt W

    (defun C:HATCHBACK ( / hss cmd)
       (setq cmd (getvar "cmdecho"))
       (setvar "cmdecho" 0)
       (setq hss (ssget "X" (list (cons 0 "HATCH"))))
       (command "_.draworder" "p" "" "back")
       (setvar "cmdecho" 1)
       (princ)
    )

    It is possible to do this in model and paper space at the same time? Like in on shot?

     

    Thanks!

    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,085
    Registered: ‎09-13-2004

    Re: "Hatch to back" reactor

    02-15-2013 11:04 AM in reply to: msarqui

    msarqui wrote:

    (defun C:HATCHBACK ( / hss cmd)
       (setq cmd (getvar "cmdecho"))
       (setvar "cmdecho" 0)
       (setq hss (ssget "X" (list (cons 0 "HATCH"))))
       (command "_.draworder" "p" "" "back")
       (setvar "cmdecho" 1)
       (princ)
    )

    It is possible to do this in model and paper space at the same time? Like in on shot?

    ....


    Commands that use object selection, even when used in AutoLISP (command) functions, only "see" objects in the current space.  I looked for something in objects' entity data or VLA Properties or extended data that changed when I sent them to the back, but I didn't find anything, so I'm not sure what it does to them that might be done by way of (entmod) or (vla-put...) or something, so that you could do it even to things not in the current space.

     

    If there isn't a way like that, you can always resort to changing the space you're in to do each one [untested]:

     

    (defun C:HATCHBACK (/ cmd curtab)
       (setq

         cmd (getvar 'cmdecho)

         curtab (getvar 'ctab); save starting space

       ); setq
       (setvar 'cmdecho 0)

       (foreach h (mapcar 'cadr (ssnamex (ssget "_X" '((0 . "HATCH")))))

           ; list of Hatch entity names

         (setvar 'ctab (cdr (assoc 410 (entget h)))); move to its space
         (command "_.draworder" h "" "back")

       ); foreach
       (setvar 'cmdecho 1)

       (setvar 'ctab curtab); restore starting space
       (princ)
    )

    Kent Cooper
    Please use plain text.
    Valued Contributor
    msarqui
    Posts: 87
    Registered: ‎09-14-2010

    Re: "Hatch to back" reactor

    02-15-2013 11:18 AM in reply to: Kent1Cooper

    Thanks for the reply Kent.

     

    It is not working. My AutoCAD stops...

     

     

    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,085
    Registered: ‎09-13-2004

    Re: "Hatch to back" reactor

    02-15-2013 11:40 AM in reply to: msarqui

    msarqui wrote:

    Thanks for the reply Kent.

    It is not working. My AutoCAD stops...


    It works for me, though in very limited testing.  Try commenting out the turning off of the CMDECHO System Variable, and see whether you can tell what's not working.  Also, I'm still way back in 2004 -- if you're not, might the command prompt sequence have changed in a newer version?

    Kent Cooper
    Please use plain text.