View Full Version : Can you explode all Polylines?
ReachAndre
2007-07-10, 10:20 PM
Hello all,
I am looking for a way, using lisp, to explode all polylines which are not on frozen or locked layers.
I know I can gho through "quick select" I just do not find "Quick select" so quick.
Any help would be useful.
Thank you all in advance,
Andre
CAB2k
2007-07-11, 06:19 AM
Try this: [current space only]
(defun c:test (/ ss)
(if
(setq
ss (ssget "A"
(list (cons 0 "POLYLINE,LWPOLYLINE") (cons 410 (getvar "ctab")))
)
)
(vl-cmdf "explode" ss "")
)
(princ)
)
kpblc2000
2007-07-11, 07:22 AM
One more variant :)
(defun c:explplines (/ *kpblc-activedoc*
_kpblc-error-catch _kpblc-layer-status-restore
_kpblc-layer-status-save
)
(defun *error* (msg)
(_kpblc-layer-status-restore)
(vla-endundomark *kpblc-activedoc*)
(princ msg)
(princ)
) ;_ end of defun
(defun _kpblc-error-catch (protected-function
on-error-function
/
catch_error_result
)
(setq catch_error_result (vl-catch-all-apply protected-function))
(if (and (vl-catch-all-error-p catch_error_result)
on-error-function
) ;_ end of and
(apply on-error-function
(list (vl-catch-all-error-message catch_error_result))
) ;_ end of apply
catch_error_result
) ;_ end of if
) ;_ end of defun
(defun _kpblc-layer-status-restore (/ item)
(if *kpblc-list-layer-status*
(progn
(foreach item *kpblc-list-layer-status*
(_kpblc-error-catch
'(lambda ()
(vla-put-freeze (car item) (cdr (assoc "freeze" (cdr item))))
) ;_ end of LAMBDA
nil
) ;_ end of _kpblc-error-catch
(_kpblc-error-catch
'(lambda ()
(vla-put-lock (car item) (cdr (assoc "lock" (cdr item))))
) ;_ end of LAMBDA
nil
) ;_ end of _kpblc-error-catch
) ;_ end of foreach
) ;_ end of progn
) ;_ end of if
(setq *kpblc-list-layer-status* nil)
) ;_ end of defun
(defun _kpblc-layer-status-save (layers-on / item)
(vlax-for item (vla-get-layers *kpblc-activedoc*)
(setq *kpblc-list-layer-status*
(append *kpblc-list-layer-status*
(list
(list item
(cons "freeze" (vla-get-freeze item))
(cons "lock" (vla-get-lock item))
) ;_ end of list
) ;_ end of list
) ;_ end of append
) ;_ end of setq
(if layers-on
(progn
(_kpblc-error-catch
'(lambda ()
(vla-put-freeze item :vlax-false)
) ;_ end of lambda
nil
) ;_ end of _kpblc-error-catch
(vla-put-lock item :vlax-false)
) ;_ end of progn
) ;_ end of if
) ;_ end of vlax-for
) ;_ end of defun
(vl-load-com)
(vla-startundomark
(setq *kpblc-activedoc* (vla-get-activedocument (vlax-get-acad-object)))
) ;_ end of vla-startundomark
(_kpblc-layer-status-save nil)
(vlax-for space (vla-get-blocks *kpblc-activedoc*)
(if (wcmatch (strcase (vla-get-name space)) "*_SPACE*")
(vlax-for subent space
(if (wcmatch (strcase (vla-get-objectname subent)) "ACDB*POLYLINE")
(_kpblc-error-catch
(function
(lambda ()
(vla-explode subent)
(vla-erase subent)
) ;_ end of lambda
) ;_ end of function
'(lambda (x)
(princ (strcat "\nCan't explode or erase entity..."))
) ;_ end of lambda
) ;_ end of _kpblc-error-catch
) ;_ end of if
) ;_ end of vlax-for
) ;_ end of if
) ;_ end of vlax-for
(_kpblc-layer-status-restore)
(vla-endundomark *kpblc-activedoc*)
(princ)
) ;_ end of defun
---
Edited: this code [should] explode all lightweight- and 3d-polylines in any space (model, paper...) I didn't test it in full mode :(
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.