CompoundGeometry#

class sectionproperties.pre.geometry.CompoundGeometry(geoms: MultiPolygon | list[Geometry])[source]#

Bases: Geometry

Class for defining a geometry of multiple distinct regions.

CompoundGeometry instances are composed of multiple Geometry objects. As with Geometry objects, CompoundGeometry objects have methods for generating a triangular mesh over all geometries, transforming the collection of geometries as though they were one (e.g. translation, rotation, and mirroring), and aligning the CompoundGeometry to another Geometry (or to another CompoundGeometry).

Each Geometry object may have different material properties.

CompoundGeometry objects can be created directly between two or more Geometry objects by using the + operator.

Methods

align_center

Aligns the CompoundGeometry to a center point.

align_to

Aligns the geometry to another Geometry object.

assign_control_point

Assigns a control point to the geometry.

calculate_area

Calculates the area of the geometry.

calculate_centroid

Calculates the centroid of the geometry.

calculate_extents

Calculate geometry extents.

calculate_perimeter

Returns the length of the exterior perimeter of the CompoundGeometry.

compile_geometry

Creates geometry data from shapely data.

create_facets_and_control_points

Creates geometry data from shapely data.

create_mesh

Creates a quadratic triangular mesh from the CompoundGeometry object.

from_3dm

Creates a CompoundGeometry object from the objects in a Rhino 3dm file.

from_dxf

An interface for the creation of Geometry objects from CAD .dxf files.

from_points

Creates CompoundGeometry from points, facets, control points and holes.

from_rhino_encoding

Load an encoded single surface planer brep.

mirror_section

Mirrors the CompoundGeometry object about a point on either the x or y-axis.

offset_perimeter

Dilates/erodes the perimeter of a CompoundGeometry object by an amount.

plot_geometry

Plots the geometry defined by the input section.

rotate_section

Rotates a CompoundGeometry object.

shift_points

Shifts the points in the geometry.

shift_section

Returns a CompoundGeometry object translated by (x_offset, y_offset).

split_section

Splits CompoundGeometry about a line.

Attributes

recovery_points

Returns the recovery points.

__init__(geoms: MultiPolygon | list[Geometry]) None[source]#

Inits the CompoundGeometry class.

Parameters:

geoms (MultiPolygon | list[Geometry]) – Either a list of Geometry objects or a shapely.MultiPolygon instance.

static from_points(points: list[tuple[float, float]], facets: list[tuple[int, int]], control_points: list[tuple[float, float]], holes: list[tuple[float, float]] | None = None, materials: list[Material] | None = None) CompoundGeometry[source]#

Creates CompoundGeometry from points, facets, control points and holes.

An interface for the creation of CompoundGeometry objects through the definition of points, facets, control points and holes. Geometries created through this method are expected to be non-ambiguous meaning that no “overlapping” geometries exists and that nodal connectivity is maintained (e.g. there are no nodes “overlapping” with facets without nodal connectivity).

Parameters:
  • points (list[tuple[float, float]]) – List of points (x, y) defining the vertices of the section geometry.

  • facets (list[tuple[int, int]]) – A list of (start, end) indices of vertices defining the edges of the section geoemtry. Can be used to define both external and internal perimeters of holes. Facets are assumed to be described in the order of exterior perimeter, interior perimeter 1, interior perimeter 2, etc.

  • control_points (list[tuple[float, float]]) – A list of points (x, y) that define regions as being distinct, contiguous, and having one material. The point can be located anywhere within region. Only one point is permitted per region. The order of control_points must be given in the same order as the order that polygons are created by facets.

  • holes (list[tuple[float, float]] | None) – A list of points (x, y) that define interior regions as being holes or voids. The point can be located anywhere within the hole region. Only one point is required per hole region.

  • materials (list[Material] | None) – A list of Material objects that are to be assigned, in order, to the regions defined by the given control_points. If not given, then the DEFAULT_MATERIAL will be used for each region.

