Class: Sketchup::PickHelper
- Inherits:
-
Object
- Object
- Sketchup::PickHelper
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 #
- Sketchup::PickHelper::PICK_INSIDE
- Sketchup::PickHelper::PICK_CROSSING
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) ⇒ Integer
Used to pick a set of entities from a model from a Geom::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) ⇒ Sketchup::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 ⇒ Sketchup::View
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.
↑ #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.
↑ #boundingbox_pick(bounding_box, pick_type, transformation = IDENTITY) ⇒ Integer
Used to pick a set of entities from a model from a Geom::BoundingBox. The pick criteria can be for completely-contained or partially-contained entities, similar to how the Selection tool works.
↑ #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. 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.
↑ #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.
↑ #init(x, y, aperture = 0) ⇒ Sketchup::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.
↑ #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.
↑ #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.
↑ #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.
↑ #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.
↑ #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.
↑ #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.
↑ #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.
↑ #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.
↑ #view ⇒ Sketchup::View
The #view method is used to get the view associated with the Sketchup::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. 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.