How do I delete all objects outside of a boundry?
I am trying to fill a large cricle with an array of smaller cricles. I want to automatically delete all the smaller circles that are outside of the larger cricle. See attached image to understand what I mean.
I am using AutoCAD 2015
@aabufl wrote:How do I delete all objects outside of a boundry?
I am trying to fill a large cricle with an array of smaller cricles. I want to automatically delete all the smaller circles that are outside of the larger cricle. See attached image to understand what I mean.
I am using AutoCAD 2015
One answer to that is hiding in the code in
http://forums.autodesk.com/t5/autocad-2013-2014-2015/circle-packing-algorithm/m-p/4949186#M48674
--
Hello from France
Welcome to the Autodesk/AutoCAD Forums !
Please remind that I am not at all a Lisp/VLisp programmer ...
To do your job, I use a beautiful french routine "Special_Selections" from (gile) Gilles ! ... ...
1) Please load the joined routine with APPLOAD ...
2) Look at the beginning of the routine with "NOTEPAD.exe" to see the new select available commands ...
SSOC, SSOF, SSL, SSC, INV_SEL, etc
3) Important : Assuming that ALL concerned entities are on UNLOCKED layers and that ALL OTHERS layers are LOCKED !!!
4) Command : SSOC
Then Click on the Circle or the closed Pline or the closed Ellipse
Or maybe SSOF (for standard Windows selection) - SSOC is Capture Windows Selection ...
5) Command: INV_SEL
To invert the Selection
6) Command : ERASE
Very important that ALL UNCONCERNED Layers are LOCKED !!
Is it ok for you ?
THKS to Gilles (gile) because I am using very often : SSOC, SSOF, SSL, SSC, INV_SEL, etc
Patrice BRAUD
This has come up several times before, sometimes involving a Polyline as a boundary but probably also as applicable to a Circle == there may be some that can use either. Put something like "erase all outside" or "delete all outside" into the Search window, and you'll get lots of thread to look into.
Wow thanks. The attached LISP program worked great! I thought it wouldn't work because the smaller cricles are defined as blocks. But it worked perfect. Thank you.
I have few more questions related to this.
1) Is there such thing as a "Fill Array"? What I mean is, can I select the small cricle (block), and fill the bigger circle using the Array command while also difing the paramters such as pitch? The program should only fill up to the border of the bigger circle. Nothing outside.
2) I am expereincing that some operations in AutoCAD are slow with the design I am making. The file is turning out to be very large ~10MB. What I am trying to acheive is filling a big circle with smaller circles. The small cricles are polygons with 50 sides. I created a block of the smaller cricle, then I usee the array command to fille the bigger circle. After doing all of this, I notice my file becomes very big and AutoCAD starts to slow down. The big circle is 20mm diameter and small circles are 100um diamter.
The later routine of mine in the link that Martti posted can be modified pretty easily to do that, if you like. It uses spheres to fill the base end of a vertical cylinder, and then goes on to line the walls and the top, but it would be a simplification of the first part only to merely do Circles inside a bigger Circle. It packs them in a triangular arrangement for maximum density, but again, it wouldn't be hard to change it to a rectangular arrangement. Try it to see what it does, and see whether you think an adaptation would suit your needs. [I don't know what you mean by "difing," or what "pitch" would mean in relation to your illustration....]
You might also look into the SuperHatch Express Tool [if it's still an Express Tool in later versions than I have here].
[EDIT: That routine also packs them in touching each other, but could be adjusted to space them however you prefer.]
Hello from France
Maybe you could use a pseudo circle Hatch (regular polygons) !?
Please look at this Topic :
And try the hatch Pattern : G_Circle_05 ... coming from with my 1st answer ...
Patrice BRAUD
@braudpat wrote:
....
Maybe you could use a pseudo circle Hatch (regular polygons) !?
....
That raises the question of whether the Circles [or Blocks] represent something like objects that are always whole, so that you would be able to count a quantity of them, or something. If they had originally asked to eliminate all small Circles fully outside the big Circle and Trim all those that cross it, the result would be like using a Hatch pattern. If they want to have only those that fit fully inside the big Circle, a Hatch pattern won't do [and neither would my SuperHatch suggestion].
Is there a way I can modify the SSOC command to also include objects that are touching the circle/pline/ellipse? Currently the command only selects objects "inside" of the circle, not the ones touching the circle also.
I don't know anything about LIPS. I looked at the code for SSOC but, I don't understand it or know how to modify it.
I found out the command, FS, fast select selects all the objects touching the circle. The issue with this command is that it will only select the touch objects visible on the screen. What I mean is that if I zoom in all the way, it won't selects the objects touching the cricle which are not in the view.
Hi aabufl,
if I understand correctly your goal, try this quick and dirty code.
It's a slooowww code!
(defun c:demo (/ BC BCEN BRAD CLGT FUZZ I LGT LST N NCD NLGT NM OLD-OSM PT1 SC SCEN SPC SRAD SS ST ) (if (and (setq BCen (getpoint "\nEnter Big Circle center point: ")) (setq BRad (getdist BCen "\nSpecify Big Circle radius: ")) (setq SRad (getdist "\nEnter Small Circle radius: ")) (setq spc (getdist "\nEnter the distance between Small Circles: ")) );; and (progn (setq old-osm (getvar 'OSMODE)) (setvar 'OSMODE 0) (command "_.undo" "G") (command "_.circle" BCen BRad) (setq BC (entlast) fuzz (/ (+ (* SRad 2) spc) 10) Clgt (vlax-curve-getdistatparam BC (vlax-curve-getendparam BC)) n (1+ (fix (/ Clgt fuzz))) i (/ Clgt n) st 0.0 ) (repeat n (setq pt1 (trans (vlax-curve-getPointAtDist BC (setq st (+ st i))) 0 1) lst (cons pt1 lst) ) );; repeat (setq lgt (* BRad 2) nm (/ (- lgt (* SRad 2)) (+ spc (* SRad 2))) ) (if (zerop (- nm (fix nm))) (setq nm (1+ (fix nm))) (setq nm (+ (fix nm) 2)) ) (setq nlgt (+ (* spc (1- nm)) (* (* SRad 2.0) nm)) ncd (- (/ nlgt 2) SRad) SCen (list (- (car BCen) ncd) (- (cadr BCen) ncd)) ) (command "_.circle" SCen SRad) (setq ss (ssadd) SC (entlast) ) (ssadd SC ss) (command ".-array" SC "" "_R" nm nm (+ spc (* SRad 2.0)) (+ spc (* SRad 2.0)) ) (while (setq SC (entnext SC)) (ssadd SC ss) ) (command "_.zoom" "_E") ;; change "_CP" to "_WP" for not include the objects that are touching the circle (command "_.erase" ss "_R" "_CP") (foreach p lst (command p) ) (command "") (command "") (command "_.zoom" "_P") (command "_.undo" "E") (setvar 'OSMODE old-osm) );; progn );; if (princ) )
HTH
Henrique
Hi aabufl,
this code version uses polygons, instead of small circles...
It's even a sloowweerr code!
(defun c:demo1 (/ BC BCEN BRAD CLGT FUZZ I LGT LST N NCD NLGT NM NSid OLD-OSM PT1 SC SCEN SPC SRAD SS ST ) (if (and (setq BCen (getpoint "\nEnter Big Circle center point: ")) (setq BRad (getdist BCen "\nSpecify Big Circle radius: ")) (setq SRad (getdist "\nEnter Small Circle radius: ")) (setq NSid (getint "\nEnter Small Circle number of sides: ")) (setq spc (getdist "\nEnter the distance between Small Circles: ")) );; and (progn (setq old-osm (getvar 'OSMODE)) (setvar 'OSMODE 0) (command "_.undo" "G") (command "_.circle" BCen BRad) (setq BC (entlast) fuzz (/ (+ (* SRad 2) spc) 10) Clgt (vlax-curve-getdistatparam BC (vlax-curve-getendparam BC)) n (1+ (fix (/ Clgt fuzz))) i (/ Clgt n) st 0.0 ) (repeat n (setq pt1 (trans (vlax-curve-getPointAtDist BC (setq st (+ st i))) 0 1) lst (cons pt1 lst) ) );; repeat (setq lgt (* BRad 2) nm (/ (- lgt (* SRad 2)) (+ spc (* SRad 2))) ) (if (zerop (- nm (fix nm))) (setq nm (1+ (fix nm))) (setq nm (+ (fix nm) 2)) ) (setq nlgt (+ (* spc (1- nm)) (* (* SRad 2.0) nm)) ncd (- (/ nlgt 2) SRad) SCen (list (- (car BCen) ncd) (- (cadr BCen) ncd)) ) (command "_.polygon" NSid SCen "_I" SRad) (setq ss (ssadd) SC (entlast) ) (ssadd SC ss) (command ".-array" SC "" "_R" nm nm (+ spc (* SRad 2.0)) (+ spc (* SRad 2.0)) ) (while (setq SC (entnext SC)) (ssadd SC ss) ) (command "_.zoom" "_E") ;; change "_CP" to "_WP" for not include the objects that are touching the circle (command "_.erase" ss "_R" "_CP") (foreach p lst (command p) ) (command "") (command "") (command "_.zoom" "_P") (command "_.undo" "E") (setvar 'OSMODE old-osm) );; progn );; if (princ) )
HTH
Henrique
@aabufl wrote:
I am trying to fill a large cricle with an array of smaller cricles. I want to automatically delete all the smaller circles that are outside of the larger cricle.
@martti.halminen wrote:One answer to that is hiding in the code in
http://forums.autodesk.com/t5/autocad-2013-2014-2015/circle-packing-algorithm/m-p/4949186#M48674@Kent1Cooper wrote:
The later routine of mine in the link that Martti posted can be modified pretty easily to do that, if you like. ....
Here ya go -- I modified it accordingly. No need to Array too many and remove all those outside the Circle; you can just fill the larger Circle with smaller ones directly. I included the option of whether to array them in a rectangular or triangular pattern, and to specify a gap distance between them. Read the notes at the top of the file. Lightly tested.
For the, Special_Selections__US_English_GC_2011_11.lsp program, I found out that the SSOF command includes all the objects that are touching the cricle! This command worked great!
@Kent1Cooper, your CircleFillCircle command works awesome! It is very quick and gets the job done very fast! Amazing! Is it possible to modify the program to instead of filling the big cricle with another cricle, it will fill the big circle with a selected object/Block with the desired spacing/arrangement (rectrualar or triangular).
The reason for this is because, currently, I define the small cricle as a block so that way I can change its properities later. For example, the cricle can be turned into a start, or a triangle, or any other shape. In addition, I currenlty don't build the cricle with the circle command. I build it using the polygon command. The reason for this is because the DXF fille will be converted to another file format where all objects need to be a polygon.
If its not possible, then thats fine also. You guys help me a lot! I really appreciate the help!
@aabufl wrote:
.... Is it possible to modify the program to instead of filling the big cricle with another cricle, it will fill the big circle with a selected object/Block with the desired spacing/arrangement (rectrualar or triangular).
....
Yes, it is certainly possible. For a Block, if it is defined with its effective radius as one drawing unit, it would be a rather simple change, using the User's specified radius as the Scale Factors in an Insertion, instead of as the Radius of a Circle. Or for any User selection or Block that would always be Pasted in or Inserted at Scale Factors of 1, it would be a different but also not difficult change, but I would want to know whether the User could specify the center-to-center spacing of the Inserts or Pastes, rather than the size and the amount of space between them, as the current routine does with Circles. [The space-between approach is possible, for example using bounding boxes to determine the size of the Block or selection, but if that is not circular, the space between would usually come out differently in different directions in a triangular array.]