ip = Sketchup::InputPoint.new
ip.pick view, x, y
view.model.active_path = ip.instance_path.valid? ? ip.instance_path : nil
view = Sketchup.active_model.active_view
face = ip.face
rpt = ip.position
In these codes rpt is not exactly on face. How can I select a point on face?
Would you please so kind to edit your post following this guide:
I moved your post - in my opinion - better category to: Developers: Ruby API
ip = Sketchup::InputPoint.new ip.pick view, x, y view.model.active_path = ip.instance_path.valid? ? ip.instance_path : nil face = ip.face if face rpt = ip.position else # something else end
To ensure if the cursor is really on the face you can combine it with
ip = Sketchup::InputPoint.new ip.pick view, x, y face = ip.face ph = view.pick_helper ph.do_pick(x, y) face_ph = ph.picked_face if face && face_ph && face == face_ph rpt = ip.position else # something else end
Thank you for your help and attention. in an example face x is 15.0 but x we picked is 15.000000000000055. Before and after your codes result is same. is it real problem or simply we can ignore it?
As far as I know SketchUp’s built-in tolerance for length is 1/1000". Therefore it treats as same if you use as Poind3D coordinates.
If you cope paste this to Ruby console
pt1 = Geom::Point3d.new(15.0,0.0,0.0) pt2 = Geom::Point3d.new(15.000000000000055,0.0,0.0) pt1 == pt2
The result will be
pt1 equal to
So yes, you can ignore.
Similar as you are ignoring my first post in this topic:
You can test the inputpoint for degrees of freedom caused by the inference engine.
If you are on a face, then the degrees_of_freedom will be 2 meaning that you can only move on the plane of the face.
English is not my mother language also I am bigginer in Ruby. Simply I confused. Forgive me for it. I will be more careful about your posts. ```ruby before ruby codes. I will remember it.
Very useful for me. Thank you.
Please edit the first post and add the code delimiters.
Use the pencil icon ( ) to edit your posts.
Dear Dezmo, Sorry that I have to back to this old topic. As you said view.model.active_path method use for SU2020. What can I do for older version? I use this line to put a group in edit mode (same as double click in SU). Thank you in advance,
Search this category for “sendkeys”. It is hack.
You put the group into the selection set alone, and then send an ENTER key to SketchUp.
There is no way using the API in older versions to enter edit context.