Module Contents#

ifcopenshell.util.shape_builder.PRECISION = 1e-05#
class ifcopenshell.util.shape_builder.ShapeBuilder(ifc_file: ifcopenshell.file)#
circle(self, center: mathutils.Vector = Vector((0.0, 0.0)).freeze(), radius: float = 1.0) ifcopenshell.entity_instance#
  • center (Vector, optional) – circle 2D position, defaults to zero-vector

  • radius (float, optional) – radius of the circle, defaults to 1.0



Return type


create_ellipse_curve(self, x_axis_radius, y_axis_radius, position=Vector((0.0, 0.0)).freeze(), trim_points=[], ref_x_direction=Vector((1.0, 0.0)), trim_points_mask=[])#

Ellipse trimming points should be specified in counter clockwise order.

For example, if you need to get the part of the ellipse ABOVE y-axis, you need to use mask (0,2). Below y-axis - (2,0)

For more information about trim_points_mask check builder.get_trim_points_from_mask

Notion: trimmed ellipse also contains polyline between trim points, meaning IfcTrimmedCurve could be used for further extrusion.

create_swept_disk_solid(self, path_curve, radius)#

Create IfcSweptDiskSolid from path_curve (must be 3D) and radius

create_transition_arc_ifc(self, width, height, create_ifc_curve=False)#
create_z_profile_lips_curve(self, FirstFlangeWidth, SecondFlangeWidth, Depth, Girth, WallThickness, FilletRadius)#
curve_between_two_points(self, points)#

Simple circle based curve between two points Good for creating curves and fillets, won’t work for continuous ellipse shapes.

deep_copy(self, element)#
extrude(self, profile_or_curve, magnitude=1.0, position: mathutils.Vector = Vector([0.0, 0.0, 0.0]).freeze(), extrusion_vector: mathutils.Vector = Vector((0.0, 0.0, 1.0)).freeze(), position_z_axis: mathutils.Vector = Vector((0.0, 0.0, 1.0)).freeze(), position_x_axis: mathutils.Vector = Vector((1.0, 0.0, 0.0)).freeze(), position_y_axis: mathutils.Vector = None)#

Extrude profile or curve to get IfcExtrudedAreaSolid.

REMEMBER when handling custom axes - IFC is using RIGHT handed coordinate system.

Position and position axes are in world space, extrusion vector in placement space defined by position_x_axis/position_y_axis/position_z_axis

NOTE: changing position also changes the resulting geometry origin.

extrude_face_set(self, points, magnitude: float, extrusion_vector=V(0, 0, 1).freeze(), offset=None, start_cap=True, end_cap=True)#

Method to extrude by creating face sets rather than creating IfcExtrudedAreaSolid.

Useful if your representation is already using face sets and you need to avoid using SweptSolid to assure CorrectItemsForType.

  • points – list of points, assuming they form consecutive closed polyline.

  • magnitude – extrusion magnitude

  • type – float

  • extrusion_vector – extrusion direction, by default it’s extruding by Z+ axis

  • type – Vector, optional

  • offset – offset from the points

  • type – Vector, optional

  • start_cap – if True, create start cap, by default it’s True

  • type – bool, optional

  • end_cap – if True, create end cap, by default it’s True

  • type – bool, optional



extrude_kwargs(self, axis)#

Shortcut to get kwargs for ShapeBuilder.extrude to extrude by some axis.

It assumes you have 2D profile in:

XZ plane for Y axis extrusion,

YZ plane for X axis extrusion,

XY plane for Z axis extrusion,

Extruding by X/Y using other kwargs might break ValidExtrusionDirection.

get_axis2_placement_3d_matrix(self, axis2_placement_3d)#
get_polyline_coords(self, polyline)#

polyline should be either IfcIndexedPolyCurve or IfcPolyline

get_rectangle_coords(self, size: mathutils.Vector = Vector((1.0, 1.0)).freeze(), position: mathutils.Vector = None) List[mathutils.Vector]#

