Jump to content
chrisdarmanin

lisp request - send hatch to back in all blocks

Recommended Posts

chrisdarmanin

don't know if its simple, but i guess it is... anyone bothers to do it?¬†ūüėĀ

Share this post


Link to post
Share on other sites
Emmanuel Delay

 

On 1/14/2019 at 12:48 PM, rlx said:

 

Yes, it works.

 

I made it send every hatch to the back of the draw order (by ignoring the capa9 variable, which was only for 1 specific layer)

 

Like this:

Command HTB

dwg as example, with a block "MyBlock"

(SETQ *Doc* (VLA-GET-ACTIVEDOCUMENT(VLAX-GET-ACAD-OBJECT)))

(DEFUN HatchToBackBlk (blk / od_blk od_ent blkname)
  (SETQ od_ent (TBLOBJNAME "BLOCK" (SETQ blkname (CDR (ASSOC 2 (ENTGET blk))))))
  (WHILE (SETQ od_ent (ENTNEXT od_ent))
    ;; (IF (EQ (CDR (ASSOC 8 (ENTGET od_ent))) capa9)
    (IF T
      (VL-CATCH-ALL-APPLY
        (FUNCTION
          (LAMBDA ()
            (VLA-MOVETOBOTTOM
              (VLA-ADDOBJECT (VLA-GETEXTENSIONDICTIONARY (VLA-ITEM(VLA-GET-BLOCKS *Doc*) blkname)) "ACAD_SORTENTS" "AcDbSortentsTable")
              (VLAX-MAKE-VARIANT (VLAX-SAFEARRAY-FILL (VLAX-MAKE-SAFEARRAY VLAX-VBOBJECT '(0 . 0)) (LIST (VLAX-ENAME->VLA-OBJECT od_ent))))
            )
          )
        )
      )
    )
  )
  (VLA-REGEN *Doc* 1)
)

(defun c:htb  ( / )
  (HatchToBackBlk  (car (entsel "\nSelect block: " )))
)

HatchToBackBlk.dwg

Edited by Emmanuel Delay

Share this post


Link to post
Share on other sites
Emmanuel Delay

here is how to perform this for every block in the blocks table, so you don't have to select them 1 by 1

 



(SETQ *Doc* (VLA-GET-ACTIVEDOCUMENT(VLAX-GET-ACAD-OBJECT)))

(DEFUN HatchToBackBlk (blkname / od_ent )
  (SETQ od_ent (TBLOBJNAME "BLOCK"  blkname ))
  (WHILE (SETQ od_ent (ENTNEXT od_ent))
    (IF T
      (VL-CATCH-ALL-APPLY
        (FUNCTION
          (LAMBDA ()
            (VLA-MOVETOBOTTOM
              (VLA-ADDOBJECT (VLA-GETEXTENSIONDICTIONARY (VLA-ITEM(VLA-GET-BLOCKS *Doc*) blkname)) "ACAD_SORTENTS" "AcDbSortentsTable")
              (VLAX-MAKE-VARIANT (VLAX-SAFEARRAY-FILL (VLAX-MAKE-SAFEARRAY VLAX-VBOBJECT '(0 . 0)) (LIST (VLAX-ENAME->VLA-OBJECT od_ent))))
            )
          )
        )
      )
    )
  )
)

(defun blocks_in_table  ( / result)
  (setq result (list))
  (vlax-for block
    (vla-get-blocks
         (vla-get-activedocument (vlax-get-acad-object))
      )
    (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (progn
      (setq result (append result (list (vla-get-name block) )))
    ))
  )
  result
)

(defun c:htb  ( / blkname)
  (foreach blkname (blocks_in_table)
    (HatchToBackBlk  blkname)
  )
  (VLA-REGEN *Doc* 1)
  (princ)
)

Share this post


Link to post
Share on other sites
Adju

Hi Emmanuel,

I tried your routine and it worked just fine.

Do you think it would be difficult to create a slight variation of it ? Instead of hatch it could send wipeouts to the back ?

I took a look at the routine and must admit that i'm not in your league... creating/modifying lisp routines... peoples here are very good. So, i have no clue about what to change in order to do it by myself.

 

I heard or found somewhere... i don't remember... :) that when you print something, it print things in order they were ceated. So, when i create a wipeout for a block, i have to move the wipeout away, copy all the elements of the block, erase them and then paste everything back and move the wipeout to it's original place so the wipeout would not be the last element created.

If it's not a big deal, it would be great ! If it's trouble then no problem, i'll continue manually.

Merci !

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...