sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Exploded circle not circle anymore... (request code or idea)

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 4 Posters 869 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N Offline
      NewOne
      last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        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...

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • N Offline
          NewOne
          last edited by

          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 πŸ˜„)

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            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...

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • N Offline
              NewOne
              last edited by

              @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.

              1 Reply Last reply Reply Quote 0
              • X Offline
                xrok1
                last edited by

                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.


                Capture.JPG

                β€œThere are three classes of people: those who see. Those who see when they are shown. Those who do not see.”

                http://www.Twilightrender.com try it!

                1 Reply Last reply Reply Quote 0
                • jeff hammondJ Offline
                  jeff hammond
                  last edited by

                  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.

                  http://homepage.mac.com/jeffhammond/.Public/scf/find_radius.jpg

                  dotdotdot

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    NewOne
                    last edited by

                    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:0x40f86e0

                    but for an exploded circle i got
                    24
                    #Sketchup::Edge:0x3dbd9a8
                    nil

                    The 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 😒

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement