vernonlee Posted December 3, 2014 Share Posted December 3, 2014 I came across LISP routine to remove dimension & hatches but not text & leader lines. Anyone with such a routine to delete all text & leaders (including within blocks & nested block) Thanks Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted December 3, 2014 Share Posted December 3, 2014 I came across LISP routine to remove dimension & hatches but not text & leader lines. Anyone with such a routine to delete all text & leaders (including within blocks & nested block) Thanks sorry if im not quite understand normally we use to filter selections, ss then erase, example TEXT , MTEXT (defun c:TEST1 ( / ss) ; TEXT& MTEXT (setq [color="red"]ss[/color] (ssget "_X" '((0 . "*TEXT")))) ;_ end of setq (command "_erase" [color="red"]ss[/color]) (princ) ) ie: a bit study some method ssget here, then you can mod yourself example: filter leader &associated Mtext can try replace the (setq ss ...) to above code in c:TEST1 (setq [color="red"]ss[/color] (ssget "_:L" (list '(-4 . "<OR") '(0 . "LEADER") '(-4 . "<AND") '(0 . "MTEXT") '(102 . "{ACAD_REACTORS") '(-4 . "AND>") '(-4 . "OR>")) ;_ end of list ) ;_ end of ssget ) ;_ end of setq ;example delete entity (without filtering ssget) TEXT, MTEXT, DIMENSION, etc.. (which dxf index 1) (defun c:test2 ( / ss) (if(setq ss (ssget "_X" )) (foreach en (vl-remove-if ''((x) (not(cdr (assoc 1 (entget x))))) (acet-ss-to-list ss)) ; express tool (if en (entdel en)) (princ)) )) ;p/s: this method is not good practice, just an alternative reference ;filter by ssget is the best practice for nested try similar thread HTH Quote Link to comment Share on other sites More sharing options...
vernonlee Posted December 9, 2014 Author Share Posted December 9, 2014 Hi HT. WIll reply in detail when i am back from vacation. Thanks Quote Link to comment Share on other sites More sharing options...
vernonlee Posted December 9, 2014 Author Share Posted December 9, 2014 Basically i am looking for something similar to this for text & leader lines. Below is what i found for hatch & dimension (defun c:DIMDEL ( / d l ) (setq d (vla-get-activedocument (vlax-get-acad-object))) (vlax-for a (vla-get-layers d) (if (eq :vlax-true (vla-get-lock a)) (progn (vla-put-lock a :vlax-false) (setq l (cons a l)) ) ) ) (vlax-for b (vla-get-blocks d) (if (eq :vlax-false (vla-get-isxref b)) (vlax-for o b (if (wcmatch (vla-get-objectname o) "AcDb*Dimension*") (vla-delete o) ) ) ) ) (foreach a l (vla-put-lock a :vlax-true)) (vla-regen d acallviewports) (princ) ) --------------------------------------------------------------------------------------------------------------------- (defun C:HatchDel ()(delete-all-hatch)) (defun delete-all-hatch ( / adoc *error*) (defun *error* (msg) (setvar "MODEMACRO" "") (princ msg) (vla-regen aDOC acactiveviewport) (bg:progress-clear) (bg:layer-status-restore) (princ) ) ;_ end of defun (defun _loc-delete-items () (if (= (vla-get-IsXref Blk) :vlax-false) (progn (setq count 0) (if (> (vla-get-count Blk) 100) (bg:progress-init (strcat (vla-get-name Blk) " :") (vla-get-count Blk) ) ;_ end of bg:progress-init (progn (setvar "MODEMACRO" (vla-get-name Blk)) ) ;_ end of progn ) ;_ end of if (vlax-for Obj Blk (if (= (vla-get-ObjectName Obj) "AcDbHatch") (vl-catch-all-apply 'vla-delete (list Obj)) ) ;_ end of if ) ;_ end of vlax-for (bg:progress-clear) ) ;_ end of progn ) ;_ end of if ) ;_ end of defun (setq aDOC (vla-get-activedocument (vlax-get-acad-object)) ) ;_ end of setq (bg:layer-status-save) (vlax-for Blk (vla-get-Blocks aDOC) (_loc-delete-items) ) (bg:layer-status-restore) (vla-regen aDOC acActiveViewport) (princ) ) ;_ end of defun (defun bg:layer-status-restore () (foreach item *BG_LAYER_LST* (if (not (vlax-erased-p (car item))) (vl-catch-all-apply '(lambda () (vla-put-lock (car item) (cdr (assoc "lock" (cdr item)))) (vla-put-freeze (car item) (cdr (assoc "freeze" (cdr item)))) ) ;_ end of lambda ) ;_ end of vl-catch-all-apply ) ;_ end of if ) ;_ end of foreach (setq *BG_LAYER_LST* nil) ) ;_ end of defun (defun bg:layer-status-save () (setq *BG_LAYER_LST* nil) (vlax-for item (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (setq *BG_LAYER_LST* (cons (list item (cons "freeze" (vla-get-freeze item)) (cons "lock" (vla-get-lock item)) ) ;_ end of cons *BG_LAYER_LST* ) ;_ end of cons ) ;_ end of setq (vla-put-lock item :vlax-false) (if (= (vla-get-freeze item) :vlax-true) (vl-catch-all-apply '(lambda () (vla-put-freeze item :vlax-false)))) ) ;_ end of vlax-for ) ;_ end of defun (defun bg:progress-init (msg maxlen) ;;; msg - ñîîáùåíèå èëè ïóñòàÿ ñòðîêà ;;; maxlen - ìàêñèìàëüíîå êîëè÷åñòâî (setq *BG:PROGRESS:OM* (getvar "MODEMACRO")) (setq *BG:PROGRESS:MSG* (vl-princ-to-string msg)) (setq *BG:PROGRESS:MAXLEN* maxlen) (setq *BG:PROGRESS:LPS* '-1)(princ) ) (defun bg:progress ( currvalue / persent str1 count) (if *BG:PROGRESS:MAXLEN* (progn (setq persent (fix (/ currvalue 0.01 *BG:PROGRESS:MAXLEN*))) ;;;Êàæäûå 5 % (setq count (fix(* persent 0.2))) (setq str1 "") (if (/= count *BG:PROGRESS:LPS*) (progn ;;(setq str1 "") (repeat persent (setq str1 (strcat str1 "|"))) ) ) ;;; currvalue - òåêóùåå çíà÷åíèå (setvar "MODEMACRO" (strcat (vl-princ-to-string *BG:PROGRESS:MSG*) " " (itoa persent) " % " str1 ) ) (setq *BG:PROGRESS:LPS* persent) ) ) ) (defun bg:progress-clear () (setq *BG:PROGRESS:MSG* nil) (setq *BG:PROGRESS:MAXLEN* nil) (setq *BG:PROGRESS:LPS* nil) (setvar "MODEMACRO" (vl-princ-to-string *BG:PROGRESS:OM*)) ;;;(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport) (princ) ) Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted December 9, 2014 Share Posted December 9, 2014 Basically i am looking for something similar to this for text & leader lines. Below is what i found for hatch & dimension (defun c:DIMDEL ( / d l ) ... ... (if (wcmatch (vla-get-objectname o) [color="red"] "AcDb*Dimension*"[/color]) ... ) Try replace it, just by filtering objectname a bit study basic & practise, you get benefited [color="red"]"AcDb*Leader*"[/color] ; leader ,mleader or [color="red"]"AcDb*Text*" [/color]; Text, Mtext Quote Link to comment Share on other sites More sharing options...
vernonlee Posted December 19, 2014 Author Share Posted December 19, 2014 (defun c:DIMDEL ( / d l ) ... ... (if (wcmatch (vla-get-objectname o) [color=red] "AcDb*Dimension*"[/color]) ... ) Try replace it, just by filtering objectname a bit study basic & practise, you get benefited [color=red]"AcDb*Leader*"[/color] ; leader ,mleader or [color=red]"AcDb*Text*" [/color]; Text, Mtext It worked bro! Errr...how to combine leader,text & dimension together?So that it can run in 1 command. I tried combining the above code with different variation but ended with error. Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted December 19, 2014 Share Posted December 19, 2014 It worked bro! Errr...how to combine leader,text & dimension together?So that it can run in 1 command. I tried combining the above code with different variation but ended with error. it's ok you can post error code here, members in forum will assist you. how did you combine? so i just assume your error was due to not separated with commas "AcDb*Leader*,AcDb*Text*,AcDb*Dimension*" Quote Link to comment Share on other sites More sharing options...
vernonlee Posted December 22, 2014 Author Share Posted December 22, 2014 it's ok you can post error code here, members in forum will assist you. how did you combine? so i just assume your error was due to not separated with commas "AcDb*Leader*,AcDb*Text*,AcDb*Dimension*" hahs ya. I did not include comma among other variations i tried. Thanks dude Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.