Raises:
  • ValueError – If there are materials provided without control points

  • ValueError – If the number of materials does not equal the number of control points

  • ValueError – If the number of exterior regions doesn’t match the number of control points

  • ValueError – If control points are not contained within geometries with holes

Returns:

CompoundGeometry object from points

Return type:

CompoundGeometry

Example

This example creates two regions with different material properties:

from sectionproperties.pre import Material, CompoundGeometry
from sectionproperties.analysis import Section

mat1 = Material(
    name="mat1",
    elastic_modulus=1.0,
    poissons_ratio=0.0,
    density=1.0,
    yield_strength=1.0,
    color="tab:olive",
)

mat2 = Material(
    name="mat2",
    elastic_modulus=2.0,
    poissons_ratio=0.0,
    density=2.0,
    yield_strength=2.0,
    color="tab:purple",
)

points = [(0, 0), (10, 0), (15, 10), (-12, -5)]
facets = [(0, 1), (1, 2), (2, 0), (1, 3), (3, 0), (0, 1)]
control_points = [(1, 1), (1, -1)]
materials = [mat1, mat2]

geom = CompoundGeometry.from_points(
    points=points,
    facets=facets,
    control_points=control_points,
    materials=materials,
)
geom.create_mesh(mesh_sizes=[0])
Section(geometry=geom).plot_mesh()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-1.png

Composite CompoundGeometry created from points and facets.#

classmethod from_3dm(filepath: str | Path, **kwargs: Any) CompoundGeometry[source]#

Creates a CompoundGeometry object from the objects in a Rhino 3dm file.

Parameters:
  • filepath (str | Path) – File path to the rhino .3dm file.

  • kwargs (Any) – See below.

Keyword Arguments:
  • refine_num (Optional[int]) – Bézier curve interpolation number. In Rhino a surface’s edges are nurb based curves. Shapely does not support nurbs, so the individual Bézier curves are interpolated using straight lines. This parameter sets the number of straight lines used in the interpolation. Default is 1.

  • vec1 (Optional[numpy.ndarray]) – A 3d vector in the Shapely plane. Rhino is a 3D geometry environment. Shapely is a 2D geometric library. Thus a 2D plane needs to be defined in Rhino that represents the Shapely coordinate system. vec1 represents the 1st vector of this plane. It will be used as Shapely’s x direction. Default is [1,0,0].

  • vec2 (Optional[numpy.ndarray]) – Continuing from vec1, vec2 is another vector to define the Shapely plane. It must not be [0,0,0] and it’s only requirement is that it is any vector in the Shapely plane (but not equal to vec1). Default is [0,1,0].

  • plane_distance (Optional[float]) – The distance to the Shapely plane. Default is 0.

  • project (Optional[bool]) – Controls if the breps are projected onto the plane in the direction of the Shapley plane’s normal. Default is True.

  • parallel (Optional[bool]) – Controls if only the rhino surfaces that have the same normal as the Shapely plane are yielded. If true, all non parallel surfaces are filtered out. Default is False.

Raises:

ImportError – If rhino3dm is not installed. To enable rhino features use pip install sectionproperties[rhino].

Returns:

CompoundGeometry object

Return type:

CompoundGeometry

create_mesh(mesh_sizes: float | list[float], min_angle: float = 30.0, coarse: bool = False) CompoundGeometry[source]#

Creates a quadratic triangular mesh from the CompoundGeometry object.

Parameters:
  • mesh_sizes (float | list[float]) – A float describing the maximum mesh element area to be used in the finite-element mesh for each Geometry object within the CompoundGeometry object. If a list of length 1 or a float is passed, then the one size will be applied to all constituent Geometry meshes.

  • min_angle (float) – The meshing algorithm adds vertices to the mesh to ensure that no angle smaller than the minimum angle (in degrees, rounded to 1 decimal place). Note that small angles between input segments cannot be eliminated. If the minimum angle is 20.7 deg or smaller, the triangulation algorithm is theoretically guaranteed to terminate (given sufficient precision). The algorithm often doesn’t terminate for angles greater than 33 deg. Some meshes may require angles well below 20 deg to avoid problems associated with insufficient floating-point precision.

  • coarse (bool) – If set to True, will create a coarse mesh (no area or quality constraints)