Get rectangle coords arranged as below:

3 2
0 1
  • size (Vector, optional) – rectangle size, could be either 2d or 3d, defaults to (1,1)

  • position (Vector, optional) – rectangle position, default to None. if position not specified zero-vector will be used


list of rectangle coords

Return type


get_representation(self, context, items, representation_type: str = None) ifcopenshell.entity_instance#

Create IFC representation for the specified context and items.

  • context – IfcGeometricRepresentationSubContext

  • items – could be a list or single curve/IfcExtrudedAreaSolid

  • representation_type (str, optional) – Explicitly specified RepresentationType, defaults to None. If not provided it will be guessed from the items types



Return type


get_simple_2dcurve_data(self, coords, fillets=[], fillet_radius=[], closed=True, create_ifc_curve=None)#

Creates simple 2D curve from set of 2d coords and list of points with fillets. Simple curve means that all fillets are based on 90 degree angle.

> coords: list of 2d coords. Example: ((x0,y0), (x1,y1), (x2, y2)) > fillets: list of points from coords to base fillet on. Example: (1,) > fillet_radius: list of fillet radius for each of corresponding point form fillets. Example: (5.,) Note: filler_radius could be just 1 float value if it’s the same for all fillets.

Optional arguments: > closed: boolean whether curve should be closed (whether last point connected to first one). Default: True > create_ifc_curve: create IfcIndexedPolyCurve or just return the data. Default: False

< returns (points, segments, ifc_curve) for the created simple curve if both points in e are equally far from pt, then v1 is returned.

get_trim_points_from_mask(self, x_axis_radius, y_axis_radius, trim_points_mask, position_offset=None)#

Handy way to get edge points of the ellipse like shape of a given radiuses.

Mask points are numerated from 0 to 3 ccw starting from (x_axis_radius/2; 0).

Example: mask (0, 1, 2, 3) will return points (x, 0), (0, y), (-x, 0), (0, -y)

mep_bend_shape(self, segment, start_length: float, end_length: float, angle: float, radius: float, bend_vector: mathutils.Vector, flip_z_axis: bool) ifcopenshell.entity_instance#
  • segment (ifcopenshell.entity_instance) – IfcFlowSegment for a bend. Note that for a bend start and end segments types should match.

  • angle (float) – bend angle, in radians

  • radius (float) – bend radius

  • bend_vector (Vector) – offset between start and end segments in local space of start segment used mainly to determine the second bend axis and it’s direction (positive or negative), the actual magnitude of the vector is not important (though near zero values will be ignored).

  • flip_z_axis (bool) – since we cannot determine z axis direction from the profile offset, there is an option to flip it if bend is going by start segment Z- axis.


tuple of Model/Body/MODEL_VIEW IfcRepresentation and transition shape data

mep_transition_calculate(self, start_half_dim, end_half_dim, offset, diff=None, end_profile=False, angle=None, length=None, verbose=True)#

will return transition length based on the profile dimension differences and offset.

If length is provided will return transition angle

mep_transition_length(self, start_half_dim, end_half_dim, angle, profile_offset=V(0, 0).freeze(), verbose=True)#

get the final transition length for two profiles dimensions, angle and XY offset between them,

the difference from calculate_transition - get_transition_length is making sure that length will fit both sides of the transition

mep_transition_shape(self, start_segment, end_segment, start_length, end_length, angle=30.0, profile_offset=V(0, 0).freeze())#

returns tuple of Model/Body/MODEL_VIEW IfcRepresentation and transition shape data

mirror(self, curve_or_item, mirror_axes: mathutils.Vector = Vector((1.0, 1.0)).freeze(), mirror_point: mathutils.Vector = Vector((0.0, 0.0)).freeze(), create_copy=False, placement_matrix=None)#

mirror_axes - along which axes mirror will be applied

For example, mirroring A(1,0) by axis (1,0) will result in A’(-1,0)

