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

    Pick vertex?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 324 Views 2 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.
    • thomthomT Offline
      thomthom
      last edited by

      I want to be able to pick a vertex, how would I do that? The pickhelper doesn't seem to return vertices.

      Also, I got this little test code:

      
      def pick
      	Sketchup.active_model.select_tool Stix.new
      end
      
      class Stix
      	#def self.onMouseMove(flags, x, y, view)
      	#	
      	#end
      	
      	def onLButtonUp(flags, x, y, view)
      		ph = view.pick_helper
      		ph.do_pick(x, y)
      		picked = ph.all_picked
      		puts 'picked;'
      		puts picked
      	end
      end
      
      

      When I group a cube and click on a point that would be a vertex, all_picked return the group multiple times.

      
      picked;
      #<Sketchup;;Group;0x88c5ce0>
      #<Sketchup;;Group;0x88c5ce0>
      #<Sketchup;;Group;0x88c5ce0>
      #<Sketchup;;Group;0x88c5ce0>
      #<Sketchup;;Group;0x88c5ce0>
      #<Sketchup;;Group;0x88c5ce0>
      
      

      As oppose to this when it's not grouped, or inside the group.

      
      picked;
      #<Sketchup;;Edge;0x8851fe8>
      #<Sketchup;;Edge;0x8851fd0>
      #<Sketchup;;Face;0x88545b0>
      #<Sketchup;;Edge;0x88545e0>
      #<Sketchup;;Face;0x8851fb8>
      #<Sketchup;;Face;0x88545c8>
      
      

      I had expected it to list the group as well as the edges and faces inside it.

      How come I get this result? What's the point in returning the same group multiple times?

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

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

        You should use an InputPoint instead, if you are just interested by the vertex.

        
        ip = Sketchup;;Input.point.new
        
        ip.pick view, x, y
        
        vertex = ip.vertex   #or nil if none
        edge = ip.edge #or nil if none
        face = ip.face   #or nil if none
        
        #use tr * ip.position to have the absolute coords if your vertex is embedded 
        # in groups or components
        
        tr = ip.transformation 
        
        

        redo

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

          Ah! Thanks Fredo!

          If it's nested in multiple groups, do I have to do transformation * transformation on all groups first?

          group1.transformation * group2.transformation * ip.position ?

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

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

            Still curious to why pickhelper returns the group so many times though...

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

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

              No, just use ip.transformationto get the coordinates in the current active_model (it is cumulative).
              You don't have to use the pickhelper, except if you want to know more about the hierarchy of groups and components.

              Fredo

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

                Thanks allot, once more. 👍

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

                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