py4design.py3dmodel.construct module

py4design.py3dmodel.construct.make_rectangle(xdim, ydim)

This function constructs an OCCface rectangle from the rectangle’s breath and height.

Parameters:
xdim : float

Breath of the rectangle.

ydim : ydim

Height of the rectangle.

Returns:
rectangle : OCCface

An OCCface rectangle constructed from the breath and height.

py4design.py3dmodel.construct.make_box(length, width, height)

This function constructs a box based on the length, width and height.

Parameters:
length : float

Length of box

width : float

Width of box

height : float

Height of box.

Returns:
box : OCCsolid

OCCsolid box constructed based on the length, width and height.

py4design.py3dmodel.construct.make_brep_text(text_string, font_size)

This function constructs a OCCcompound 3D text from a string.

Parameters:
text_string : str

The string to be converted.

font_size : int

The font size.

Returns:
3D text : OCCcompound

An OCCcompound of the 3D text.

py4design.py3dmodel.construct.make_vertex(pypt)

This function constructs an OCCvertex.

Parameters:
pypt : tuple of floats

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

Returns:
vertex : OCCvertex

An OCCvertex constructed from the point

py4design.py3dmodel.construct.make_plane_w_dir(centre_pypt, normal_pydir)

This function constructs a OCCface plane from a centre pt and the normal direction of the plane.

Parameters:
centre_pypt : tuple of floats

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

normal_pydir : tuple of floats

A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)

Returns:
plane : OCCface

An OCCface constructed from the point and direction

py4design.py3dmodel.construct.make_circle(centre_pypt, normal_pydir, radius)

This function constructs an OCCedge circle based on the centre point, the orientation direction and the radius.

Parameters:
centre_pypt : tuple of floats

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

normal_pydir : tuple of floats

A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)

radius : float

Radius of the circle.

Returns:
circle : OCCedge

An OCCedge circle.

py4design.py3dmodel.construct.make_polygon_circle(centre_pypt, normal_pydir, radius, division=10)

This function constructs an polygon circle based on the centre point, the orientation direction and the radius.

Parameters:
centre_pypt : tuple of floats

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

normal_pydir : tuple of floats

A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)

radius : float

Radius of the circle.

distance : float, optional

The smallest distance between two points from the edges, Default = 0.01. The further the distance the less precise is the resultant faces.

Returns:
circle : OCCedge

An OCCedge circle.

py4design.py3dmodel.construct.make_edge(pypt1, pypt2)

This function constructs an OCCedge from two points.

Parameters:
pypt1 : tuple of floats

The starting pt of the edge. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

pypt2 : tuple of floats

The last pt of the edge. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)

Returns:
edge : OCCedge

An OCCedge constructed from the two points

py4design.py3dmodel.construct.make_vector(pypt1, pypt2)

This function create a OCCvector from two points.

Parameters:
pypt1 : tuple of floats

The starting pt of the vector. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

pypt2 : tuple of floats

The last pt of the vector. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)

Returns:
vector : OCCvector(gp_Vec)

The OCCvector(gp_Vec).

py4design.py3dmodel.construct.make_gp_ax3(pypt, pydir)

This function constructs a OCC coordinate system (gp_ax3) with a point and direction.

Parameters:
pypt : tuple of floats

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

pydir : tuple of floats

A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)

Returns:
coordinate system : OCC coordinate (gp_ax3)

An OCC coordinate system (gp_ax3) constructed from the point and direction.

py4design.py3dmodel.construct.make_gppnt(pypt)

This function constructs a OCC point (gp_pnt) with a point.

Parameters:
pypt : tuple of floats

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

Returns:
OCC point : OCC point (gp_pnt)

An OCC point (gp_pnt) constructed from the point.

py4design.py3dmodel.construct.make_line(pypt, pydir)

This function constructs a OCC line (gp_lin) with a point and direction.

Parameters:
pypt : tuple of floats

The starting point of the line. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

pydir : tuple of floats

The direction of the line. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)

Returns:
line : OCC line (gp_lin)