Returns:

CompoundGeometry object with mesh data stored in .mesh attribute. Returned CompoundGeometry object is self, not a new instance.

Return type:

CompoundGeometry

Example

The following example creates a mesh for a plate with a hole, with a refined mesh around the hole region:

from sectionproperties.pre.library import rectangular_section
from sectionproperties.pre.library import circular_section
from sectionproperties.analysis import Section

outer_rect = rectangular_section(d=100, b=200)
inner_rect = rectangular_section(d=50, b=50).align_center(
    align_to=outer_rect
)
circle = circular_section(d=20, n=32).align_center(align_to=outer_rect)

geom = outer_rect - inner_rect + inner_rect - circle
geom.create_mesh(mesh_sizes=[100, 5])
Section(geometry=geom).plot_mesh(materials=False)

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-2.png

Mesh refinement around hole#

shift_section(x_offset: float = 0.0, y_offset: float = 0.0) CompoundGeometry[source]#

Returns a CompoundGeometry object translated by (x_offset, y_offset).

Parameters:
  • x_offset (float) – Distance in x-direction by which to shift the geometry.

  • y_offset (float) – Distance in y-direction by which to shift the geometry.

Returns:

New Geometry object shifted by x_offset and y_offset

Return type:

CompoundGeometry

rotate_section(angle: float, rot_point: tuple[float, float] | str = 'center', use_radians: bool = False) CompoundGeometry[source]#

Rotates a CompoundGeometry object.

Rotates the CompoundGeometry and specified angle about a point. If the rotation point is not provided, rotates the section about the center of the CompoundGeometry’s bounding box.

Parameters:
  • angle (float) – Angle (degrees by default) by which to rotate the section. A positive angle leads to a counter-clockwise rotation.

  • rot_point (tuple[float, float] | str) – Point (x, y) about which to rotate the section. If not provided, will rotate about the center of the compound geometry’s bounding box.

  • use_radians (bool) – Boolean to indicate whether angle is in degrees or radians. If True, angle is interpreted as radians.

Returns:

CompoundGeometry object rotated by angle about rot_point

Return type:

CompoundGeometry

Example

The following example rotates a 200UB25 section with a plate clockwise by 30 degrees:

from sectionproperties.pre.library import rectangular_section, i_section

geom1 = i_section(d=203, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=8)
geom2 = rectangular_section(d=20, b=133)
compound = geom1 + geom2.align_center(align_to=geom1).align_to(
    other=geom1, on="top"
)
compound.rotate_section(angle=-30).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-3.png

Reinforced 200UB25 rotated.#

mirror_section(axis: str = 'x', mirror_point: tuple[float, float] | str = 'center') CompoundGeometry[source]#

Mirrors the CompoundGeometry object about a point on either the x or y-axis.

Parameters:
  • axis (str) – Axis about which to mirror the geometry, "x" or "y"

  • mirror_point (tuple[float, float] | str) – Point about which to mirror the geometry (x, y). If no point is provided, mirrors the geometry about the centroid of the shape’s bounding box.

Returns:

CompoundGeometry object mirrored on axis about mirror_point

Return type:

CompoundGeometry

Example

The following example mirrors a 200PFC section with a plate about the y-axis and the point (0, 0):

from sectionproperties.pre.library import rectangular_section
from sectionproperties.pre.library import channel_section

geom1 = channel_section(d=200, b=75, t_f=12, t_w=6, r=12, n_r=8)
geom2 = rectangular_section(d=20, b=133)
compound = geom1 + geom2.align_center(align_to=geom1).align_to(
    other=geom1, on="top"
)
compound.mirror_section(axis="y", mirror_point=(0,0)).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-4.png

Reinforced 200PFC mirrored.#

align_center(align_to: Geometry | tuple[float, float] | None = None) CompoundGeometry[source]#

Aligns the CompoundGeometry to a center point.

