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

    Find the position of a specific vertex on a face.

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 4 Posters 6.3k 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.
    • M Offline
      ManuelB
      last edited by

      Hello, 😄

      The method below shows the x, y,z positions of all vertices at the beginning of edges for a selected face.

      Sketchup.active_model.selection.grep(Sketchup;;Face).each{|f|f.edges.each{|e|p e.start.position}}
      

      I wish to know the position of the vertex down right side for a selected face?

      https://i.imgur.com/JTUT9u3.png

      The goal is to find this vertex even if the face is tilted or drawn in any direction.

      It's been a while since I study the class "Edges" and "Faces" in the API without success.

      Thanks for your help.

      Manuel

      1 Reply Last reply Reply Quote 0
      • fredo6F Offline
        fredo6
        last edited by

        You can directly access the vertices of faces

        
        Sketchup.active_model.selection.grep(Sketchup;;Face).each do |face|
           face.vertices.each do |vx|
               puts "VX of face #{face.entityID} = #{vx.position}"
           end
        end
        
        

        By using only edge.start, you may miss some vertices, because some vertices can be at the END of the their edges.

        NOW, there is no way to identify your specific vertex if the face is tilted, unless there is something particular to it (like an angle of its edges).

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

          Work on a single face.
          You can collect all of its vertices in a uniq array, using a method like Fredo's.
          Then find the point pt = face.bounds.min
          Start with a test length that's ridiculously big say 1000.m ?, and initially set vert = nil.
          Then consider the distance from ' pt' to the position of each vertex in turn.
          Use a test along the lines of:
          if distance <= length; vert = vertex; length = distance; end
          After processing all vertices ' vert' will be the one nearest ' pt' 'bottom-left'...
          To find 'top-right' use face.bounds.max, and to find other permutations combine the various xyz values of the two min/max and project the combo-point perpendicularly onto the face.plane too ?

          TIG

          1 Reply Last reply Reply Quote 0
          • TNTDAVIDT Offline
            TNTDAVID
            last edited by

            Hello, ☀

            Try this:

            mod = Sketchup.active_model
            sel = mod.selection
            sommet = []
            sel.grep(Sketchup;;Face).each do |f|
              @pt = f.bounds.min  
              f.edges.each do |e| 
                e.vertices.each do |v| 
                  sommet << v.position 
                end
              end
            end
            p "VERTICES POSITIONS = #{vertices_posy}"
            p "POINT POSITION = #{@pt}"
            

            Then follow the instructions of TIG. 😉

            [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

            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