An OCC line (gp_lin) constructed from the point and direction.

py4design.py3dmodel.construct.make_occvertex_list(pyptlist)

This function constructs a list of OCCvertices.

Parameters:
pyptlist : a list of tuples

List of points to be converted. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

Returns:
list of points : list of OCCvertices.

A list of OCCvertices converted from the list of points.

py4design.py3dmodel.construct.make_gppnt_list(pyptlist)

This function constructs a list of OCC points (gp_pnt).

Parameters:
pyptlist : a list of tuples

List of points to be converted. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

Returns:
list of OCC points : list of OCC points (gp_pnt)

A list of OCC points (gp_pnt) converted from the list of points.

py4design.py3dmodel.construct.make_polygon(pyptlist)

This function constructs a OCCface polygon from a list of points.

Parameters:
pyptlist : a list of tuples

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

Returns:
polygon : OCCface

An OCCface constructed from the list of points

py4design.py3dmodel.construct.make_bspline_edge(pyptlist, mindegree=3, maxdegree=8)

This function constructs an bspline OCCedge from a list of points.

Parameters:
pyptlist : a list of tuples

List of points for constructing the edge. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

mindegree : int, optional

The minimun degree of the bspline curve. Default = 3.

maxdegree : int, optional

The maximum degree of the bspline curve. Default = 8.

Returns:
edge : OCCedge

An OCCedge constructed from the list of points

py4design.py3dmodel.construct.make_bspline_edge_interpolate(pyptlist, is_closed)

This function constructs an bspline OCCedge from a list of points.

Parameters:
pyptlist : a list of tuples

List of points for constructing the edge. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

is_closed : bool

True or False whether the edge constructed should be opened or closed.

Returns:
edge : OCCedge

An OCCedge constructed from the list of points. The edge is opened or closed as specified.

py4design.py3dmodel.construct.make_wire(pyptlist)

This function constructs an OCCwire from a list of points.For a closed wire, the last point needs to be the same as the first point.

Parameters:
pyptlist : a list of tuples

List of points for constructing the wire. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

Returns:
wire : OCCwire

An OCCwire constructed from the list of points.

py4design.py3dmodel.construct.circles_frm_pyptlist(pyptlist, radius)

This function constructs a list of OCCedge circles based on the list of centre points and the radius.

Parameters:
pyptlist : a list of tuples

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

radius : float

Radius of the circles.

Returns:
list of circles : list of OCCedge

List of OCCedge circles.

py4design.py3dmodel.construct.delaunay3d(pyptlist, tolerance=1e-06)

This function constructs a mesh (list of triangle OCCfaces) from a list of points. Currently only works for two dimensional xy points.

Parameters:
pyptlist : a list of tuples

The list of points to be triangulated. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

tolerance : float, optional

The minimal surface area of each triangulated face, Default = 1e-06.. Any faces smaller than the tolerance will be deleted.

Returns:
list of face : list of OCCfaces

A list of meshed OCCfaces (triangles) constructed from the meshing.

py4design.py3dmodel.construct.convex_hull3d(pyptlist, return_area_volume=False)

This function constructs a convex hull (list of triangle OCCfaces) from a list of points. The points cannot be coplanar.

Parameters:
pyptlist : a list of tuples

The list of points to be triangulated. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

return_area_volume : bool, optional

If set to True, will only return the area and volume of the hull and not the faces, default = False

Returns:
list of face : list of OCCfaces

A list of meshed OCCfaces (triangles) constructed from the hull. Return faces only when return_area_volume == False.

hull area : float

Area of hull. Return area only when return_area_volume == True.

hull volume : float

Volume of hull. Return volume only when return_area_volume == True.

py4design.py3dmodel.construct.convex_hull2d(pyptlist)

This function constructs a 2d convex hull (list of triangle OCCfaces) from a list of points. Only work on 2d xy points.

Parameters:
pyptlist : a list of tuples

The list of points to be triangulated. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]

Returns:
face : OCCface

A OCCface polygon constructed from the hull.