Returns a new CompoundGeometry object, translated in both x and y, so that the center-point of the new object’s material-weighted centroid will be aligned with centroid of the object in align_to. If align_to is an x, y coordinate, then the centroid will be aligned to the coordinate. If align_to is None then the new object will be aligned with its centroid at the origin.

Note

The material-weighted centroid refers to when individual geometries within the CompoundGeometry object have been assigned differing materials. The centroid of the compound geometry is calculated by using the elastic modulus of each geometry’s assigned material.

Parameters:

align_to (Geometry | tuple[float, float] | None) – Another Geometry to align to, an (x, y) coordinate, or None

Raises:

ValueErroralign_to is not valid

Returns:

CompoundGeometry object translated to new alignment

Return type:

CompoundGeometry

Example

The following example creates a rectanglular steel-concrete composite section and uses the align_center() method to place the composite centroid at the origin.

from sectionproperties.pre import Material
from sectionproperties.pre.library import rectangular_section
from sectionproperties.analysis import Section

steel = Material(
    name="Steel",
    elastic_modulus=200e3,
    poissons_ratio=0.3,
    density=7.85e-6,
    yield_strength=250,
    color="grey",
)
concrete = Material(
    name="Concrete",
    elastic_modulus=30.1e3,
    poissons_ratio=0.2,
    density=2.4e-6,
    yield_strength=32,
    color="lightgrey",
)

geom_steel = rectangular_section(d=50, b=50, material=steel)
geom_timber = rectangular_section(d=50, b=50, material=concrete)
geom = geom_timber.align_to(geom_steel, on="right") + geom_steel
geom = geom.align_center()
geom.create_mesh(mesh_sizes=[10, 5])
Section(geometry=geom).plot_mesh()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-5.png

Reinforced 200PFC mirrored.#

split_section(point_i: tuple[float, float], point_j: tuple[float, float] | None = None, vector: tuple[float, float] | None | ndarray[Any, dtype[float64]] = None) tuple[list[Geometry], list[Geometry]][source]#

Splits CompoundGeometry about a line.

Splits, or bisects, the geometry about an infinite line, as defined by two points on the line or by one point on the line and a vector. Either point_j or vector must be given. If point_j is given, vector is ignored.

Returns a tuple of two lists each containing new Geometry instances representing the top and bottom portions, respectively, of the bisected geometry.

If the line is a vertical line then the right and left portions, respectively, are returned.

Parameters:
  • point_i (tuple[float, float]) – A tuple of (x, y) coordinates to define a first point on the line

  • point_j (tuple[float, float] | None) – A tuple of (x, y) coordinates to define a second point on the line

  • vector (tuple[float, float] | None | ndarray[Any, dtype[float64]]) – A tuple or numpy array of (x, y) components to define the line direction.

Returns:

A tuple of lists containing Geometry objects that are bisected about the infinite line defined by the two given points. The first item in the tuple represents the geometries on the "top" of the line (or to the "right" of the line, if vertical) and the second item represents the geometries to the "bottom" of the line (or to the "left" of the line, if vertical).

Return type:

tuple[list[Geometry], list[Geometry]]

offset_perimeter(amount: float = 0.0, where: str = 'exterior', resolution: int = 12) CompoundGeometry[source]#

Dilates/erodes the perimeter of a CompoundGeometry object by an amount.

Parameters:
  • amount (float) – Distance to offset the section by. A negative value “erodes” the section. A positive value “dilates” the section.

  • where (str) – One of either "exterior", "interior", or "all" to specify which edges of the geometry to offset. If geometry has no interiors, then this parameter has no effect.

  • resolution (int) – Number of segments used to approximate a quarter circle around a point

Returns:

CompoundGeometry object translated to new alignment

Return type:

CompoundGeometry

Example

The following example erodes a 200UB25 with a 12 plate stiffener section by 2 mm:

from sectionproperties.pre.library import rectangular_section, i_section

