sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Lock inference to X, Y or Z_

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 4 Posters 924 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
      cjthompson
      last edited by

      basically, just create 2 input points: one at the origin of the line you want to inference to, and another input point offset from that origin along the vector.

      here is a really quick example:

      class TestTool
      	def initialize
      		@ip = Sketchup;;InputPoint.new
      	end
      	def self.add_tool
      		Sketchup.active_model.tools.push_tool(TestTool.new)
      	end
      	def onKeyDown(key,repeat,flags,view)
      		ip1,ip2 = Sketchup;;InputPoint.new,Sketchup;;InputPoint.new
      		origin2d = view.screen_coords([0,0,0])
      		if(key == VK_UP)
      			z2d = view.screen_coords([0,0,100])
      			ip1.pick(view,origin2d[0],origin2d[1])
      			ip2.pick(view,z2d[0],z2d[1])
      			view.lock_inference(ip1,ip2)
      			puts "up"
      		elsif(key == VK_LEFT)
      			y2d = view.screen_coords([0,100,0])
      			ip1.pick(view,origin2d[0],origin2d[1])
      			ip2.pick(view,y2d[0],y2d[1])
      			view.lock_inference(ip1,ip2)
      			puts "left"
      		elsif(key == VK_RIGHT)
      			x2d = view.screen_coords([100,0,0])
      			ip1.pick(view,origin2d[0],origin2d[1])
      			ip2.pick(view,x2d[0],x2d[1])
      			view.lock_inference(ip1,ip2)
      			puts "right"
      		elsif(key == VK_DOWN)
      			view.lock_inference
      			puts "down"
      		end
      	end
      	def onMouseMove(flags,x,y,view)
      		@ip.pick(view,x,y)
      		view.invalidate
      	end
      	def draw(view)
      		@ip.draw(view)
      	end
      end
      
      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        facepalm! 😳

        Yea - use the .pick method! I just got so fixed on looking for a .new method that took a Point3d argument.

        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

          Wait... when you use screen coords like that - don't you risk picking a point that isn't exactly on the axis you want to pick from?
          If the is geometry near by from your first pick point that you offset - won't it pick from the surface of that geometry instead?

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

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

            It looks like it. 😞 although I can't see any way to get an input point from 3d coordinates, so I don't really think it can be avoided.

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

              Back to square one then...

              ..or....

              line = [ip1.position, ip1.position.offset(Z_AXIS)] ip2.project_to_line(line)

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

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

                could you not draw a hidden reference axis for yourself when your tool is invocked then use this as a reference to X,Y,Z?

                β€œ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
                • C Offline
                  cjthompson
                  last edited by

                  well, another thing you could do is to add an edge going along the axis you want, lock the inference from that IP, and delete the edge again.

                  You might have the same problems with geometry getting your way, though.

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

                    @cjthompson said:

                    well, another thing you could do is to add an edge going along the axis you want, lock the inference from that IP, and delete the edge again.

                    how would one get an IP from that?

                    My idea in the previous post isn't working as I want it. I get extra inferring...

                    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

                      Just in case someone comes across this topic again: it is possible to create input points with arbitrary 3d points: http://forums.sketchucation.com/viewtopic.php?f=180&t=14608
                      ip=Sketchup::InputPoint.new( [1,2,3] )
                      or
                      ip=Sketchup::InputPoint.new( Geom::Point3d.new(1,2,3) )

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

                      1 Reply Last reply Reply Quote 0
                      • Chris FullmerC Offline
                        Chris Fullmer
                        last edited by

                        Is that the same idea as it is shown in the View.inputpoint class?

                        http://code.google.com/apis/sketchup/docs/ourdoc/view.html#inputpoint

                        It states you can supply it with a point and/or another inputpoint.

                        Lately you've been tan, suspicious for the winter.
                        All my Plugins I've written

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

                          @chris fullmer said:

                          a point and/or another inputpoint.

                          I only see it referring to InputPoints...

                          And I think the ip it takes as argument are meant for inferring...

                          ...the docs are a wee bit unclear here...

                          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