py4design.py3dmodel.construct.extrude_edge(occedge, pydir, magnitude)

This function creates an extruded OCCface from an OCCedge.

Parameters:
occedge : OCCedge

The OCCedge to be extruded.

pydir : tuple of floats

The direction of the extrusion. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)

magnitude : float

The magnitude of the extrusion.

Returns:
face : OCCface

An OCCface constructed from the extrusion.

py4design.py3dmodel.construct.make_wire_frm_edges(occedge_list)

This function constructs an OCCwire from a list of OCCedges.

Parameters:
occedge_list : a list of OCCedges

List of OCCedge for constructing the wire.

Returns:
wire : OCCwire

An OCCwire constructed from the list of OCCedge.

py4design.py3dmodel.construct.faces_frm_loose_edges(occedge_list)

This function creates a list of OCCfaces from a list of OCCedges. The edges need to be able to form a close face. It does not work with a group of open edges.

Parameters:
occedge_list : list of OCCedges

The list of OCCedges for creating the list of OCCfaces.

Returns:
list of faces : list of OCCfaces

A list of OCCfaces constructed from the list of OCCedges.

py4design.py3dmodel.construct.faces_frm_loose_edges2(occedge_list, roundndigit=6, distance=0.1)

This function creates a list of OCCfaces from a list of OCCedges. The edges need to be able to form a close face. It does not work with a group of open edges. wire_frm_loose_edges2 are for more complex geometries.

Parameters:
occedge_list : list of OCCedges

The list of OCCedges for creating the list of OCCfaces.

roundndigit : int, optional

The number of decimal places of the xyz of the points, Default = 6. The higher the number the more precise are the points. Depending on the precision of the points, it will decide whether the edges are connected.

distance : float, optional

The smallest distance between two points from the edges, Default = 0.01. The further the distance the less precise is the resultant faces.

Returns:
list of faces : list of OCCfaces

A list of OCCfaces constructed from the list of OCCedges.

py4design.py3dmodel.construct.arrange_edges_2_wires(occedge_list, isclosed=False)

This function creates a list of OCCwires from a list of OCCedges. The edges does not need to form a close face.

Parameters:
occedge_list : list of OCCedges

The list of OCCedges for creating the list of OCCwires.

isclosed : bool, optional

True or False, is the resultant wires suppose to be closed or opened.

Returns:
list of wires : list of OCCwires

A list of OCCwires constructed from the list of OCCedges.

py4design.py3dmodel.construct.make_loft_with_wires(occwire_list)

This function lofts a list of OCCwires.

Parameters:
occwire_list : a list of OCCwires

List of OCCwires for the loft.

Returns:
shape : OCCshape

An OCCshape constructed from lofting the list of OCCwires.

py4design.py3dmodel.construct.make_face_frm_wire(occwire)

This function creates an OCCface from an OCCwire.

Parameters:
occwire : OCCwire

The OCCwire for creating the OCCface.

Returns:
face : OCCface

An OCCface constructed from the OCCwire.

py4design.py3dmodel.construct.make_offset(occface, offset_value)

This function offsets an OCCface.

Parameters:
occface : OCCface

OCCface to be offset

offset_value : float

The offset value. A negative value will offset the circle inwards, while a positive value will offset it outwards.

Returns:
offset face : OCCface

The offsetted OCCface.

py4design.py3dmodel.construct.make_offset_face2wire(occface, offset_value)

This function offsets an OCCface and return the wire instead of the face.

Parameters:
occface : OCCface

OCCface to be offset

offset_value : float

The offset value. A negative value will offset the circle inwards, while a positive value will offset it outwards.

Returns:
offset wire : OCCwire

The offsetted OCCwire.

py4design.py3dmodel.construct.grid_face(occface, udim, vdim)

This function creates a list of OCCfaces grids from an OCCface. The OCCface must be planar.

Parameters:
occface : OCCface

The OCCface to be gridded.

udim : int

The x dimension of the grid.

vdim : int

The y dimension of the grid.

Returns:
grids : list of OCCfaces