geom1 = i_section(d=203, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=8)
geom2 = rectangular_section(d=12, b=133)
compound = geom1 + geom2.align_center(align_to=geom1).align_to(
    other=geom1, on="top"
)
compound.offset_perimeter(amount=-2).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-6.png

Eroded 200UB25 with stiffener.#

Note

If performing a positive offset on a CompoundGeometry with multiple materials, ensure that the materials propagate as desired by performing a .plot_mesh() prior to performing any analysis.

compile_geometry() None[source]#

Creates geometry data from shapely data.

Converts the shapely.Polygon objects stored in self.geoms into lists of points, facets, control_points, and hole points.

calculate_perimeter() float[source]#

Returns the length of the exterior perimeter of the CompoundGeometry.

If the CompoundGeometry includes disjoint geometries then the perimeter cannot be calculated and the method returns -1.0.

Returns:

CompoundGeometry perimeter

Return type:

float

__add__(other: Geometry | CompoundGeometry) CompoundGeometry#

Combine Geometry objects into a CompoundGeometry using the + operator.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the combination with

Raises:

ValueError – Unable to perform combination operation

Returns:

New Geometry object

Return type:

CompoundGeometry

Example

The following example creates a tee section the + operator:

from sectionproperties.pre.library import rectangular_section

flange = rectangular_section(d=16, b=200)
web = (
    rectangular_section(d=284, b=16)
    .align_center(align_to=flange)
    .align_to(other=flange, on="bottom")
)
(flange + web).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-7.png

Tee section#

__and__(other: Geometry | CompoundGeometry) Geometry | CompoundGeometry#

Performs an intersection on Geometry objects with the & operator.

Returns the regions of geometry common to both geometries.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the intersection with

Raises:

ValueError – Unable to perform intersection

Returns:

New Geometry object

Return type:

Geometry | CompoundGeometry

Example

The following example performs an intersection of a square and circle using the & operator:

from sectionproperties.pre.library import rectangular_section
from sectionproperties.pre.library import circular_section

rect = rectangular_section(d=200, b=200).align_center(align_to=(0, 0))
circle = circular_section(d=250, n=64)
(rect & circle).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-8.png

Intersection of a square and circle#

__or__(other: Geometry | CompoundGeometry) Geometry | CompoundGeometry#

Performs a union on Geometry objects with the | operator.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the union with

Raises:

ValueError – Unable to perform union

Returns:

New Geometry object

Return type:

Geometry | CompoundGeometry

Example

The following example combines two rectangles using the | operator:

from sectionproperties.pre.library import rectangular_section

rect1 = rectangular_section(d=100, b=200)
rect2 = rectangular_section(d=100, b=200).shift_section(
    x_offset=150,
    y_offset=70,
)
(rect1 | rect2).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-9.png

Union of two rectangles#

__sub__(other: Geometry | CompoundGeometry) Geometry | CompoundGeometry#

Performs a difference operation on Geometry objects with the - operator.

Subtracts the second geometry from the first geometry.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the difference operation with

Raises:

ValueError – Unable to perform difference

Returns:

New Geometry object

Return type:

Geometry | CompoundGeometry

Example

The following example creates a hollow box using the - operator:

from sectionproperties.pre.library import rectangular_section

rect1 = rectangular_section(d=400, b=200)
rect2 = rectangular_section(d=300, b=100).align_center(align_to=rect1)
(rect1 - rect2).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-10.png

Hollow box#

__xor__(other: Geometry | CompoundGeometry) Geometry | CompoundGeometry#

Performs a symmetric difference on Geometry objects with the ^ operator.

Returns the regions of geometry that are not overlapping.

Parameters:

other (Geometry | CompoundGeometry) – Geometry object to perform the symmetric difference with

Raises:

ValueError – Unable to perform symmetric difference

Returns:

New Geometry object

Return type:

Geometry | CompoundGeometry

Example

The following example performs a symmetric difference on two circles with the ^ operator:

from sectionproperties.pre.library import circular_section
from sectionproperties.analysis import Section

circ1 = circular_section(d=100, n=64)
circ2 = circular_section(d=100, n=64).shift_section(x_offset=35)
(circ1 ^ circ2).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-11.png

