Line#

class Line(start: Point, end: Point, data: compas.geometry.Line | None = None, plane: ReferencePlane | Axonometry | None = None)[source]#

Bases: object

The primary drawing element.

A line connects two Point objects.

Parameters:

Methods

from_xy

Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.

from_xyz

Create a new Line instance using the given start and end coordinates, interpreted as 3D (x-y-z) coordinates.

from_yz

Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.

from_zx

Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.

intersections_with_line

Compute the intersection with another line, assuming they lie on the same plane.

not_on_projection_planes

Get the plane keys in which line has no projection.

on_projection_planes

Get the plane keys in which line has a projection.

project

Project crurrent line on another plane.

project_into_surface

Projection of a surface in axonometric picture plane out of its perpendicular lines.

random_line

Make a random line object, perpendicular to one of the coordinate planes.

Attributes

plane

The Plane of which the line is in; set by parent.

projections

Collection of the lines' projections; updated automatically.

start

The first point of the line.

end

The second point of the line.

key

The lines' coordinate system, i.e. plane membership.

data

View plane coordinate system line.

Methods#

static Line.from_xy(start: tuple[float], end: tuple[float]) Line[source]#

Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.

Parameters:
  • start (tuple[float]) – A tuple containing two float values representing the starting point of the line.

  • end (tuple[float]) – A tuple containing two float values representing the ending point of the line.

Returns:

A new Line instance with the specified start and end points.

Return type:

Line

static Line.from_xyz(start: tuple[float], end: tuple[float]) Line[source]#

Create a new Line instance using the given start and end coordinates, interpreted as 3D (x-y-z) coordinates.

Parameters:
  • start (tuple[float]) – A tuple containing three float values representing the starting point of the line.

  • end (tuple[float]) – A tuple containing three float values representing the ending point of the line.

Returns:

A new Line instance with the specified start and end points.

Return type:

Line

static Line.from_yz(start: tuple[float], end: tuple[float]) Line[source]#

Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.

Parameters:
  • start (tuple[float]) – A tuple containing two float values representing the starting point of the line.

  • end (tuple[float]) – A tuple containing two float values representing the ending point of the line.

Returns:

A new Line instance with the specified start and end points.

Return type:

Line

static Line.from_zx(start: tuple[float], end: tuple[float]) Line[source]#

Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.

Parameters:
  • start (tuple[float]) – A tuple containing two float values representing the starting point of the line.

  • end (tuple[float]) – A tuple containing two float values representing the ending point of the line.

Returns:

A new Line instance with the specified start and end points.

Return type:

Line

Line.intersections_with_line(line: Line) compas.geometry.Point[source]#

Compute the intersection with another line, assuming they lie on the same plane.

Parameters:

line (Line) – The other line.

Return type:

compas.geometry.Point

Line.not_on_projection_planes() list[str] | None[source]#

Get the plane keys in which line has no projection.

Return type:

list[str] | None

Line.on_projection_planes() list[str] | None[source]#

Get the plane keys in which line has a projection.

Return type:

list[str] | None

Line.project(distance: float | None = None, start_distance: float | None = None, end_distance: float | None = None, ref_plane_key: Literal['xy', 'yz', 'zx'] | None = None) Line[source]#

Project crurrent line on another plane.

The projection can be in both directions between one of the three reference planes and the axonometric picture plane.

>>> from axonometry import Axonometry, Point, Line
>>> my_axo = Axonometry(10,15)
>>> xy_line = my_axo["xy"].draw_line(Line(Point(x=-18, y=6), Point(x=26, y=12)))
>>> xy_line.project(distance=75)
Line(Point(x=-18, y=6, z=75), Point(x=26, y=12, z=75))  # z added by projection
>>> xyz_line = my_axo.draw_line(Line(Point(x=6, y=9, z=44), Point(x=45, y=-5, z=9)))
>>> xyz_line.project(ref_plane_key="yz")
Line(Point(y=9, z=44), Point(y=-5, z=9))
Parameters:
  • distance (float | None) – The missing third coordinate in order to project the line on the axonometric picture plane. This applies when the point to project is contained in a reference plane.

  • start_distance (float | None) – Specify a distinct distance value for the Line.start projection.

  • end_distance (float | None) – Specify a distinct distance value for the Line.end projection.

  • ref_plane_key (Literal['xy', 'yz', 'zx'] | None) – Specify the reference plane for the auxilary projection.

Returns:

A new line.

Return type:

Line

Line.project_into_surface(distance: float, length: float) None[source]#

Projection of a surface in axonometric picture plane out of its perpendicular lines.

Parameters:
Return type:

None

static Line.random_line(key: Literal['xy', 'yz', 'zx', 'xyz'] = 'xyz') Line[source]#

Make a random line object, perpendicular to one of the coordinate planes.

Parameters:

key (Literal['xy', 'yz', 'zx', 'xyz'])

Return type:

Line

Attributes#

Line.plane: ReferencePlane | Axonometry#

The Plane of which the line is in; set by parent.

Line.projections: dict[Literal['xy', 'yz', 'zx', 'xyz'], Line | list[Line]]#

Collection of the lines’ projections; updated automatically.

Line.start: Point#

The first point of the line.

Line.end: Point#

The second point of the line.

Line.key: Literal['xy', 'yz', 'zx', 'xyz']#

The lines’ coordinate system, i.e. plane membership.

Line.data: compas.geometry.Line | None#

View plane coordinate system line.