samifox Posted August 27, 2015 Posted August 27, 2015 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 Quote
samifox Posted August 27, 2015 Author Posted August 27, 2015 This? (if ss (command "_.Erase" ss "")) out mof the box solution well done Tharwat! what about autolisppic solution? Quote
Tharwat Posted August 27, 2015 Posted August 27, 2015 well done Tharwat! 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 ? Quote
samifox Posted August 27, 2015 Author Posted August 27, 2015 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 Quote
Tharwat Posted August 27, 2015 Posted August 27, 2015 yea of course... i like it when you challange me Tharwat! (repeat (sslength ss) (entdel (ssname ss i)) ) but its not working 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] ) Quote
samifox Posted August 27, 2015 Author Posted August 27, 2015 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? Quote
Tharwat Posted August 27, 2015 Posted August 27, 2015 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 Quote
samifox Posted August 27, 2015 Author Posted August 27, 2015 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) Quote
Lee Mac Posted August 27, 2015 Posted August 27, 2015 thanks:thumbsup: is there a way to extract an entity out of the selection set other than ssname? (hate setq i 0) See my tutorial: Selection Set Processing. Quote
Tharwat Posted August 27, 2015 Posted August 27, 2015 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) ) Quote
samifox Posted August 27, 2015 Author Posted August 27, 2015 See my tutorial: Selection Set Processing. Thanks LEE Quote
samifox Posted July 30, 2017 Author Posted July 30, 2017 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? Quote
Lee Mac Posted July 30, 2017 Posted July 30, 2017 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))))) ) ) Quote
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.