SketchUp  Ruby API Reference 

Class Index

Method Index

Developers Guide

Examples

ConstructionLine class

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

Instance Methods


direction

The direction method retrieves a 3d vector in the direction of the construction line.

Syntax

vector = constructionline.direction

Return Value

vector - a Vector3d object if successful

Example

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

 

 


direction=

The direction= method is used to set the direction of the construction line to a 3d vector.

Syntax

vector = constructionline.direction = vector

Arguments

vector - the Vector3d whose direction will be used to set the direction of the construction line

Return Value

vector - the new Vector3d object if successful

Example

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

 

 


end

The end method retrieves the end point of a construction line in the form of a 3d point.

Syntax

point = constructionline.end

Return Value

point - a Point3d object representing the end of the construction line

Comments

If the construction line is infinite at the end, this returns nil.

Example

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

 

 


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.

Syntax

status = line.end = point | nil

Arguments

point - the Point3d object to set for the end point of the construction line 

nil - sets the end point to infinite

Return Value

status - 3d point if or nil

Comments

Set the end to nil to make the construction line infinite at the end.

Example

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

 

 


position

The position method is used to retrieve a 3d point used to create a construction line on an infinite construction line.

Syntax

point = line.position

Return Value

point - the Point3d object used to create the line (if successful)

Example

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

 

 


position=

Thie postion= method is used to set a 3d point that the construction passes through

Syntax

point = constructionline.position= point

Arguments

point - the Point3d object for the construction line to pass through

Return Value

point - the new Point3d object that the construction line will pass through (if successful)

Example

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

 

 


reverse!

The reverse! method is used to reverse the direction of the construction line.

Syntax

status = line.reverse!

Return Value

status - ?

Example

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!

 

 


start

The start method is used to retrieve the starting point of a construction line.

Syntax

point = constructionline.start

Return Value

point - the Poin3d object representing the starting point of the construction line (if successful)

Comments

If the construction line is infinite at the start, this returns nil.

Example

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

 

 


start=

The start= method is used to set the start point of a construction line making the line's length finite at the start.

Syntax

point = constructionline.start = pt | nil

Arguments

point - the Point3d object to set for the end point of the construction line 

nil - sets the end point to infinite

Return Value

point - a Point3d object if successful or nil

Comments

Setting the start to nil will make the construction line infinite ate the start.

Example

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

 

 


stipple

The stipple method is used to retrieve the  stipple pattern used to display the construction line.

Syntax

pattern = constructionline.stipple

Return Value

pattern - the stipple pattern being used

Example

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

 

 


stipple=

The stipple= method is used to set the stipple pattern used to display the construction line.

Syntax

pattern = constructionline.stipple = pattern

Arguments

pattern - a new stipple pattern

Return Value

pattern - the newly set stipple pattern

Comments

The stipple pattern can be given as a string or as a number. Valid strings are:  

"."
"-"
"_"
"-.-"

Example

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="-.-"