Lock inference to X, Y or Z_
-
I'm trying to recreate inference locking like SU's native tools.
Shift to lock is fine, just pass the input point from the cursor to
view.lock_inference
.But how does one lock to the X, Y or Z axis? Since
view.lock_inference
only accepts InputPoints I don't see how one would do this. -
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
-
facepalm!
Yea - use the
.pick
method! I just got so fixed on looking for a .new method that took a Point3d argument. -
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? -
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.
-
Back to square one then...
..or....
line = [ip1.position, ip1.position.offset(Z_AXIS)] ip2.project_to_line(line)
-
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?
-
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.
-
@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...
-
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) )
-
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.
-
@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...
Advertisement