sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Way to simplify the edges of a square?

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 4 Posters 385 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.
    • C Offline
      confitex architure
      last edited by

      Hi,
      I'm trying to retrieve the 4 vertices of a quadrangle that has divided edges.
      But right now I did not found the way to detect when an edge is the continuation of an other and to bypass the result of the middle vertice.
      Any help would be great.

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        We must assume that the quadrilateral has just 4 corners that are ~90 degrees and the other Vertices are on 'straight' edges.
        You need to test each Vertex.
        Every Vertex will have a pair of Edges.
        These two Edges will each have another 'End' Point [that isn't the tested Vertex].
        For each 'End' Point you now find the Vector from the Vertex to the that 'End' Point.
        If one Edge's Vector isn't the same as [or equal to the 'reverse' of] the other one then the Vertex isn't on a 'side' and it is at a 'corner'...
        .

        TIG

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

          How do you check for these things? Are the assisting functions or is it just pure math?

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

          1 Reply Last reply Reply Quote 0
          • Didier BurD Offline
            Didier Bur
            last edited by

            Hi,
            Do a loop through edges.
            If an edge shares a vertex with another edge and if these two edges are colinear, the vertex you are testing is not a corner.

            Here is the code of such a function that will return an array of corners as Point3d, (no matter how many corners the face has), assuming that parameter "f" is a face entity:

            def corners(f)
              edges=f.edges
              corners=[]
              0.upto(edges.length-1) do |i|
                e=edges.shift
                edges.each do |edge|
                  if edge.start==e.start or edge.end==e.start or edge.start==e.end or edge.end==e.end and not e.line[1].parallel?(edge.line[1])
                    corners.push(e.position)
                  end
                end
              end
              return corners
            end
            

            Erase face "f" and redraw a new face with the Point3d array ☀

            Voilà,

            DB

            1 Reply Last reply Reply Quote 0
            • C Offline
              confitex architure
              last edited by

              It could help to retrieve the vertices of edge from faces that are connected. If an edge of one face do not overlap exactly an adge of another face it just divide these element and it becomes difficult to retrieve the vertices.(I mean before Didier and Tig's reply).
              Thanks Didier and Tig.

              Hope to be back soon with the plugin that takes advantage of this post.

              1 Reply Last reply Reply Quote 0
              • C Offline
                confitex architure
                last edited by

                Didier,
                I made a change because I get an error message in the ruby console about the edge.position in your code

                		edges.each do |edge|
                			if edge.start==e.start or edge.end==e.start or edge.start==e.end or edge.end==e.end and not (e.line[1].parallel? (edge.line[1]))
                				if edge.start==e.start or edge.start==e.end
                					corners.push(edge.start.position)
                				else
                					corners.push(edge.end.position)
                				end
                			end
                		end
                
                

                Would you have done it differently?

                1 Reply Last reply Reply Quote 0
                • Didier BurD Offline
                  Didier Bur
                  last edited by

                  No... 😳 😳 😳

                  DB

                  1 Reply Last reply Reply Quote 0
                  • TIGT Offline
                    TIG Moderator
                    last edited by

                    You need to look in the API methods for various bits... it's all there...

                    Make a list of the loop's vertices.
                    You get a vertex.
                    You get its point in 3D
                    You get the vertex's edges.
                    For the two edges get its other end's vertex and thence its point.
                    You get the vector between the vertex-point and that end-point in turn.
                    You see if vertor1==vertor2 [or its 'reverse'].
                    If they're not 'equal' then it's a corner...
                    .

                    TIG

                    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