|
SketchUp Ruby API Reference |
The ConstructionLine class contains methods for modifying construction lines. Construction lines can be infinite in length, semi-infinite (i.e. infinite in one direction) or finite.
Parent:Drawingelement
Methods: direction, direction=, end, end=, position, position=, reverse!, start, start=, stipple, stipple=
Example Code: constructionlinetests.rb
The direction method retrieves a 3d vector in the direction of the construction line.
vector = constructionline.direction
vector - a Vector3d object if successful
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
constline = entities.add_cline point1, point2
vector = constline.direction
if (vector)
UI.messagebox vector
else
UI.messagebox "Failure"
end
The direction= method is used to set the direction of the construction line to a 3d vector.
vector = constructionline.direction = vector
vector - the Vector3d whose direction will be used to set the direction of the construction line
vector - the new Vector3d object if successful
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
constline = entities.add_cline point1, point2
vector = constline.direction if (vector)
UI.messagebox vector
else
UI.messagebox "Failure"
end
newvector = Geom::Vector3d.new 30,30,30
vector = constline.direction=newvector if (vector)
UI.messagebox vector
else
UI.messagebox "Failure"
end
The end method retrieves the end point of a construction line in the form of a 3d point.
point = constructionline.end
point - a Point3d object representing the end of the construction line
If the construction line is infinite at the end, this returns nil.
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
constline = entities.add_cline point1, point2
endofline = constline.end
The end= method is used to set the end point of the construction line. This method will make the length finite at the end.
status = line.end = point | nil
point - the Point3d object to set for the end point of the construction line
nil - sets the end point to infinite
status - 3d point if or nil
Set the end to nil to make the construction line infinite at the end.
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
point3 = Geom::Point3d.new (10,10,10)
constline = entities.add_cline point1, point2
endofline = constline.end=nil
if (endofline)
UI.messagebox endofline
else
UI.messagebox endofline
end
The position method is used to retrieve a 3d point used to create a construction line on an infinite construction line.
point = line.position
point - the Point3d object used to create the line (if successful)
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
vector = Geom::Vector3d.new (10,10,10)
constline = entities.add_cline point1, vector
# Returns point1 or 0,0,0
position = constline.position
Thie postion= method is used to set a 3d point that the construction passes through
point = constructionline.position= point
point - the Point3d object for the construction line to pass through
point - the new Point3d object that the construction line will pass through (if successful)
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
point3 = Geom::Point3d.new (0,20,20)
constline = entities.add_cline point1, point2
position = constline.position=point3
The reverse! method is used to reverse the direction of the construction line.
status = line.reverse!
status - ?
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
constline = entities.add_cline point1, point2
status = constline.reverse!
The start method is used to retrieve the starting point of a construction line.
point = constructionline.start
point - the Poin3d object representing the starting point of the construction line (if successful)
If the construction line is infinite at the start, this returns nil.
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
constline = entities.add_cline point1, point2
startofline = constline.start
The start= method is used to set the start point of a construction line making the line's length finite at the start.
point = constructionline.start = pt | nil
point - the Point3d object to set for the end point of the construction line
nil - sets the end point to infinite
point - a Point3d object if successful or nil
Setting the start to nil will make the construction line infinite ate the start.
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
point3 = Geom::Point3d.new (5,5,5)
constline = entities.add_cline point1, point2
startofline = constline.start=point3
The stipple method is used to retrieve the stipple pattern used to display the construction line.
pattern = constructionline.stipple
pattern - the stipple pattern being used
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
constline = entities.add_cline point1, point2 # Default returns 0
pattern = constline.stipple
The stipple= method is used to set the stipple pattern used to display the construction line.
pattern = constructionline.stipple = pattern
pattern - a new stipple pattern
pattern - the newly set stipple pattern
The stipple pattern can be given as a string or as a number. Valid strings are:
"."
"-"
"_"
"-.-"
model = Sketchup.active_model
entities = model.active_entities
point1 = Geom::Point3d.new (0,0,0)
point2 = Geom::Point3d.new (20,20,20)
constline = entities.add_cline point1, point2
constline.stipple="-.-"
|
SketchUp Ruby API Reference: ConstructionLine |
© Google Inc. 2007 sketchup.google.com |