Jump to content

how can i delete all entites which are members in a selection set?


Recommended Posts

Posted

Hi

 

how can i delete all entites which are members in a selection set?

 

(setq ss (ssget '((0 . "DIMENSION") (3 . "AR-DS-50"))))
;_ delete all ss members off the model space

 

Thanks

S

Posted
This?

 

(if ss (command "_.Erase" ss ""))

 

out mof the box solution

well done Tharwat!

 

what about autolisppic solution?

Posted

well done Tharwat!

:D

 

what about autolisppic solution?

 

Cycle though each entity in the selection set then use the function entdel to delete the entity name. ;) I think you should be able to write yours , shouldn't you ?

Posted
:D

 

 

 

Cycle though each entity in the selection set then use the function entdel to delete the entity name. ;) I think you should be able to write yours , shouldn't you ?

 

yea of course... i like it when you challange me Tharwat!

 

(setq ss (ssget '((0 . "DIMENSION") (3 . "AR-DS-50"))) i 0)


(repeat (sslength ss)
 (entdel (ssname ss i))
)

 

but its not working :shock:

Posted
yea of course... i like it when you challange me Tharwat!

 

(repeat (sslength ss)
 (entdel (ssname ss i))
)

 

but its not working :shock:

 

It does not work because the variable i is equal to nothing ;)

 

(repeat (setq i (sslength ss)) [color="gray"];; i = the quantity of selection set[/color]
 (entdel (ssname ss (setq i (1- i)))) [color="gray"];; variable i would be decreased till it is equal to zero logically with the usage of repeat function .[/color]
)

Posted
It does not work because the variable i is equal to nothing ;)

 

(repeat (setq i (sslength ss)) [color="gray"];; i = the quantity of selection set[/color]
 (entdel (ssname ss (setq i (1- i)))) [color="gray"];; variable i would be decreased till it is equal to zero logically with the usage of repeat function .[/color]
)

 

well done Tharwat! what a dummy i am:cry:

 

is there a way to extract an entity out of the selection set other than ssname?

Posted
well done Tharwat! what a dummy i am:cry:

 

is there a way to extract an entity out of the selection set other than ssname?

 

We all being in these situations before , so never give up to reach your goal :)

Posted
We all being in these situations before , so never give up to reach your goal :)

 

thanks:thumbsup:

 

is there a way to extract an entity out of the selection set other than ssname? (hate setq i 0)

Posted
thanks:thumbsup:

 

is there a way to extract an entity out of the selection set other than ssname? (hate setq i 0)

 

There are many and here is one using the function ssdel to delete the enity name from the selection set while cycling :

 

(repeat (sslength ss)
   (setq obj (ssname ss 0))
   (entdel obj)
   (ssdel obj ss)
   )

  • 1 year later...
Posted

hi

 

im using this code to remove all entites based on type.

 

(defun removeByType(typ)
 (setq ss (ssget "X" (list(cons 0 typ))))
 (if ss (command "_.Erase" ss ""))
)

 

now i want to let the user to set the selection scope,

 

if nothing is selected
   remove all typ from database
   filter typ and delete 

 

how can i set this kind of condition?

Posted

Perhaps something like this?

 

(defun c:test ( / ent )
   (if (setq ent (car (entsel "\nSelect type of object to delete <all>: ")))
       (eraseselection  (list "_X" (list (assoc 0 (entget ent)))))
       (eraseselection '("_X"))
   )
   (princ)
)
(defun eraseselection ( arg / idx sel )
   (if (setq sel (apply 'ssget arg))
       (repeat (setq idx (sslength sel)) (entdel (ssname sel (setq idx (1- idx)))))
   )
)

 

It could also be written:

(defun c:test ( / ent )
   (eraseselection
       (cons "_X"
           (if (setq ent (car (entsel "\nSelect type of object to delete <all>: ")))
               (list (list (assoc 0 (entget ent))))
           )
       )
   )
   (princ)
)
(defun eraseselection ( arg / idx sel )
   (if (setq sel (apply 'ssget arg))
       (repeat (setq idx (sslength sel)) (entdel (ssname sel (setq idx (1- idx)))))
   )
)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...