My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google SketchUp Ruby API

InputPoint

class

Parent: Object

Introduction

SketchUp 6.0+

The InputPoint used to pick entities that reside under the current cursor location. InputPoint and PickHelper are similar, but InputPoint also uses inferencing. Only tools react to cursor location. Therefore, most of the methods in this class are only useful in the context of a tool you are writing. For example, if you want to determine the entity that you just clicked on with the mouse, you would use InputPoint.pick from within your onLMouseButton method in a tool. See the example script linetool.rb for examples of using the InputPoint class.

Methods

InputPoint.==SketchUp 6.0+

The == method is used to determine if two input points are the same.

Arguments:

inputpoint1
The first input point in the comparison.
inputpoint2
The second input point in the comparison.

Returns:

status
true if the InputPoint objects are the same object. False if the objects are not the same.
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = Sketchup::InputPoint.new
 ip2 = view.inputpoint x,y
 # Copy the contents of inputpoint2 into inputpoint1
 ip1.copy! ip2
 # Returns true
 status = ip1 == ip2

InputPoint.clearSketchUp 6.0+

The clear method is used to clear the input point.

This sets it to an empty state. After calling this, valid? will return false.

Returns:

inputpoint
the cleared (empty) input point if this successful
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 # Returns true
 ip = ip1.clear

InputPoint.copy!SketchUp 6.0+

The copy! method is used to copy the data from a second input point into this input point.

Arguments:

inputpoint
The second input point.

Returns:

inputpoint
the new input point that received the copy if successful
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = Sketchup::InputPoint.new
 ip2 = view.inputpoint x,y
 # Copy the contents of inputpoint2 into inputpoint1
 ip = ip1.copy! ip2

InputPoint.degrees_of_freedomSketchUp 6.0+

The degrees_of_freedom method retrieves the number of degrees of freedom there are for an input point.

If you are just getting a point in space, then the degrees_of_freedom will be 3 - meaning that there is nothing about the point that would constrain its position.

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.

If you are on an Edge or an axis, then the degrees_of_freedom will be 1 meaning that you can only move in the direction of the edge or axis.

If you get an end point of an Edge, or an intersection point, then the degrees_of_freedom will be 0.

Returns:

degrees_of_freedom
see comments.
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 dof = ip1.degrees_of_freedom

InputPoint.depthSketchUp 6.0+

The depth method retrieves the depth of an inference if it is coming from a component.

If the InputPoint is not getting a position from inside a component, this method will return 0. Otherwise it returns the depth of the entity in a nested component that is providing the position.

Returns:

depth
a number representing the depth of the inputpoint (inside groups and components) if successful
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 d = ip1.depth

InputPoint.display?SketchUp 6.0+

The display? method is used to determine if the input point has anything to draw.

If the method returns true, then the draw method will draw something.

Returns:

status
true if the draw method will draw something, false if the draw method has nothing to draw
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 status = ip1.display

InputPoint.drawSketchUp 6.0+

The draw method is used to draw the input point.

This is useful for showing an InputPoint from within the draw method of a tool that you have implemented in Ruby. Additional examples are available in the Plugins/examples directory.

Arguments:

view
The current view.

Returns:

nil
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 ip = ip1.draw view

InputPoint.edgeSketchUp 6.0+

The edge method is used to retrieve the edge if the input point is getting its position from a point on an Edge.

Returns:

edge
an Edge object if successful, or nil if unsuccessful
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 e = ip1.edge

InputPoint.faceSketchUp 6.0+

The face method retrieves the face if the input point is getting its position from a face.

Otherwise it returns nil.

Returns:

face
a Face object if successful, or nil if unsuccessful
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 f = ip1.face

InputPoint.newSketchUp 6.0+

The new method is used to create a new InputPoint object.

Returns:

inputpoint
the newly created InputPoint object if successful
 ip1 = Sketchup::InputPoint.new

InputPoint.pickSketchUp 6.0+

The pick method is used to get the input point at a specific screen position.

The first form just uses the screen position to compute the InputPoint. It is used when you don't want the InputPoint to be dependent on another InputPoint.

The second form uses the screen position and another InputPoint. It will find additional inferences such as along one of the axis directions from the first point.

Arguments:

view
The current view.
x
A x value.
y
A y value.
inputpoint
A second input point used as a reference for the pick.

Returns:

status
true if a valid InputPoint was picked and it is different than it was before.
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 inputpoint = view.inputpoint x, y
 inputpoint2 = Sketchup::InputPoint.new
 inputpoint.pick view, x, y
 inputpoint.pick view, x, y, inputpoint2

InputPoint.positionSketchUp 6.0+

The position method is used to get the 3D point from the input point.

Returns:

point
a Point3d object position for the intput point if successful
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 point = ip1.position

InputPoint.tooltipSketchUp 6.0+

The tooltip method is used to retrieve the string that is the tool tip to display for the input point.

Returns:

tip
a string tooltip or an empty string (if the input point doesn't provide a tooltip).
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 # Click on a face and you get "On Face"
 tip = ip1.tooltip

InputPoint.transformationSketchUp 6.0+

The transformation method retrieves the Transformation object for the input point.

If the InputPoint object is getting its position from something inside of a component instance, this method returns the Transformation of the component instance. Otherwise it returns the identity Transformation.

Note that the position method on a input point always returns a point that is transformed into model space. If you are using the edge, face or vertex method on the InputPoint though, you will probably need to use the transformation method to transform the data that you get back from the selected entity.

Returns:

transformation
the Transformation for the input point if successful
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 # In this case, returning the identity transformation
 tform = ip1.transformation

InputPoint.valid?SketchUp 6.0+

The valid? method is used to determine if an input point has valid data.

You must have called the pick method to set the data before it is valid.

Returns:

status
true if the input point has valid data, false if it does not have valid data.
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 status = ip1.valid?

InputPoint.vertexSketchUp 6.0+

The vertex method returns a Vertex associated with the InputPoint. If the InputPoint is on the end of a line, then it will return the Vertex. If the InputPoint does not select any vertices this method returns nil.

Returns:

vertex
The associated vertex
 view = Sketchup.active_model.active_view
 x = 100
 y = 100
 ip1 = view.inputpoint x,y
 # Click on a face and you get "On Face"
 tip = ip1.vertex