A list of OCCfaces constructed from the gridding.

py4design.py3dmodel.construct.extrude(occface, pydir, magnitude)

This function creates an extruded OCCsolid from an OCCface.

Parameters:
occface : OCCface

The OCCface to be extruded.

pydir : tuple of floats

The direction of the extrusion. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)

magnitude : float

The magnitude of the extrusion.

Returns:
list of shell : list of OCCshells

An OCCsolid constructed from the extrusion.

py4design.py3dmodel.construct.merge_faces(occface_list, tolerance=1e-06)

This function creates a list of merged OCCfaces from a list of OCCfaces. The function loops through the OCCfaces to search for all possible connected faces and merged them into a single face.

Parameters:
occface_list : a list of OCCfaces

List of OCCfaces that will be looped through in search of all possible connected faces.

tolerance : float, optional

The minimal tolerance to decide if two faces are connected, Default = 1e-06.

Returns:
list of face : list of OCCfaces

A list of merged OCCfaces constructed from the list of OCCfaces.

py4design.py3dmodel.construct.make_loft(occface_list, rule_face=True, tolerance=1e-06)

This function lofts a list of OCCfaces.

Parameters:
occface_list : a list of OCCfaces

List of OCCfaces for the loft.

rule_face : bool, optional

True or False, Default = True. Specify if the loft is a ruled face.

tolerance : float, optional

Specify the tolerance of the loft, Default = 1e-06.

Returns:
shape : OCCshape

An OCCshape constructed from lofting the list of OCCfaces.

py4design.py3dmodel.construct.make_shell(occface_list)

This function creates an OCCshell from a list of OCCfaces. The OCCfaces in the shell might not be connected. For creating an OCCshell that is definitely connected please use sew_faces function.

Parameters:
occface_list : a list of OCCfaces

List of OCCfaces for the shell.

Returns:
shell : OCCshell

An OCCshell constructed from the list of OCCfaces.

py4design.py3dmodel.construct.sew_faces(occface_list, tolerance=1e-06)

This function creates a list of OCCshells from a list of OCCfaces. The function loops through the OCCfaces to search for all possible shells that can be created from the faces.

Parameters:
occface_list : a list of OCCfaces

List of OCCfaces that will be looped through in search of all possible shells.

tolerance : float, optional

Specify the tolerance of the sewing, Default = 1e-06.

Returns:
list of shell : list of OCCshells

A list of OCCshells constructed from the list of OCCfaces.

py4design.py3dmodel.construct.make_occfaces_frm_pypolygons(pypolygon_list)

This function creates a list of OCCfaces from a list of polygons.

Parameters:
pypolygon_list : a 2d list of tuples

List of polygon for constructing the list of faces. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z). A pypolygon is a list of pypt that forms a polygon e.g. [(x1,y1,z1), (x2,y2,z2), …]. A pypolygon_list is a 2d list of tuples e.g. [[(x11,y11,z11), (x12,y12,z12), …], [(x21,y21,z21), (x22,y22,z22), …], …]

Returns:
list of faces : list of OCCfaces

A list of OCCfaces constructed from the list of pypolygons.

py4design.py3dmodel.construct.make_occsolid_frm_pypolygons(pypolygon_list)

This function creates a OCCsolid from a list of connected polygons.

Parameters:
pypolygon_list : a 2d list of tuples

List of connected polygon for constructing the OCCsolid. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z). A pypolygon is a list of pypt that forms a polygon e.g. [(x1,y1,z1), (x2,y2,z2), …]. A pypolygon_list is a 2d list of tuples e.g. [[(x11,y11,z11), (x12,y12,z12), …], [(x21,y21,z21), (x22,y22,z22), …], …]

Returns:
solid : OCCsolid

An OCCsolid constructed from the list of pypolygons.

py4design.py3dmodel.construct.make_solid(occshell)

This function creates a OCCsolid from a OCCshell.

Parameters:
occshell : OCCshell

A closed OCCshell to be converted into OCCsolid.

Returns:
solid : OCCsolid

