Finding the center of circles
-
Hi All-
I imported a rhino model, but as a sketchup file. https://www.dropbox.com/s/9o6u1e0fy6qd82z/Screenshot%202015-10-03%2016.44.07.png?dl=0
I intersected it with a plane to get this file (attached).I need to find the center of all these circles so I can make squares based on that reference.
How do I find the center of these circles ?
Thank you,
-Revel
-
Those imported shapes aren't actually circles/arcs - although they look like it.
They are actually a collection of short edges, approximating to a circle.There is a tool in the PluginStore which you can use to find the center of such forms...
Download its RBZ from here:
http://sketchucation.com/pluginstore?pln=clf_arc_centerpoint_finder
Read about it here:
http://sketchucation.com/forums/viewtopic.php?p=155504#p155504 -
@revelever said:
...... I need to find the center of all these circles so I can make squares based on that reference.
How do I find the center of these circles ? ......
The nomber of segments in your circles varies from 117 to 186. And per segmented "circle" the segment lengths arent all the same.
In general (and per circle) you can draw two lines perpendicular to two segments, running from their respective midpoints. Where these lines intersect is the circle center.
In your case you'll only get an appriximation of the center. probably due to the way shapes were imported, i.e. not as segmented circles but deformated segmented circles. Who knows?
Oops, TIG beat me to it.
-
@revelever said:
Hi All-
I imported a rhino model, but as a sketchup file. https://www.dropbox.com/s/9o6u1e0fy6qd82z/Screenshot%202015-10-03%2016.44.07.png?dl=0
I intersected it with a plane to get this file (attached).I need to find the center of all these circles so I can make squares based on that reference.
How do I find the center of these circles ?
Thank you,
-Revel
Since the "circle" edges define a face, they must be closed and co-planar. Perhaps the easiest way would be just to use the center of the faces bounds.
m=Sketchup.active_model;e=m.entities;s=m.selection;s.grep(Sketchup;;Face).each{|f|p=f.bounds.center;e.add_cpoint(p)}
-
Thank you all for the excellent solutions.
@sdmitch wow, um thats amazing. can you elaborate on how you did that a tad? ruby console from within sketchup?
-
@revelever said:
Thank you all for the excellent solutions.
@sdmitch wow, um thats amazing. can you elaborate on how you did that a tad? ruby console from within sketchup?
Yes, After selecting the faces, you can copy and paste the code into the Ruby Console to execute it.
-
I don't know Ruby, but these steps should be possible with it...
- create center point for each selected face (see above)
- loop all center points
- calculate radius from face area
- delete edges
- create new circle with centerpoint at cpoint and calculated radius
-
@jim4366 said:
Very good, thank you so much. I run into this exact situation all the time converting imported .stl files. Circles usually come in broken with hundreds of segments. Now hoping it's not too much to ask, but would it be possible that, having the center point, could those segments that made up the circle be deleted and replaced with a real sketchup circle? In one swoop? Just a standard 24 segment circle would be fine. A circle un-exploder?
Modified code
m=Sketchup.active_model;e=m.entities;s=m.selection;s.grep(Sketchup;;Face).each{|f|p=f.bounds.center;e.add_cpoint(p);n=f.normal;r=p.distance(f.vertices[0].position);e.erase_entities(f.edges);e.add_circle(p,n,r)}
Or,copy attached plugin to Plugins folder. You will need to supply your own icons for the toolbar created.
Advertisement