Class: Sketchup::PickHelper
- Inherits:
-
Object
- Object
- Sketchup::PickHelper
- Defined in:
- lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb
Overview
The same Pickhelper instance is being reused by SketchUp. Don’t extend, add methods or redefine methods on this object as it can clash with other extensions.
The PickHelper class is used to pick entities that reside under the current cursor location, similar to native Select tool. Unlike InputPoint, PickHelper uses no inference.
Only Tools react to cursor location and most of these methods are only useful in the context of a tool. For example, if you want to determine the entity you just clicked, you would use #do_pick from within your Tool#onLButtonDown method.
You can retrieve a PickHelper object using the View#pick_helper method.
Entities that are picked (found under the cursor when a mouse or keyboard event occurs), are called Pick Records and are placed in an indexed list.
Constant Summary collapse
- PICK_CROSSING =
Constants
nil
- PICK_INSIDE =
Stub value.
nil
Instance Method Summary collapse
-
#all_picked ⇒ Object
The all_picked method is used to get an array of entities from the active entities from all the pick paths.
-
#best_picked ⇒ Object
The best_picked method is used to retrieve the “best” entity picked (entity that you would have picked if you were using the select tool).
-
#boundingbox_pick(bounding_box, pick_type, transformation = IDENTITY) ⇒ Object
Used to pick a set of entities from a model from a BoundingBox.
-
#count ⇒ Object
The count method is used to count the number of entities picked (number of pick records).
-
#depth_at(index) ⇒ Object
The depth_at method retrieves the depth of one of the currently picked entities in the list of pick records.
-
#do_pick(x, y, aperture = 0) ⇒ Object
The do_pick method is used to perform the initial pick.
-
#element_at(index) ⇒ Object
The element_at method is used to retrieve a specific entity in the list of picked elements.
-
#init(x, y, aperture = 0) ⇒ PickHelper
The #init method is used to initialize the PickHelper for testing points.
-
#leaf_at(index) ⇒ Object
The leaf_at method retrieves the deepest thing in a pick path.
-
#path_at(index) ⇒ Object
The path_at method is used to retrieve the entire path for an entity in the pick list (as an array).
-
#pick_segment(*args) ⇒ Object
The #pick_segment method is used to pick a segment of a polyline curve that is defined by an array of points.
-
#picked_edge ⇒ Object
The picked_edge method is used to retrieve the “best” Edge picked.
-
#picked_element(index) ⇒ Object
The picked_element method retrieves the best drawing element, that is not an edge or a face, picked.
-
#picked_face ⇒ Object
The picked_face method is used to retrieve the best face picked.
-
#test_point(*args) ⇒ Boolean
The #test_point method is used to test a point to see if it would be selected using the default or given pick aperture.
-
#transformation_at(index) ⇒ Object
The transformation_at method is used to get a transformation at a specific pick path index in the pick helper.
-
#view ⇒ Object
The view method is used to get the view associated with the PickHelper.
-
#window_pick(start_point, end_point, pick_type) ⇒ Object
Used to pick a set of entities from a model based on a screen coordinate rectangular area defined by two points.
Instance Method Details
#all_picked ⇒ Object
The all_picked method is used to get an array of entities from the active entities from all the pick paths. Duplicates might occur if there are multiple pick paths for entities that ends in a group or component.
For example, if the pick hits at the border of an edge and face inside a group there will be two pick paths - one for the face and one for the edge. Since this method returns entities from the active entities it would return an array with the group two times.
52 53 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 52 def all_picked end |
#best_picked ⇒ Object
The best_picked method is used to retrieve the “best” entity picked (entity that you would have picked if you were using the select tool).
Returns nil if nothing was picked. You must have called do_pick before calling this method.
69 70 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 69 def best_picked end |
#boundingbox_pick(bounding_box, pick_type, transformation = IDENTITY) ⇒ Object
Used to pick a set of entities from a model from a BoundingBox. The pick criteria can be for completely-contained or partially-contained entities, similar to how the Selection tool works.
105 106 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 105 def boundingbox_pick(bounding_box, pick_type, transformation = IDENTITY) end |
#count ⇒ Object
The count method is used to count the number of entities picked (number of pick records)
117 118 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 117 def count end |
#depth_at(index) ⇒ Object
The depth_at method retrieves the depth of one of the currently picked entities in the list of pick records.
137 138 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 137 def depth_at(index) end |
#do_pick(x, y, aperture = 0) ⇒ Object
The do_pick method is used to perform the initial pick. This method is generally called before any other methods in the PickHelper class.
Returns the number of entities picked. The x and y values are the screen coordinates of the point at which would want to do a pick.
161 162 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 161 def do_pick(x, y, aperture = 0) end |
#element_at(index) ⇒ Object
The element_at method is used to retrieve a specific entity in the list of picked elements. This element will be from the active entities.
Use count() to get the number of possible pick paths.
185 186 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 185 def element_at(index) end |
#init(x, y, aperture = 0) ⇒ PickHelper
The #init method is used to initialize the PickHelper for testing points.
You do not normally need to call this method, but you can use this if you want to call #test_point or #pick_segment on a lot of points.
If the optional aperture is given, it is given in pixels.
215 216 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 215 def init(x, y, aperture = 0) end |
#leaf_at(index) ⇒ Object
The leaf_at method retrieves the deepest thing in a pick path.
For example, if you have a face that is within a component that is within another component, leaf_at returns the face.
Use count() to get the number of possible pick paths.
239 240 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 239 def leaf_at(index) end |
#path_at(index) ⇒ Object
The path_at method is used to retrieve the entire path for an entity in the pick list (as an array).
If one of the pick paths end in a face nested in a group nested in a component this method will return an array of these entities. The Group will be first and the face will be last.
The first item in the array will be from the active entities and the last item will be a drawing element that is not a group, component or image.
266 267 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 266 def path_at(index) end |
#pick_segment(points) ⇒ Integer, false #pick_segment(points, x, y, aperture = 0) ⇒ Integer, false
The return value will be a negative index when a segment is picked.
The #pick_segment method is used to pick a segment of a polyline curve that is defined by an array of points.
If you click on a point in a polyline curve, the index of the point in the curve is returned (starting at 0).
If you click on a segment in the polyline curve, the index of the segment is returned. Segments are returned by negative indicies and start at index -1 (for the segment connecting the first two points) and increase by a factor of -1 (for example, the segment connecting second and third point is -2).
There is no need to invoke #do_pick for this and the results are unrelated.
316 317 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 316 def pick_segment(*args) end |
#picked_edge ⇒ Object
The picked_edge method is used to retrieve the “best” Edge picked.
Returns nil if there were no edges picked. You must have called do_pick before calling this method.
332 333 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 332 def picked_edge end |
#picked_element(index) ⇒ Object
The picked_element method retrieves the best drawing element, that is not an edge or a face, picked.
Returns nil if nothing was picked. You must have called do_pick before calling this method.
352 353 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 352 def picked_element(index) end |
#picked_face ⇒ Object
The picked_face method is used to retrieve the best face picked.
Returns nil if there were no faces picked. You must have called do_pick before calling this method.
368 369 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 368 def picked_face end |
#test_point(point) ⇒ Boolean #test_point(point, x, y, aperture = 0) ⇒ Boolean
The #test_point method is used to test a point to see if it would be selected using the default or given pick aperture.
There is no need to invoke #do_pick for this and the results are unrelated.
402 403 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 402 def test_point(*args) end |
#transformation_at(index) ⇒ Object
The transformation_at method is used to get a transformation at a specific pick path index in the pick helper.
The transformation combines the transformation of all groups, components and images in the pick path. This transformation can be used to transform the coordinates of the leaf entity into the coordinates of the active entities.
437 438 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 437 def transformation_at(index) end |
#view ⇒ Object
The view method is used to get the view associated with the PickHelper.
448 449 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 448 def view end |
#window_pick(start_point, end_point, pick_type) ⇒ Object
Used to pick a set of entities from a model based on a screen coordinate rectangular area defined by two points. The pick criteria can be for completely-contained or partially-contained entities, similar to how the Selection tool works. The z value of the points passed in are ignored.
475 476 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb', line 475 def window_pick(start_point, end_point, pick_type) end |