Exploded circle not circle anymore... (request code or idea)
-
Hello masters of ruby!
Can it be done?
I mean a circle or arc once exploded will not behave as a circle anymore... neither ceter inference, nor diameter dimension even if use weld.rb on it. How and where is stored that information which tells SketchUp that a specific geometry is circle? And can e exploded circle (arc) to be converted back? (please don't joke saying "use UNDO after explode" )Thank you very much for any idea!
-
When you create an Circle or Arc you create an ArcCurve object which contains the information which SU uses to pick inference from. That object is built up from several Edges.
However, once it's exploded it's difficult reverse the process as all you have is a series of Edges. Though, it could be possible to take a selection of edges, which represent a Circle or Arc and calculate it's radius and centre point.
In theory:
If you have a selection of edges making up an Arc,
you start by taking two edges and work out the angle between them,
then you take the angle and divide it by two.If we draw a line along that angle on both ends of one edge we'd get the centre point where they intersect.
Now it should be possible to calculate the centre point using trigonometry. We have one edge length, we have all the angles.With the centre point and radius, we'd then have to calculate the length of the arc by using the whole collection of edges.
...in theory...
-
Yes thomthom, this is simple and cheating SketchUp. It can be done like this, but I was wondering if that array of segments can not be converted in ArcCurve object. Perhaps someone from Google reads this and makes something magic (like a new update for SU7 where curve exploding can be reversed )
-
What I wrote was just thinking out loud how a script would work. I'm a bit busy with other projects at the moment, otherwise I'd give it a bash. But maybe someone else chimes in.
...wonder where Chris is... He's been on a plugin frenzy lately... -
@thomthom said:
What I wrote was just thinking out loud how a script would work. I'm a bit busy with other projects at the moment, otherwise I'd give it a bash. But maybe someone else chimes in.
...wonder where Chris is... He's been on a plugin frenzy lately...What you said is not hard to do, but not what I want. I could do that by myself... I just hate cheating . Looking for something "straight". On the other hand, your ideea doesn't resolve dimensioning problem. Even I have a center point, I still can not attach Diameter dimension.
-
whats a ruby if not automatic cheating?
if you group your exploded circle, you can then draw an arc on top of it and use center point ruby.
-
i know this isn't what you're asking for newone.
this is what i do when faced with finding an unrecognized arc's centerpoint.. it's definitely a workaround but it's fast and painless.. all done via inferencing. you need at least 3 segments of an arc for this to work.
-
I played around with Curve class methods
model = Sketchup.active_model edges = Sketchup.active_model.selection first_edge = edges[0] curve = first_edge.curve puts edges.count puts first_edge puts curve
and for a selected circle the output was:
24
#Sketchup::Edge:0x3fc8cc0
#Sketchup::ArcCurve:0x40f86e0but for an exploded circle i got
24
#Sketchup::Edge:0x3dbd9a8
nilThe only conclusion is that add_circle method add some extra information (like center point and radius) to the circle object. And that makes the difference. One way could be to redraw selected segments with circle or arc. I'll think about this.
First select wanted segments then compute the point wehere vectors perpendicular on edges intersect. Now distance from that point to a segment's vertex is the radius. First vertex on edges[0] and last vertex on edges[-1] can help to find the starting and ending angle. In the end, edges.count represents the number of segments for add_arc. Now selected segments can be replaced with an ArcCurve object.
One thing remains: to check if selected edges were part of a face. If not, just redraw the arc. But if the face exists, i think an array must be created with all vertexes to redraw the face. Ok, things can become messy if selection contains other strange entities... but it can be refined. grrr...I think those guys from Google could make a lot of things more transparent here... and not just here
Advertisement