Author Topic: Delete Objects on Layers from List  (Read 8658 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Delete Objects on Layers from List
« Reply #30 on: August 28, 2006, 05:22:42 PM »
I'm looking into this right now.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Delete Objects on Layers from List
« Reply #31 on: August 28, 2006, 05:37:38 PM »
This works now.  I tested it.  Sorry about that.
Code: [Select]
(defun DeletLays_ExplodeBlk (Doc LayList BlkList / cnt)


(defun ExplodeList (ObjList BlkList / NewObjList)

(foreach Obj ObjList
 (if
  (and
   (= (vla-get-ObjectName Obj) "AcDbBlockReference")
   (vl-position
    T
    (mapcar
     '(lambda (y)
      (wcmatch (strcase (vla-get-Name Obj)) (strcase y))
     )
     BlkList
    )
   )
  )
  (if
   (vl-catch-all-error-p
    (setq NewObjList (vl-catch-all-apply 'vlax-invoke (list Obj "Explode")))
   )
   (setq cnt (1+ cnt))
   (progn
    (vla-Delete Obj)
    (ExPlodeList NewObjList BlkList)
   )
  )
 )
)
(princ)
)
;------------------------------------------------------------------------------
(setq cnt 0)
(vlax-for Lo (vla-get-Layouts Doc)
 (vlax-for Obj (vla-get-Block Lo)
  (cond
   ((vl-position T (mapcar '(lambda (x) (wcmatch (strcase (vla-get-Layer Obj)) (strcase x))) LayList))
    (vla-Delete Obj)
   )
   ((and
     (= (vla-get-ObjectName Obj) "AcDbBlockReference")
     (vl-position
      T
      (mapcar
       '(lambda (y)
        (wcmatch (strcase (vla-get-Name oBJ)) (strcase y))
       )
       BlkList
      )
     )
    )
    (if
     (vl-catch-all-error-p
      (setq NewObjList (vl-catch-all-apply 'vlax-invoke (list Obj "Explode")))
     )
     (setq cnt (1+ cnt))
     (progn
      (vla-Delete Obj)
      (ExPlodeList NewObjList BlkList)
     )
    )
   )   
  )
 )
)
(princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Delete Objects on Layers from List
« Reply #32 on: August 28, 2006, 05:40:45 PM »
Code: [Select]
(defun c:tst  (/ ss)
  (if (setq ss
     (ssget
       (list (cons 8 "A-ARE*,A-DIM*,A-NOT*,A-PAT*,A-SHT*,A-SYM*")
     (cons 2 "UT*"))))
    (progn
      (setvar "qaflags" 1)
      (command "_.explode" ss "")
      (setvar "qaflags" 0))))

GDF

  • Water Moccasin
  • Posts: 2081
Re: Delete Objects on Layers from List
« Reply #33 on: August 28, 2006, 05:41:52 PM »
(vlar-yourwelcome Gary)

Not sure if it will work with ObjectDBX though

Alan

I tried this also. Works now with the qaflags (as per Luis suggestion)

Code: [Select]
(defun exp_on_layer (layers / ss)
  (setvar "qaflags" 1)
  (if (setq ss (ssget "_all" (list (cons 8 layers))))
    (vl-cmdf "_.explode" ss "")
  )
  (setvar "qaflags" 0)
)

(defun del_on_layer (layers / ss)
  (if (setq ss (ssget "_all" (list (cons 8 layers))))
    (vl-cmdf "_.erase" ss "")
  )
)

(defun C:TEST ()
  (exp_on_layer "0-XREF")
  (del_on_layer "A-ALT-WIND-2,A-ALT-WIND-3,A-ARE*,A-DIM*,A-NOT*,A-PAT*,A-SYM*,A-SHT*,DEF*,0-XREF,*NOTE")
)

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Delete Objects on Layers from List
« Reply #34 on: August 28, 2006, 05:51:23 PM »
Tim

Works great now...you da man.

This works now.  I tested it.  Sorry about that.

Thank you. I like this version over Alan's because it can be used by objectdbx.

Anyway, I still have to fine tone it and add in the objectdbx code. Will post it
when I get it all togeher.

This routine is a big time saver.

I can now put up my "easy" button and get back to work.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Delete Objects on Layers from List
« Reply #35 on: August 28, 2006, 05:56:45 PM »
Tim

Works great now...you da man.

This works now.  I tested it.  Sorry about that.

Thank you. I like this version over Alan's because it can be used by objectdbx.

Anyway, I still have to fine tone it and add in the objectdbx code. Will post it
when I get it all togeher.

This routine is a big time saver.

I can now put up my "easy" button and get back to work.

Gary
Happy to help.  :wink:
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.