Manipulating the InputPoint
-
Take a look at the line tool. When you enter a length in the VCB and press 'Enter', a line gets created and the InputPoint for the linetool is set to the end of the new line, allowing you to inference from this new point.
There does not seem to be a way to duplicate this behaviour in Ruby (i.e. setting an InputPoint to a given Point3d object). What would solve my problem is if there was a method to set the position attribute of the InputPoint. For example:
ip=Sketchup;;InputPoint.new ip.position=Geom;;Point3d.new(0,0,0)
Am I missing something here? Is there a workaround for this problem? I attempted a workaround by determing the screen coordinates (using view.screen_coords) of the input point and then calling InputPoint.pick(view,x,y) method using the screen coordinates. This does not work to an acceptable level of accuracy.
Thanks.
-
I thought there was a way to do that, but I don't remember offhand what it is. If I get a chance to hunt it down, I'll let you know.
-
Hi,
I had the same problem int the past.
Try this:a=Geom::Point3d.new(1,2,3)
-> returns Point3d(1, 2, 3)
b=Geom::Point3d.new(0,0,0)
p=Sketchup::InputPoint.new(a)
-> returns #Sketchup::InputPoint:0xc905860
p.position
-> returns Point3d(1, 2, 3)
Sketchup.active_model.entities.add_line(b,p.position)
creates a line, so setting an InputPoint to a given Point3d object works.Hope dis is whaat u r looking for ?
-
@didier bur said:
Hi,
I had the same problem int the past.
Try this:a=Geom::Point3d.new(1,2,3)
-> returns Point3d(1, 2, 3)
b=Geom::Point3d.new(0,0,0)
p=Sketchup::InputPoint.new(a)
-> returns #Sketchup::InputPoint:0xc905860
p.position
-> returns Point3d(1, 2, 3)
Sketchup.active_model.entities.add_line(b,p.position)
creates a line, so setting an InputPoint to a given Point3d object works.Hope dis is whaat u r looking for ?
Great!! That's perfect Didier! I think that will work! Thankyou!
-
I so strongly wanted it...
And it has appeared so simply!module Sketchup class InputPoint def position=(pt) self.copy! InputPoint.new(pt) end end end
And it works and with arrays
a=Geom;;Point3d.new(1,2,3) p=Sketchup;;InputPoint.new(a) p.position=Geom;;Point3d.new(10,20,30) #or p.position=[10,20,30]
Whether it is necessary now?Didier Thank you!
-
Hi,
Guess what gave me the idea of 'InputPoint.new(Geom::Point3d.new(x,y,z)) ?I always wanted to know how to create with Ruby a group, but not empty.
Don't remember who answered here (Rick or TIG) to simply write:
Sketchup.active_model.entities.dd_group(ents)
where ents is an array of entities. Not in the official docs. Excuse me SU team, but they are sooooo bad !
So I tried passing an argument to InputPoint... -
Ah! So it is possible! To set the inputpoint!! For the love of sanity - I spent hours trying to find a way to do that. Don't know why it never occurred to me to try this.
This should have been mentioned in the API docs.
-
No ... no it was not mentioned in the docs at all. Though I added a comment now.
@chris fullmer said:
Maybe I should stop reading the Docs more often
Ditto!
-
Hehe, sorry. I deleted my comment rather quickly because I thought it was lame - so now you quoted me and it looks like you made it up. So to recap, essentially I said that I had just done this same thing earlier, without looking at the Docs, just presuming it was possible. Had I looked at the Docs, I might not have even tried. So Maybe I should code more often without reading the Docs.
Sorry for the confusion
Chris
-
So I'm not mad!
Advertisement