mirror_2d_point(self, point_2d: mathutils.Vector, mirror_axes: mathutils.Vector = Vector((1.0, 1.0)).freeze(), mirror_point: mathutils.Vector = Vector((0.0, 0.0)).freeze())#

mirror_axes - along which axes mirror will be applied

plane(self, location: mathutils.Vector = Vector((0.0, 0.0, 0.0)).freeze(), normal: mathutils.Vector = Vector((0.0, 0.0, 1.0)).freeze())#
polygonal_face_set(self, points, faces)#

> points - list of points

> faces - list of faces consisted of point indices (points indices starting from 0)

< IfcPolygonalFaceSet

polyline(self, points: List[mathutils.Vector], closed: bool = False, position_offset: mathutils.Vector = None, arc_points: List[int] = []) ifcopenshell.entity_instance#

Generate an IfcIndexedPolyCurve based on the provided points.

  • points (List[Vector]) – List of 2d or 3d points

  • closed (bool, optional) – Whether polyline should be closed. Default is False

  • position_offset (Vector, optional) – offset to be applied to all points

  • arc_points (List[int], optional) – Indices of the middle points for arcs. For creating an arc segment, provide 3 points: arc_start, arc_middle and arc_end to points and add the arc_middle point’s index to arc_points



Return type



# rectangle
points = Vector((0, 0)), Vector((1, 0)), Vector((1, 1)), Vector((0, 1))
position = Vector((2, 0))
# #2=IfcIndexedPolyCurve(#1,(IfcLineIndex((1,2,3,4,1))),$)
polyline = builder.polyline(points, closed=True, position_offset=position)

# arc between points (1,0) and (0,1). Second point in the arc should be it's middle
points = Vector((1, 0)), Vector((0.707, 0.707)), Vector((0, 1)), Vector((0,2))
arc_points = (1,) # point with index 1 is a middle of the arc
# 4=IfcIndexedPolyCurve(#3,(IfcArcIndex((1,2,3)),IfcLineIndex((3,4,1))),$)
curved_polyline = builder.polyline(points, closed=False, position_offset=position, arc_points=arc_points)
profile(self, outer_curve, name=None, inner_curves=[], profile_type='AREA')#
rectangle(self, size: mathutils.Vector = Vector((1.0, 1.0)).freeze(), position: mathutils.Vector = None) ifcopenshell.entity_instance#

Generate a rectangle polyline.

  • size (Vector, optional) – rectangle size, could be either 2d or 3d, defaults to (1,1)

  • position (Vector, optional) – rectangle position, default to None. if position not specified zero-vector will be used



Return type


rotate(self, curve_or_item, angle=90, pivot_point: mathutils.Vector = Vector((0.0, 0.0)).freeze(), counter_clockwise=False, create_copy=False)#
rotate_2d_point(self, point_2d: mathutils.Vector, angle=90, pivot_point: mathutils.Vector = Vector((0.0, 0.0)).freeze(), counter_clockwise=False)#
rotate_extrusion_kwargs_by_z(self, kwargs, angle, counter_clockwise=False)#

shortcut to rotate extrusion kwargs by z axis

kwargs expected to have position_x_axis and position_z_axis keys

angle is a rotation value in radians

by default rotation is clockwise, to make it counter clockwise use counter_clockwise flag

set_polyline_coords(self, polyline, coords)#

polyline should be either IfcIndexedPolyCurve or IfcPolyline

sphere(self, radius: float = 1.0, center: mathutils.Vector = Vector((0, 0, 0)).freeze()) ifcopenshell.entity_instance#
  • radius (float, optional) – radius of the sphere, defaults to 1.0

  • center (Vector, optional) – sphere position, defaults to zero-vector



Return type


translate(self, curve_or_item, translation: mathutils.Vector, create_copy=False)#
ifcopenshell.util.shape_builder.is_x(value, x, si_conversion=None)#