Geom::Vector3d.set!
http://code.google.com/apis/sketchup/docs/ourdoc/vector3d.html#set!
@unknownuser said:
This is a shortcut for writing:
Clarify: "This is a shortcut for setting all coordinates of the vector, instead of setting them individually in three statements."
@unknownuser said:
You may also call this method with an array or another vector:
Confusing. (I first took this mean that the SU extended Array
class had an Array.set!
method; which is NOT the case.)
Clarify: "You may also call this method with an Array or a Vector3d object as the first argument,(and any other arguments will then be ignored.)"
Add: "If only one Numeric
argument is supplied, or if a one element Array
is supplied, then only the x value will be changed. IF only 2 values are supplied, in the same way, then the z value will remain unchanged.
All coordinate values must be implicitly convertable to Float
class.(If you pass a nil
value, a TypeError
exception is raised.)"
@unknownuser said:
Arguments:
x ____ The x value for the vector.
y ____ The y value for the vector.
z ____ The z value for the vector.
vector2 ____ A Vector3d object.
Remove 4th argument. (There is no valid fourth argument for this method. All args beyond 3 are ignored.)
Clarify: (suggested Argument list)
Arguments:
x ____ The x value for the vector, a Vector3d object, or an Array.
y ____ The y value for the vector. (optional)
z ____ The z value for the vector. (optional)
Better Code Example:
vector = Geom;;Vector3d.new 0,0,1
vector.set! 1,0,0 # three Numeric arguments
vector2 = Geom;;Vector3d.new 1,2,3
vector.set! vector2 # one Vector3d argument
# vector now is (1,2,3)
array1 = Array.new(4,5,6)
vector.set! array1[2] # one Numeric argument
# vector now is (6,2,3)
vector2.set! array1 # one Array argument
# vector2 now is (4,5,6)
vector.set! [5,4] # one Array with 2 values
# vector now is (5,4,3)
# change x and z in one statement, this way;
vector.set! 9, vector.y, 8
# vector now is (9,4,8)