Symmetric difference of two circles#

align_to(other: Geometry | CompoundGeometry | tuple[float, float], on: str, inner: bool = False) Geometry#

Aligns the geometry to another Geometry object.

Returns a new Geometry object, representing self translated so that is aligned on one of the outer bounding box edges of other.

If other is a tuple representing an (x, y) coordinate, then the new Geometry object will represent ‘self’ translated so that it is aligned on that side of the point.

Parameters:
  • other (Geometry | CompoundGeometry | tuple[float, float]) – Either another Geometry or a tuple representing an (x, y) coordinate point that self should align to.

  • on (str) – A str of either “left”, “right”, “bottom”, or “top” indicating which side of other that self should be aligned to.

  • inner (bool) – If True, align self to other in such a way that self is aligned to the “inside” of other. In other words, align self to other on the specified edge so they overlap.

Returns:

Geometry object translated to alignment location

Return type:

Geometry

Example

from sectionproperties.pre.library import rectangular_section
from sectionproperties.pre.library import triangular_section

rect = rectangular_section(b=100, d=50)
tri = triangular_section(b=50, h=50)
tri = tri.align_to(other=rect, on="top")
(rect + tri).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-12.png

A triangle aligned to the top of a rectangle.#

assign_control_point(control_point: tuple[float, float]) Geometry#

Assigns a control point to the geometry.

Returns a new Geometry object with control_point assigned as the control point for the new Geometry. The assignment of a control point is intended to replace the control point automatically generated by shapely.Polygon.representative_point().

An assigned control point is carried through and transformed with the Geometry whenever it is shifted, aligned, mirrored, unioned, and/or rotated. If a perimeter_offset operation is applied, a check is performed to see if the assigned control point is still valid (within the new region) and, if so, it is kept. If not, a new control point is auto-generated.

The same check is performed when the geometry undergoes a difference operation (with the - operator) or a shift_points operation. If the assigned control point is valid, it is kept. If not, a new one is auto-generated.

For all other operations (e.g. symmetric difference, intersection, split), the assigned control point is discarded and a new one auto-generated.

Parameters:

control_point (tuple[float, float]) – An (x, y) coordinate that describes the distinct, contiguous, region of a single material within the geometry.

Returns:

New Geometry object with control_point assigned as the control point

Return type:

Geometry

calculate_area() float#

Calculates the area of the geometry.

Returns:

Geometry area

Return type:

float

calculate_centroid() tuple[float, float]#

Calculates the centroid of the geometry.

Returns:

Geometry centroid

Return type:

tuple[float, float]

calculate_extents() tuple[float, float, float, float]#

Calculate geometry extents.

Calculates the minimum and maximum x and y-values amongst the list of points; the points that describe the bounding box of the Geometry instance.

Returns:

Minimum and maximum x and y-values (x_min, x_max, y_min, y_max)

Return type:

tuple[float, float, float, float]

create_facets_and_control_points() None#

Creates geometry data from shapely data.

Generates points, facets, control points, holes and perimeter from the shapely geometry.

static from_dxf(dxf_filepath: str | Path, spline_delta: float = 0.1, degrees_per_segment: float = 1) Geometry | CompoundGeometry#

An interface for the creation of Geometry objects from CAD .dxf files.

Parameters:
  • dxf_filepath (str | Path) – A path-like object for the dxf file

  • spline_delta (float) – Splines are not supported in shapely, so they are approximated as polylines, this argument affects the spline sampling rate

  • degrees_per_segment (float) – The number of degrees discretised as a single line segment

Returns:

Geometry or CompoundGeometry object

Return type:

Geometry | CompoundGeometry

classmethod from_rhino_encoding(r3dm_brep: str, **kwargs: Any) Geometry#

Load an encoded single surface planer brep.

Parameters:
  • r3dm_brep (str) – A Rhino3dm.Brep encoded as a string.

  • kwargs (Any) – See below.

