Hello everyone
I have this code below with selection sets. I need help to simplify/shorten the code. Please help!
(defun c:test (/ s0 s1 s2 s3 s4 s5 s6 s7) (setq s0 (ssget "_X" '((0 . "dimension")))) (command "erase" "p" "") (setq s1 (ssget "_X" '((0 . "TEXT")))) (command "erase" "p" "") (setq s2 (ssget "_X" '((0 . "MTEXT")))) (command "erase" "p" "") (setq s3 (ssget "_X" '((0 . "lwpolyline")))) (command "erase" "p" "") (setq s4 (ssget "_X" '((0 . "line")))) (command "erase" "p" "") (setq s5 (ssget "_X" '((0 . "hatch")))) (command "erase" "p" "") (setq s6 (ssget "_X" '((0 . "leader")))) (command "erase" "p" "") (setq s7 (ssget "_X" '((0 . "circle")))) (command "erase" "p" "") (PRINC) )
Solved! Go to Solution.
Solved by marko_ribar. Go to Solution.
(defun c:test (/ ss) (setq ss (ssget "_X" '((0 . "DIMENSION,TEXT,MTEXT,LWPOLYLINE,LINE,HATCH,LEADER,CIRCLE")))) (command "erase" ss "") (princ) )
But I would supply current active viewport on current layout... Only if you really want to erase all this entities on all layouts and on layers that are off and frozen, your version will be satisfactory...
(defun c:test (/ ss) (setq ss (ssget "_X" (list '(0 . "DIMENSION,TEXT,MTEXT,LWPOLYLINE,LINE,HATCH,LEADER,CIRCLE") (if (= 1 (getvar 'cvport) (cons 410 (getvar 'ctab)) '(410 . "Model"))))) (command "erase" ss "") (princ) )
HTH, M.R.
The system variable returns the name of tab ( Model or Layout ) so to call it this way (cons 410 (getvar 'ctab)) is enough .
@_Tharwat wrote:The system variable returns the name of tab ( Model or Layout ) so to call it this way (cons 410 (getvar 'ctab)) is enough .
Have you tried this with active viewport in paperspace, Tharwat? When you check this, then you'll probably realize why my version is more adequate...
@marko_ribar wrote:
Have you tried this with active viewport in paperspace, Tharwat? When you check this, then you'll probably realize why my version is more adequate...
Since that you considered the viewport into your consideration , I would agree with you that yours is perfect .
Sorry for the inconvenience .