My favorites | English | Sign in

Google SketchUp Ruby API

PickHelper

class

Parent: Object

Introduction

SketchUp 6.0+

The PickHelper class is used to pick entities that reside under the current cursor location. PickHelper and InputPoint are similar, but InputPoint also uses inferencing. You can retrieve a PickHelper object using the pick_helper method on a View object.

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.

Methods

PickHelper.all_pickedSketchUp 6.0+

The all_picked method is used to get an array of elements in the pick.

Returns:

elements
the array of elements in the pick.
 ph = view.pick_helper
 ph.do_pick x,y
 t = ph.all_picked

PickHelper.best_pickedSketchUp 6.0+

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).

You must have called do_pick prior to calling this method.

Returns:

entity
the best picked entity
 ph = view.pick_helper
 ph.do_pick x,y
 best = ph.best_picked

PickHelper.countSketchUp 6.0+

The count method is used to count the number of entities picked (number of pick records)

Returns:

number
the number of entities picked
 number = pickhelper.count

PickHelper.depth_atSketchUp 6.0+

The depth_at method retrieves the depth of one of the currently picked entities in the list of pick records.

Returns 1 if element is outside a component or group.

Arguments:

index
A number from 1 to number of items picked.

Returns:

depth
the depth of the entity if successful
 ph = view.pick_helper
 ph.do_pick x,y
 depth = ph.depth_at 1

PickHelper.do_pickSketchUp 6.0+

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.

Arguments:

x
X screen coordinate for the pick.
y
Y screen coordinate for the pick.

Returns:

numpicked
the number of entities picked
 ph = view.pick_helpernum = ph.do_pick(x, y)

PickHelper.element_atSketchUp 6.0+

The element_at method is used to retrieve a specific entity in the list of picked elements.

Arguments:

index
A number from 0 to number of items picked.

Returns:

entity
the entity at the index position in the list of picked entities.
 ph = view.pick_helper
 ph.do_pick x,y
 # Returns the element at a specific spot in the list of
 # elements picked.
 element = ph.element_at 0

PickHelper.initSketchUp 6.0+

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 on a lot of points.

If the optional aperture is given, it is given in pixels.

Arguments:

x
X screen coordinate for the pick.
y
Y screen coordinate for the pick.
aperture
(optional) aperture in pixels.

Returns:

pickhelper
a PickHelper object
 ph = view.pick_helper
 phnew = ph.init x, y

PickHelper.leaf_atSketchUp 6.0+

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.

Arguments:

index
A number from 1 to number of items picked.

Returns:

entity
the leaf entity
 ph = view.pick_helper
 # Returns nil
 phnew = ph.leaf_at 1

PickHelper.path_atSketchUp 6.0+

The path_at method is used to retrieve the entire path for an entity in the pick list (as an array).

Arguments:

index
A number from 1 to number of items picked.

Returns:

array
an array of entities including the leaf
 ph = view.pick_helper  # Returns nil
 path = ph.path_at 1

PickHelper.pick_segmentSketchUp 6.0+

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 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).

Arguments:

array_or_list
A series of Point3d objects in the polyline as a list of parameters or an array containing Point3d objects.
aperture
(optional) aperture in pixels.

Returns:

index
an index of the point in the array if you clicked on a point or an index of a segment if you clicked on a segment (if successful)
 point1 = Geom::Point3d.new 0,0,0
 point2 = Geom::Point3d.new 10,0,0
 ph = view.pick_helper  # Returns -1 or 0
 path = ph.pick_segment point1, point2

PickHelper.picked_edgeSketchUp 6.0+

The picked_edge method is used to retrieve the "best" Edge picked.

Returns:

edge
an Edge object if successful
 edge =pickhelper.picked_edge

PickHelper.picked_elementSketchUp 6.0+

The picked_element method retrieves the best drawing element, that is not an edge or a face, picked.

Returns nil if there was nothing picked. You must have called do_pick before calling this method.

Returns:

element
a drawing element that is not an edge or face if successful
 ph = view.pick_helper
 ph.do_pick x,y
 best = ph.picked_element

PickHelper.picked_faceSketchUp 6.0+

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.

Returns:

face
a Face object if successful.
 ph = view.pick_helper
 ph.do_pick x,y
 best = ph.picked_face

PickHelper.test_pointSketchUp 6.0+

The test_point method is used to test a point to see if it would be selected using the default or given pick aperture.

In the first form, you must have initialized the PickHelper using the init method. This is more efficient if you want to test a lot of points using the same screen point.

In the second and third forms, it initializes the PickHelper using a screen point and an optional pick aperture that you pass in as the 2nd-4th arguments.

Arguments:

point
Screen point.
x
(optional) x position of pick.
y
(optional) y position of pick.
aperture
(optional) aperture in pixels.

Returns:

would_be_selected
true or false
 ok = pickhelper.test_point(pt)
 ok = pickhelper.test_point point, x, y
 ok = pickhelper.test_point point, x, y, aperture

PickHelper.transformation_atSketchUp 6.0+

The transformation_at method is used to get a transformation at a specific index in the pick helper.

The index represents the depth (whether the transformation is encapsulated in a component or group). A depth of 1 represents no encapsulation.

Arguments:

index
The index where the transformation should be retrieved.

Returns:

transformation
the transformation found
 ph = view.pick_helper
 ph.do_pick x,y
 t = ph.transformation_at 1

PickHelper.viewSketchUp 6.0+

The view method is used to get the view associated with the PickHelper.

Returns:

view
the associated view
 number = pickhelper.count