Lisp getpoint (not finished!)
-
Hi all!
I try to do a function like "GETPOINT" Lisp function.
I have one problem... I use a class method to do this function. It works great (I have not yet transformed into sub-function (or semi-invoked function), which may suspend the main function) but I want to assignate a variable to retrieve point clicked.
for example :pt=getpoint("Specify first point:")
... Butpt
always returns active model... In fact it returnsGetPoint.new
result!Do you know how to replace model result by point-clicked result, please?
Code is attached below...
-
What happens if you draw a face and zoom in so that the face is taking up 100% of the screen and then try clicking on the face. Does that return that face?
Also, what is the msg variable supposed to contain? It is being sent into the class, but I haven't figured out what its supposed to do.
Chris
-
Oh, I get the message bit now. It is the status text.
So what is the main thing you are trying to do? I'm not familiar with the LiSP that named. What does it do? Just click on a point and this will display the point 3d position?
Chris
-
Hi Chris! Thank you for your answers!
This function will be used by coders. I hope this kind of function will be able to simplify coding work... Now, to know position of a point defined by the user, we have to use class methods. Here I hope you may create a function like this:
# Code example; To make a line by two points... def speed_coding_line model=Sketchup.active_model model.entities.add_edges(getpoint("Specify start point; "),getpoint("Specify end point; ")) end
So I want code available in the first post (function
getpoint(msg)
) returns position of point clicked by the user.Sorry for my bad english...
-
Ahh, I'm getting it now. And you're trying to do it without using a global variable?
-
Yes...
-
With a global you could have your speed code setup like this:
def speed_coding_line model=Sketchup.active_model (getpoint("Specify start point; ") pt1 = $global_variable.clone (getpoint("Specify start point; ") pt2 = $global_variable.clone model.entities.add_edges( pt1, pt2 ) end
Not as simple, but it does the trick. I think since the $global_variable will be holding a Point3d object, you will need to .clone it or else you will get pt1 == pt2.
Is that a possible workaround? I don't like globals. Maybe someone else can figure out how to pass the variable back to the getpoint method.
Chris
-
And maybe I should mention that the code above assumes that you add this to the onLbuttonDown method of the script:
$global_variable = pt.position
So that your class actually sets the global variable. Then the little code snippet I added above should work.
Chris
-
I thought about that work-around method... I will use it until something better...
Thank you Chris!
Advertisement