An OCCsolid constructed from the closed OCCshell.

py4design.py3dmodel.construct.make_solid_from_shell_list(occshell_list)

This function creates a OCCsolid from a list of connected OCCshell.

Parameters:
occshell_list : list of OCCshells

A list of connected closed OCCshell to be converted into OCCsolid.

Returns:
solid : OCCsolid

An OCCsolid constructed from the list of connected closed OCCshell.

py4design.py3dmodel.construct.make_compound(occtopo_list)

This function creates a OCCcompound from a list of OCCtopologies.

Parameters:
occtopo_list : list of OCCtopology

A list of OCCtopologies to be converted into OCCcompound. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

Returns:
compound : OCCcompound

An OCCcompound constructed from the list of OCCtopologies.

py4design.py3dmodel.construct.boolean_common(occtopology1, occtopology2)

This function creates an OCCcompound from intersecting the two OCCtopologies.

Parameters:
occtopology1 : OCCtopology

The OCCtopology to be intersected. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

occtopology2 : OCCtopology

The OCCtopology to be intersected. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

Returns:
compound : OCCcompound

An OCCcompound constructed from the intersection.

py4design.py3dmodel.construct.boolean_fuse(occtopology1, occtopology2)

This function creates an OCCcompound from fusing the two OCCtopologies.

Parameters:
occtopology1 : OCCtopology

The OCCtopology to be fused. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

occtopology2 : OCCtopology

The OCCtopology to be fused. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

Returns:
compound : OCCcompound

An OCCcompound constructed from the fusion.

py4design.py3dmodel.construct.boolean_difference(occstopology2cutfrm, cutting_occtopology)

This function creates an OCCcompound from cutting the two OCCtopologies.

Parameters:
occstopology2cutfrm : OCCtopology

The OCCtopology to be cut. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

cutting_occtopology : OCCtopology

The cutting OCCtopology. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

Returns:
compound : OCCcompound

An OCCcompound constructed from the cutting.

py4design.py3dmodel.construct.boolean_section(section_occface, occtopology2cut, roundndigit=6, distance=0.1)

This function creates an OCCcompound from cutting the OCCtopology with an OCCface.

Parameters:
section_occface : OCCface

The OCCface for cutting the OCCtopology.

occtopology2cut : OCCtopology

The OCCtopology to be cut. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

roundndigit : int, optional

The number of decimal places of the xyz of the points, Default = 6. The higher the number the more precise are the points. Depending on the precision of the points, it will decide whether the edges are connected.

distance : float, optional

The smallest distance between two points from the edges, Default = 0.01. The further the distance the less precise is the resultant faces.

Returns:
compound : OCCcompound

An OCCcompound constructed from the cutting. The OCCcompound is a collection of OCCfaces

py4design.py3dmodel.construct.simple_mesh(occtopology, linear_deflection=0.8, angle_deflection=0.5)

This function creates a mesh (list of triangle OCCfaces) of the OCCtopology. For explaination on what is linear deflection and angle deflection refer to https://www.opencascade.com/doc/occt-7.1.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11_2

Parameters:
occtopology : OCCtopology

The OCCtopology to be meshed. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

mesh_incremental_float : float, optional

Default = 0.8.

Returns:
list of face : list of OCCfaces

A list of meshed OCCfaces (triangles) constructed from the meshing.

py4design.py3dmodel.construct.tessellator(occtopology)

This function creates a mesh (list of triangle OCCfaces) of the OCCtopology.

Parameters:
occtopology : OCCtopology

The OCCtopology to be meshed. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

Returns:
list of face : list of OCCfaces

A list of meshed OCCfaces (triangles) constructed from the meshing.

py4design.py3dmodel.construct.mesh_3d(occtopology, stl_filepath)

This function creates a mesh (list of triangle OCCfaces) of the OCCtopology.

Parameters:
occtopology : OCCtopology

The OCCtopology to be meshed. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

Returns:
list of face : list of OCCfaces

A list of meshed OCCfaces (triangles) constructed from the meshing.