Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to simplify selection sets

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
JCprog
304 Views, 5 Replies

How to simplify selection sets

Hello everyone Smiley Happy

 

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)
)

 

5 REPLIES 5
Message 2 of 6
marko_ribar
in reply to: JCprog

(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.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 3 of 6
JCprog
in reply to: marko_ribar

Thanks Marko for your help! It worked perfectly! Smiley Very Happy

Message 4 of 6
_Tharwat
in reply to: marko_ribar

The system variable returns the name of tab ( Model or Layout ) so to call it this way (cons 410 (getvar 'ctab)) is enough .

Message 5 of 6
marko_ribar
in reply to: _Tharwat


@_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, d.i.a. (graduated engineer of architecture)
Message 6 of 6
_Tharwat
in reply to: marko_ribar


@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 .

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost