Author Topic: Deleting a Hatch or Solids in a block using LISP  (Read 4845 times)

0 Members and 1 Guest are viewing this topic.

AVCAD

  • Guest
Deleting a Hatch or Solids in a block using LISP
« on: June 05, 2014, 11:14:43 AM »
Maybe someone here can help me out with this...

I am so tired of having to go through drawings and qselect and blockedit objects that have hatches that are on layer 0 and cant be deleted or easily changed to a different layer so I can change the color to have it print "lighter"

SO...I am trying to create this LISP routine to basically just select all Hatches, Solids and Wipeouts in the drawings and delete them, which works but I need to do this to blocks as well which is where I am running into the problem.

Code: [Select]
(defun c:shf ()
(wo)
  (ht)
    (sd)
  (delbht)
(princ "\nAll Hatches, Wipeout & Solids have been deleted!")
(princ)
  )

(defun wo (/)
   (Setq wo (ssget "_x" '((0 . "WIPEOUT"))))
(command "_.erase" wo "")
)

(defun ht (/)
   (Setq ht (ssget "_x" '((0 . "HATCH"))))
(command "_.erase" ht "")
)

(defun sd (/)
   (Setq sd (ssget "_x" '((0 . "SOLID"))))
(command "_.erase" sd "")
)

(defun delbht ()
   (setq Block1 (tblnext "BLOCK" T))
   (setq Bname1 (cdr (assoc -2 Block1)))
(Fixh Bname1)
    (princ)
);defun
;;-----------------------
(defun Fixh ()
  (Setq ht2 (ssget "_x" '((0 . "HATCH"))))
(command "_.erase" ht2 "")
(princ)
);defun

Any help would be greatly appreciated

kpblc

  • Bull Frog
  • Posts: 396
Re: Deleting a Hatch or Solids in a block using LISP
« Reply #1 on: June 05, 2014, 11:44:56 AM »
Sorry for my English.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Deleting a Hatch or Solids in a block using LISP
« Reply #2 on: June 05, 2014, 11:51:19 AM »
Try this UNTESTED routine .

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ doc)
  2.                       doc (vla-get-ActiveDocument (vlax-get-acad-object))
  3.                     )
  4.                   )
  5.     (if (and (eq :vlax-false (vla-get-islayout bks))
  6.              (eq :vlax-false (vla-get-isXref bks))
  7.         )
  8.       (vlax-for obj bks
  9.         (if (and (wcmatch (vla-get-objectname obj)
  10.                           "AcDbSolid,AcDbHatch,AcDbWipeout"
  11.                  )
  12.                  (vlax-write-enabled-p obj)
  13.             )
  14.           (vla-delete obj)
  15.         )
  16.       )
  17.     )
  18.   )
  19.   (vla-regen doc AcAllViewports)
  20.   (princ)
  21.  
  22.  
« Last Edit: June 05, 2014, 11:57:00 AM by Tharwat »