Automate for selecting all circles & delete from entire drawing

Automate for selecting all circles & delete from entire drawing

sanjayph1111
Explorer Explorer
345 Views
15 Replies
Message 1 of 16

Automate for selecting all circles & delete from entire drawing

sanjayph1111
Explorer
Explorer

I want to automate for selecting all circles of 5mm dia & delete from entire drawing

0 Likes
Accepted solutions (2)
346 Views
15 Replies
Replies (15)
Message 2 of 16

sanjayph1111
Explorer
Explorer

Qselect is not working for this even try to record macros...

0 Likes
Message 3 of 16

sanjayph1111
Explorer
Explorer

Please if anybody can provide me the solution for this

 

0 Likes
Message 4 of 16

cadffm
Consultant
Consultant
Accepted solution

Hi,

 

if you drawing is drawn 1unit=1mm, this is a simple statement to erase all 5diam circles on non-locked Layers in the current space only.

Command: (if (setq ss (ssget "_X" (list'(0 . "CIRCLE")'(40 . 2.5)(cons 410 (getvar 'CTAB)))))(command "_.erase" "_p" ""))

Sebastian

Message 5 of 16

sanjayph1111
Explorer
Explorer

Great ...

Thanks a lot... Its working perfectly... 🙂

0 Likes
Message 6 of 16

sanjayph1111
Explorer
Explorer

Can I make a shortcut key for the same as this is too repeated work... I added ZOMM all also to this one & now if you can provide to make macros for this one, please ...

 

(command "_.zoom" "_a")(if (setq ss (ssget "_X" (list'(0 . "CIRCLE")'(40 . 3.5)(cons 410 (getvar 'CTAB)))))(command "_.erase" "_p" ""))

 

Message 7 of 16

cadffm
Consultant
Consultant

Hi

 

we changed from 5.0 to 7.0 ? okay

 

>" if you can provide to make macros for this one, please ..."

Macro? You can add the line in macros, so what is the problem?

Create a Command-Tool in your Toolpalette or any other Button for Toolbars, menus or Ribbon and add the line.  ^C^C^C(command "_.zoom" "_a");(if (setq ss (ssget "_X" (list'(0 . "CIRCLE")'(40 . 3.5)(cons 410 (getvar 'CTAB)))))(command "_.erase" "_p" ""))

 

>"Can I make a shortcut key"

Shortcut are defined in you CUI

but I can offer edited lines, so after load a new command is available: DelAll7diaCircles

 

 

(defun c:DelAll7diaCircles nil
 (command "_.zoom" "_a")
 (if (setq ss (ssget "_X" (list'(0 . "CIRCLE")'(40 . 3.5)(cons 410 (getvar 'CTAB)))))(command "_.erase" "_p" ""))
 (princ)
)

 

 

 
 

 

 

Sebastian

0 Likes
Message 8 of 16

Kent1Cooper
Consultant
Consultant

@sanjayph1111 wrote:

Qselect is not working for this ....


I'm curious about that -- it should work.  Could you be doing something like giving it a radius where you should be giving it a diameter?

Also, suggestions so far work to remove Circles in only the current space, because the Erase command in an AutoLisp (command) function with object selection can "see" only those.  It would not be difficult to write something to remove them from all spaces in the drawing, if you need that.

Kent Cooper, AIA
0 Likes
Message 9 of 16

cadffm
Consultant
Consultant

Quote: I want to automate for ...

Sebastian

0 Likes
Message 10 of 16

sanjayph1111
Explorer
Explorer

I created shortcut Key also for the same. But the issue is that for some files it works & not all. I checked the dimensions as you can find in attached screenshots...
Why this may happen & how to resolve it.Screenshots.png

0 Likes
Message 11 of 16

sanjayph1111
Explorer
Explorer

Find DXF File as well

0 Likes
Message 12 of 16

Brock_Olly
Collaborator
Collaborator
Accepted solution

Your white circle isn't exactly 7, it's 6.99998600 (set LUPREC variable to 8 and see)
When I edit the property to 7 and run the command it works fine.

Here's Cadffm's command updated to give some tolerance: (0.01)
(command "_.zoom" "_a") (if (setq ss (ssget "_X" (list '(0 . "CIRCLE") (cons 410 (getvar 'CTAB))))) (foreach e (vl-remove-if-not '(lambda (x) (<= (abs (- (cdr (assoc 40 (entget x))) 3.5)) 0.01)) (mapcar 'cadr (ssnamex ss))) (entdel e)))

Message 13 of 16

sanjayph1111
Explorer
Explorer

Please find reference attached AutoCAD DXF file, so that you can find the issue in this...

0 Likes
Message 14 of 16

sanjayph1111
Explorer
Explorer

Perfect...
It's now working to delete all 7mm dia circles...

 

Thanks a lot... 🙂

 

0 Likes
Message 15 of 16

cadffm
Consultant
Consultant

The previous code deletes all 7units dia circles,

tha last code delete all 7units dia circles and circle with dia near to 7units.

 

 

Sebastian

Message 16 of 16

Brock_Olly
Collaborator
Collaborator

The code *was* working, your circles were not exactly 7mm..

0 Likes