Keyword Arguments:
  • refine_num (Optional[int]) – Bézier curve interpolation number. In Rhino a surface’s edges are nurb based curves. Shapely does not support nurbs, so the individual Bézier curves are interpolated using straight lines. This parameter sets the number of straight lines used in the interpolation. Default is 1.

  • vec1 (Optional[numpy.ndarray]) – A 3d vector in the Shapely plane. Rhino is a 3D geometry environment. Shapely is a 2D geometric library. Thus a 2D plane needs to be defined in Rhino that represents the Shapely coordinate system. vec1 represents the 1st vector of this plane. It will be used as Shapely’s x direction. Default is [1,0,0].

  • vec2 (Optional[numpy.ndarray]) – Continuing from vec1, vec2 is another vector to define the Shapely plane. It must not be [0,0,0] and it’s only requirement is that it is any vector in the Shapely plane (but not equal to vec1). Default is [0,1,0].

  • plane_distance (Optional[float]) – The distance to the Shapely plane. Default is 0.

  • project (Optional[bool]) – Controls if the breps are projected onto the plane in the direction of the Shapley plane’s normal. Default is True.

  • parallel (Optional[bool]) – Controls if only the rhino surfaces that have the same normal as the Shapely plane are yielded. If true, all non parallel surfaces are filtered out. Default is False.

Raises:

ImportError – If rhino3dm is not installed. To enable rhino features use pip install sectionproperties[rhino].

Returns:

A Geometry object found in the encoded string.

Return type:

Geometry

plot_geometry(labels: tuple[str] = ('control_points',), title: str = 'Cross-Section Geometry', cp: bool = True, legend: bool = True, **kwargs: Any) matplotlib.axes.Axes#

Plots the geometry defined by the input section.

Parameters:
  • labels (tuple[str]) – A tuple of str which indicate which labels to plot. Can be one or a combination of "points", "facets", "control_points", or an empty tuple to indicate no labels.

  • title (str) – Plot title

  • cp (bool) – If set to True, plots the control points

  • legend (bool) – If set to True, plots the legend

  • kwargs (Any) – Passed to plotting_context()

Returns:

Matplotlib axes object

Return type:

matplotlib.axes.Axes

property recovery_points: list[tuple[float, float]] | list[Point]#

Returns the recovery points.

Returns:

Recovery points

shift_points(point_idxs: int | list[int], dx: float = 0.0, dy: float = 0.0, abs_x: float | None = None, abs_y: float | None = None) Geometry#

Shifts the points in the geometry.

Translates one (or many points) in the geometry by either a relative amount or to a new absolute location. Returns a new Geometry representing the original with the selected point(s) shifted to the new location.

Points are identified by their index, their relative location within the points list found in self.points. You can call self.plot_geometry(labels="points") to see a plot with the points labeled to find the appropriate point indexes.

Parameters:
  • point_idxs (int | list[int]) – An integer representing an index location or a list of integer index locations.

  • dx (float) – The number of units in the x-direction to shift the point(s) by

  • dy (float) – The number of units in the y-direction to shift the point(s) by

  • abs_x (float | None) – Absolute x-coordinate in coordinate system to shift the point(s) to. If abs_x is provided, dx is ignored. If providing a list to point_idxs, all points will be moved to this absolute location.

  • abs_y (float | None) – Absolute y-coordinate in coordinate system to shift the point(s) to. If abs_y is provided, dy is ignored. If providing a list to point_idxs, all points will be moved to this absolute location.

Returns:

Geometry object with selected points translated to the new location

Return type:

Geometry

Example

The following example expands the sides of a rectangle, one point at a time, to make it a square:

from sectionproperties.pre.library import rectangular_section

geom = rectangular_section(d=200, b=150)

# using relative shifting
geom_step_1 = geom.shift_points(point_idxs=1, dx=50)

# using absolute relocation
geom_step_1.shift_points(point_idxs=2, abs_x=200).plot_geometry()

(Source code, png, hires.png, pdf)

../_images/sectionproperties-pre-geometry-CompoundGeometry-13.png

Rectangle transformed to a square with shift_points#