InputPoint for Inference
-
I have a tool that requires 3 points. After the first point, the user can use the VCB to enter a length to get the second point, then the third. The problem is, I want to allow inference lock. But view.lock_inference only accepts an InputPoint. However, InputPoint's new method doesn't accept parameters. I can get the points I need using Point3d, but have no way to produce the InputPoint needed for inference lock.
Any ideas? Thanks!
-
The line tool has implemented this functionality, so play with it to get a feel for how it runs. You have to click once to start. Sot he first point is pure inputpoint.
The second point is also an inputpoint. That 2nd point is what is used to feed to the inference (which needs two points). But the 2nd point is not "set" until the user clicks, or enters the number into the VCB manually. So use the inputpoint of the mouse moving around to help set the inference, but don't use it as your 2nd point until the user clicks or enters the value into the VCB.
Does that make any sense? I think I made it sound confusing.....
Chris
-
Unfortunately, it doesn't work the same way.
In linetool, it is creating an inputpoint on mouse click, then when the user enters a length in the VCB, the tool creates the line and that iteration of operation is done, no inference lock necessary. It works in linetool because it only needs 2 points. I need 3 points.what I need is like this:
- Mouse click -> Create InputPoint1
- Mouse moves -> Update InputPoint2
- User types into VCB
- Point created by taking the vector from IP1 to IP2, length from VCB
- up to now, no problem, just like linetool - - Mouse moves -> Update InputPoint3
And here is the problem. I have IP3, but IP2 either doesn't exist or is at the least not in the right place because the user never clicked the mouse in steps 3 & 4, they entered text in the VCB. So I don't have and input point at the real location for Point 2.
Maybe you are suggesting I grab IP2 at the point the user enters text into the VCB. But that would put IP2 at, quite likely, the wrong location, since length along the vector is from the VCB.
-
Find Mirror.rb and see how that copes with three input points...
-
I recommend looking at TIG's script, he's got it all worked out.
What I was getting at is that when you activate your tool, the mouse moving should be creating temporary IP points. As soon as you click, the first one is then stored as point1. Then when you move it again, the movement is creating more temporary IP points. Use the temporary points to help find and lock the inference. There is no need to click. Once the inference is locked using point 1 and the temporary IP point, then allow the user to enter a lnegth into the VCB. That is how the linetool works to get its 2nd point. You'll see that no 2nd click is necessary with the linetool, but it does set inference before the 2nd click, meaning it must be using the mouse cursor location as a temporary 2nd IP point. But it doesn't set point2 until the user enters a length, or clicks.
Seems like it is more similar than you think, but maybe I'm missing the point (thats pretty common).
Chris
-
Ohhh.... I see. I can use the "on-the-fly" InputPoint to perform the inference, but I don't actually need to use it for positioning. Just inference. Since it's all along the same line, no difference! Thanks!
-
Yes, exactly
So use the clicked and set point1 and the temporary IP to align the inference. Then find the vector between those 2 points with
vector = point1.vector between temp_IP
, and when the user enters a value, it should set that vector to the length of the input distance withvector.length = user_input_distance
, and do apoint2 = point1.offset vector
. The syntax is shaky, but that is the idea of how to use a set point, an on-the-fly inputpoint and an input distance to create a second set point.Chris
-
No, wait...I've confused myself. That still isn't what I mean.
Getting the inference for the first segment, between IP1 and pt2 is easy, just as described above. And that's what I've been doing.
But what about inferencing between pt2 and IP3? IP2, where the mouse was when the user entered in the VCB (the top of the line in image 1), may be on the right line for thefirst segment, but isn't on the right line at all for the second segment. If I try to inference lock with IP2 and IP3, that is not at all the same line as pt2 to IP3.As you can see below, pt2 to IP3 is not on the red axis, but IP2 to IP3 is. The inference lock is wrong for the line that I actually want, which is pt2 to IP3, not IP2 to IP3.
So it goes back to the original intent, which is, how do I get an IP (InputPoint) at pt2 in order to get the correct inferencing for the second segment?
-
@TIG: Mirror3_1 doesn't appear to accept input from the VCB. That's what is causing the problem. Just doing it by mouse click is easy because all the clicks generate IP's. But having to generate pt2 programatically allows only the creation of a Point3d, because InputPoint has no method for setting it's 3D coordinate.
Advertisement