Table Of Contents

Previous topic

4.6. bdgroup Package

Next topic

5. Test Pages

This Page

4.7. bdtool Package

4.7.1. bdtool Package

__init__.py Initialization file for BDTool package.

BDTool Provides tools that are used in Buildes

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>

This is a description of what the following modules do. This information is important to understand the structure and relationship between the various parts of buildes.

  • doc
  • kalk
  • kerror
  • misc
  • modelview
  • qthelpers
  • transform

The doc module provides the Doc object which is used to store all building components created when buildes is executed.

4.7.2. doc Module

Document Tools

Manages the storage of objects for use in Buildes.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
class bdtool.doc.Document

Bases: object

Provides objects to manage the storage of building components.

../_images/document.png
add(obj)

Adds the provided object to storage.

Parameter:obj (object) – Building component
adjust_count(otype)

Adjust count for object type.

Parameter:otype
count(otype)

Update the count for object type

The document keeps count of various components. At this time it is not for any particular reason but information that seems interesting.

Parameter:otype (String) – Type of object in storage.
find(name)

Returns an object in storage

Parameter:name (String) – Unique identifier for an object
Returns:An object in storage
Return type:object
replace(new_obj, old_name=None)

Replace object in storage with a new version.

If old_name is provided, this first replaces the old_name key in dictionary. Then updates the value with the the new object. Otherwise it assumes new_obj has the same name as the object to replace in dictionary.

Parameters:
  • old_name (String) – Name of object currently in storage.
  • new_obj (BuildesData) – New object to be stored.

4.7.3. kalk Module

Kalk-ulations

Provides calculations necessary to create building information using buildes.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
class bdtool.kalk.SpreadSheet

Bases: object

Spreadsheet object.

../_images/spreadsheet.png
get_cell(key)

Return formula for the given key (cell).

Parameter:key
Returns:Cell content that is a formula
Return type:Math
get_formula(key)

Return formula for the given key (cell).

Parameter:key
Returns:Cell content that is a formula
Return type:Math
set_formula(formula)

Dummy method to keep pylint at bay for now

Parameter:formula
class bdtool.kalk.Vector(x, y)

Bases: object

Provides a vector class that only has the attributes x, y. It prevents the creation of __dict__. In this way it does a lot of things one of which is occupies less memory.

../_images/vector.png
angle(vec)

Angle (0 to +/- 180 degrees) of a line defined by two vectors.

This assumes that the vertical, parallel to y axis, is at 0 degrees.

angle_deg(vec)

Angle (in degrees) between two lines defined by two vectors.

It is assumed that vec is a vector. This means that the center of both coordinates is the origin (i.e. 0,0)

Parameter:vec (Vector) – Other vector
Returns:Angle in degrees
Return type:Float
angle_rad(vec)

Angle (in radians) between two lines defined by two vectors.

It is assumed that vec is a vector. This means that the center of both coordinates is at the origin (i.e. 0,0)

Parameter:vec (Vector) – Other vector
Returns:Angle in radians
Return type:Float
bounce(vec)
clockwise(vec, ori=None)

Whether vector is clockwise to self.

It is assumed that the rotation is around the origin.

For 2 vectors a = (ax, ay), b = (bx, by) compute cz = (ax * by) - (ay * bx) if cz > 0 then b is on the CCW side of a. If cz < 0 then b is on the CW side of a. If cz = 0 then a and b are parallel.

The reasoning behind this formula is that you can consider the 2D vectors as 3D vectors in the x/y plane: a = (ax, ay, 0), b = (bx, by, 0). The cz component of the vector product

c = axb = (0, 0, axby - aybx)

characterizes the orientation of the vectors a, b with respect to each other.

Parameters:
  • vec (Vector) – 2D point to determine relationship to self
  • ori (Vector | None) – 2D point
Returns:

Less than 0 if CW, more than 0 if CCW and 0 if collinear.

Return type:

<0 | >0 | 0

copy()
cross(vec)
cross_product(vec)
degrees
Virtual “degrees” Attribute
direction
Virtual “direction” Attribute
dist(vec)
Return distance between vectors
dot(vec)
dot_product(vec)
interpolate(vec, bias)
inverse()
is_xless(vec)

Check if self is on the left of vec.

Parameter:vec (Vector) – Coordinate with placement to be determined.
Returns:True or False.
Return type:Boolean
is_xmore(vec)

Check if self is on the right of vec.

Parameter:vec (Vector) – Coordinate with placement to be determined.
Returns:True or False.
Return type:Boolean
is_yless(vec)

Check if self is below vec.

Parameter:vec (Vector) – Coordinate with placement to be determined.
Returns:True or false.
Return type:Boolean
is_ymore(vec)

Check if self is above vec.

Parameter:vec (Vector) – Coordinate with placement to be determined.
Returns:True or false.
Return type:Boolean
lerp(vec, bias)
magnitude
Virtual “magnitude” Attribute
mid(vec)

Middle coordinates of a line segment

Parameter:vec
Returns:x and y coordinates at midpoint
Return type:?
near(dist)
normalize()
orient(vec)

Orientation (0 - 360 degrees) of a line defined by two coords.

This assumes that the vertical, parallel to y axis, is at 0 degrees.

perp()
perpendicular()
polar_repr()
project(vec)
reflect(vec)
rotate(vec)
slope(vec)
Slope (in radians) of a line defined by two coords.
subset(vec1, vec2)
unit()
unit_vector()
x
xy
Virtual “xy” Attribute
y
yx
Virtual “yx” Attribute
bdtool.kalk.arc_arc_cross(pnt1, rad1, pnt2, rad2)

Calculate the intersection between two circles.

../_images/arcArcCross.png

Finding intersection between circles

pnt1 and rad1 are the center and radius of the first circle. p2 and rad2 are the center and radius of the second circle. p3 is the point where the line through the circle intersection points crosses the line between the circle centers. p4 is either of the two points where the two circle intersect.

Parameters:
  • pnt1 (Vector) – Center of the first circle.
  • rad1 (Float) – Radius of the first circle.
  • pnt2 (Vector) – Center of the second circle.
  • rad2 (Float) – Radius of the second circle.
Returns:

A boolean with one or two vectors.

Return type:

None | [True, Vector, Vector]

bdtool.kalk.arc_length(radius, angle_in_radians)

Returns length of arc

Parameters:
  • radius (Float) – Radius of the circle
  • angle_in_radians (Float) – Subtended Angle in radians
Returns:

A numberic value

Return type:

Float

bdtool.kalk.arc_mid(pnt1, pnt2, cen, cen_angle=None)

Returns the mid point of provided arc

Parameters:
  • pnt1 (Vector) – The startpoint for the arc
  • pnt2 (Vector) – The endpoint of the arc
  • cen (Float) – Coordinates at the center of the arc
  • cen_angle – Arc subtended angle
Returns:

Coordinates at the mid point of arc

Return type:

Vector

bdtool.kalk.edge_parallel(edge1p1, edge1p2, edge2p1, edge2p2)

Check whether the provided edges are parallel.

Assumming that the first edge is vertical, we test for whether the second edge is vertical or not. Then we assume the second edge is vertical and test for whether the first edge is vertical or not. Finally we get the slope of the two edges and test whether or not they are the same.

Parameters:
  • edge1p1 (Vector) – First point on first edge.
  • edge1p2 (Vector) – Second point on first edge.
  • edge2p1 (Vector) – First point on second edge.
  • edge2p2 (Vector) – Second point on second edge.
Returns:

Whether the edges are parallel.

Return type:

Boolean

bdtool.kalk.eq(afloat, bfloat)

Test to see if two floats are equal.

Parameters:
  • afloat (Float) – Float to determine if same as other.
  • bfloat (Float) – Float to determine if same as other.
Returns:

Whether the provided floats are equal.

Return type:

Boolean

bdtool.kalk.gt(afloat, bfloat)

Test to see if float afloat is greater than float bfloat.

Subtract ‘bfloat’ from ‘afloat’. If the real difference is greater than EPSILON, then ‘afloat’ is significantly greater than ‘bfloat’.

Parameters:
  • afloat (Float) – Float to determine if greater than other
  • bfloat (Float) – Float to determine if greater than other
Returns:

Whether afloat is greater than bfloat.

Return type:

Boolean

bdtool.kalk.horizontal_placement(vec, vec_list)

Returns the horizontal placement of vec in relation to others in list.

Parameters:
  • vec (Vector) – 2D point coordinates.
  • vec_list (List) – 2D coorinates of two or more points.
Returns:

Horizontal position as ‘left’, ‘right’ or ‘none’.

Return type:

String

bdtool.kalk.in_polygon(point, poly, on_vertex=False, on_edge=False)

Determine if point is inside a polygon.

Checks if point is inside the boundary created by the points in poly. By default it considers points on a vertex and on any of the edges to be outside the polygon. The caller can change this default by providing appropriate on_vertex and on_edge flags.

Adapted from http://www.ariel.com.au/a/python-point-int-poly.html

Parameters:
  • point (Vector) – Point to check whether inside polygon.
  • poly (List) – Collection of vectors that define a closed polygon.
  • on_vertex (Boolean) – Flag to consider if point is on a vertex.
  • on_edge (Boolean) – Flag to consider if point is on an edge.
Returns:

Whether point is inside the polygon.

Return type:

Boolean

bdtool.kalk.in_sector(pnt0, pnt1, pnt2, cen, cen_angle=None)

Check if the provided point (pnt0) is inside sector.

This solution is based on the observation that the sum of the subtended angles between (pnt0, pnt1) and (pnt0, pnt2) must equal that for (pnt1, pnt2) which is angle at center of the sector. If the center angle is not provided, it is assumed to be less than 180.

Limitations

  • Does not check if point is on the edges or verteces.
Parameters:
  • pnt0 (Vector) – 2D point to be checked.
  • pnt1 (Vector) – 2D point at one end of arc.
  • pnt2 (Vector) – 2D point at other end of arc.
  • cen (Vector) – 2D point at center of arc.
  • cen_angle (Float) – Arc’s subtended angle.
Returns:

Whether point (pnt0) is on arc (pnt1, pnt2) with center at cen.

Return type:

Boolean

bdtool.kalk.in_sector1(pnt, sec_start, sec_end, radius)

Check whether a point is inside a sector

Based on Oren Trutner’s answer on finding points inside sectors at Stackoverflow.

Untested

Notes, caveats and limitations

  • You have to specify the boundaries of the sector in terms of vectors.
  • The logic here works for sectors with an inner angle of less than 180

degrees. If your sectors can span a larger angle, you’ll have to modify it.

  • Additionally, the code assumes that you know which of the bounding

vectors of the sector is the “start” and which is the “end”. If you don’t, you can run Vector.clockwise() on them to find out.

Parameters:
  • pnt (Vector) – Query point
  • sec_start (Vector) – Start of sector
  • sec_end (Vector) – End of sector
  • radius (Float) – Radius of sector
Returns:

Whether pnt is inside sector

Return type:

Boolean

bdtool.kalk.line_arc_cross(line_p1, line_p2, arc_cen, arc_rad)

Find the intersection(s) between line and arcd edges.

If there is no intersection None is returned otherwise eqn_a list containing the number of intersections and the coordinates at the intersection(s) is returned.

Adapted solution at http://paulbourke.net/geometry/circlesphere/

Points (P) on eqn_a line defined by two points (P1, P2) is described by: P = P1 + u(P2 - P1)

or for each coordinate: x = x1 + u(x2 - x1) y = y1 + u(y2 - y1)

Equation for circle centered at P3 (x3, y3) with radius (r) is described by: (x - x3)^2 + (y - y3)^2 = (r)^2

Substituting line equation into circle equation: eqn_a = (x - x3)^2 + (y - y3)^2 eqn_b = 2[(x2 - x1)(x1 - x3) + (y2 - y1)(y1 - y3)] eqn_c = (x3)^2 + (y3)^2 + (x1)^2 + (y1)^2 - 2[x3 * x1 + y3 * y1] - (r)^2

Determine if there are intersection(s): conn_pnt = eqn_b * eqn_b - 4 * eqn_a * eqn_c

Parameters:
  • line_p1 (Vector) – First coordinates on line edge.
  • line_p2 (Vector) – Second coordinates on line edge.
  • arc_cen (Vector) – Coordinates at center of arc.
  • arc_rad (Float) – Radius of arc.
Returns:

Number of intersections and 2D points of intersection.

Return type:

None | [1, Vector] | [2, Vector, Vector]

bdtool.kalk.line_line_cross(e1p1, e1a, e2p1, e2p2)

Find intersection of two line edges.

Calculate the point where two infinitely long edges (e1p1 to e1p2 and e2p1 to e2p2) intersect. Handle parallel edges and vertical edges (the later has infinite ‘m’). Returns None or a tuple of the length from intersection to e1p1 and the coords at intersection. In non parallel cases the there is only one intersection point. For parallel lines that lay on top of one another the return will be the provided three points from the two edges.

In this routine it is assumed that only one point is known from the first edge. The second point along the edge is automatically obtained before continuing with the rest of the routine.

Parameter:e1p1 – First point for the first edge.

:type e1p1:Vector :param e1a: Angle for the first edge :type e1a: Float :param e2p1: First point for the second edge. :type e2p1: Vector :param e2p2: Second point for the second edge :type e2p2: Vector :returns: Length and coordinates at intersection. :rtype: None | (Float, Vector)

bdtool.kalk.lt(afloat, bfloat)

Test to see if float afloat is less than float bfloat.

Subtract ‘bfloat’ from ‘afloat’ and test if the absolute difference is greater than EPSILON.

Parameters:
  • afloat (Float) – Float to determine if less than other
  • bfloat (Float) – Float to determine if less than other
Returns:

Whether float afloat is less than float bfloat.

Return type:

Boolean

bdtool.kalk.on_arc(pnt0, pnt1, pnt2, cen, cen_angle=None)

Check if the provided point (pnt0) is on the arc.

This solution is based on the observation that the sum of the subtended angles between (pnt0, pnt1) and (pnt0, pnt2) must equal that for (pnt1, pnt2) which is angle at center of the arc. If the center angle of the arc (cen_angle) is not provided, it is assumed to be less than 180.

Parameters:
  • pnt0 (Vector) – 2D point to be checked.
  • pnt1 (Vector) – 2D point at start of arc.
  • pnt2 (Vector) – 2D point at end of arc.
  • cen (Vector) – 2D point at center of arc.
  • cen_angle (Float) – Arc’s subtended angle.
Returns:

Whether point (pnt0) is on arc (pnt1, pnt2) with center at cen.

Return type:

Boolean

bdtool.kalk.on_segment(pnt0, pnt1, pnt2, epi=0.01)

Check if the provided point (pnt0) is in the line segment (pnt1, pnt2).

Check if cross product of (pnt2 - pnt1) and (pnt0 - pnt1) is 0, answers whether points pnt1, pnt2 and pnt0 are aligned/colinear. But, need to know if pnt0 is between pnt1 and pnt2. So check that the dot product of (pnt2 - pnt1) and (pnt0 - pnt1) is positive and is less than the square of the distance between pnt1 and pnt2.

Parameters:
  • pnt0 (Vector) – 2D point to be checked.
  • pnt1 (Vector) – 2D point designating the first point of line segment.
  • pnt2 (Vector) – 2D point designating the second point of line segment.
Returns:

Whether point (pnt0) is anywhere on line (pnt1, pnt2).

Return type:

Boolean

bdtool.kalk.polar2(magnitude, degrees)
bdtool.kalk.polygon_area(corners)

Calculate the area of a polygon

As an added bonus this function also determines if the corners of the polygon is provided in clockwise or counter clockwise direction. If Boolean is true, polygon was described in a clockwise direction otherwise in a counter-clockwise direction.

Adapted from http://paulbourke.net/geometry/polygonmesh/

Parameter:corners (List) – List of vectors designating corners of polygon.
Returns:Area of polygon and direction of bounded corners.
Return type:(Boolean, Area)
bdtool.kalk.polygon_center(corners)

Calculate center of mass for a polygon.

Adapted from http://paulbourke.net/geometry/polygonmesh/

Parameter:corners (List) – List of vectors designating corners of polygon.
Returns:Coordinates at center of mass
Return type:Vector
bdtool.kalk.rotated_length_coords(angle, length, off=None)

Calculates 2D coordinates of point at length and angle.

../_images/rotLenCoords.png

Calculate coordinates by angle and length

This routine will calculate the coordinates of a point at a length and angle from another point. If off is not provided, the desired point B is oriented from the origin as shown in AB. If off is a float (distance AC at 90 degrees relative to AB), then the desired point D is offset from the origin as shown in CD. Alternately, to get the desired point D, off can be a vector which designates the point C.

Parameters:
  • angle (Float) – Rotation in degrees.
  • length (Float) – Length from origin.
  • off (Float/Vector) – Offset distance or point.
Returns:

2D coordinates at point B.

Return type:

Vector

bdtool.kalk.sector_area(radius, angle_in_radians)

Returns area of a sector

Parameters:
  • radius (Float) – Radius of the circle
  • angle (Float) – Subtended angle in radians
Returns:

A numberic value

Return type:

Float

bdtool.kalk.segment_area(radius, angle_in_radians)

Returns area of a segment of a circle

Parameters:
  • radius (Float) – Radius of the circle
  • angle_in_radians (Float) – Subtended angle in radians
Returns:

A numberic value

Return type:

Float

bdtool.kalk.select_bottom_vector(vec_list)

Select the bottom-most vector from list of two vectors.

Parameter:vec_list (List) – Two 2D vectors
Returns:Whether there is one as well as the vector itself.
Return type:None | (True, Vector)
bdtool.kalk.select_left_vector(vec_list)

Select the left-most vector from list of two vectors.

Parameter:vec_list (List) – Two 2D vectors
Returns:Whether there is one as well as the vector itself.
Return type:None | (True, Vector)
bdtool.kalk.select_right_vector(vec_list)

Select the right-most vector from list of two vectors.

Parameter:vec_list (List) – Two 2D vectors
Returns:Whether there is one as well as the vector itself.
Return type:None | (True, Vector)
bdtool.kalk.select_top_vector(vec_list)

Select the top-most vector from list of two vectors.

Parameter:vec_list (List) – Two 2D vectors
Returns:Whether there is one as well as the vector itself.
Return type:None | (True, Vector)
bdtool.kalk.select_vector(symbol, options)

Select the intersection from options using symbol.

When there are more than one intersection points such as when a arc is involved, the following symbols can be used in selecting the preferred point.

../_images/cIntOptions.png

Selecting Intersection on Arc Objects

There are 4 valid symbols each of which include a short and long version. These are l or left, r or right, t or top and finally b or bottom. Using this system Figures 1 – 5 show how intersections between line and arc objects can be designated.

Parameters:
  • symbol (String) – Designation for desired intersection.
  • options (List) – Contains a boolean and one or two vectors.
Returns:

A flag and a coordinate point.

Return type:

None | (True, Vector)

bdtool.kalk.sqr(val)

Returns the square of the provided value.

Helper for squaring values. Avoiding overhead of external function calls

Parameter:val (Float) – Value to be squared.
Returns:Square of value.
Return type:Float
bdtool.kalk.vertical_placement(vec, vec_list)

Returns the vertical placement of vec in relation to others in list.

Parameters:
  • vec (Vector) – 2D point coordinates.
  • vec_list (List) – 2D coordinates of two or more points.
Returns:

Vertical position as ‘up’, ‘down’ or ‘none’.

Return type:

String

4.7.4. kerror Module

Buildes Exceptions

Provides exception definitions for buildes.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
exception bdtool.kerror.AttributeError
Bases: bdtool.kerror.BuildesError
exception bdtool.kerror.BuildesError
Bases: exceptions.Exception
exception bdtool.kerror.FixateError
Bases: bdtool.kerror.BuildesError
exception bdtool.kerror.OffsetError
Bases: bdtool.kerror.BuildesError
exception bdtool.kerror.PlacementError
Bases: bdtool.kerror.BuildesError
exception bdtool.kerror.SnapLabelError
Bases: bdtool.kerror.BuildesError

4.7.5. makehtml Module

MakeHTML

Has the resources to make html code for buildes program

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
class bdtool.makehtml.Table

Bases: object

Provides the resources to create an html table

border(val=2)

Value for the borders

Parameter:val
Returns:
Return type:
borders(val=2)

Value for the borders

Parameter:val
Returns:
Return type:
header(headers)

Create header for the table

Parameter:headers
Returns:
Return type:
headers(headers)

Create header for the table

Parameter:headers
Returns:
Return type:
padding(val=1)

Value for the borders

Parameter:val
Returns:
Return type:
row(cols=None)

Adds a new row to the table body

Parameter:cols
Returns:
Return type:
rows(cols=None)

Adds a new row to the table body

Parameter:cols
Returns:
Return type:
spacing(val=1)

Value for the borders

Parameter:val
Returns:
Return type:
table()

Returns a table body

Returns:
Return type:
bdtool.makehtml.boldsize(string, size=None)
Optionally change the size of text and make it bold
bdtool.makehtml.br(string=None)
Insert a break in a line of text
bdtool.makehtml.color(string, col)
Change the color of text
bdtool.makehtml.font(string, face)
Change the font face of text
bdtool.makehtml.header(string, level=1)

Return a header line for selected level

Level 1 is the default if no level is provided.

Parameters:
  • string
  • level (Number) – Header level number
Returns:

HTML code for rendering string

Return type:

HTML

bdtool.makehtml.hl()
Insert a horizontal line
bdtool.makehtml.hspace(number)

Return space codes for the desired number

Parameter:number
Returns:
Return type:
bdtool.makehtml.it(string)
Change text to italics
bdtool.makehtml.iurl(link, descr=None)

Return internet url with provided information

The url link created opens in the parent browser window

Parameters:
  • link (String) – The desired url
  • descr (String) – Description associated with the url
Returns:

HTML code for rendering URL

Return type:

HTML

bdtool.makehtml.olist(list_obj, list_string=None)

Create an ordered list

Can produce list to any desired depth. Just provide list_obj that contains lists.

Parameters:
  • list_obj (List) – Words to be formatted
  • list_string (None | List) – Container for the formatted html
bdtool.makehtml.par(string)
Insert a paragraph in a body of text
bdtool.makehtml.sym(string)

Return symbol for provided string

Parameter:string
Returns:HTML code for rendering String
Return type:HTML
bdtool.makehtml.tt(txt)
Short cute to change the font of text to mono
bdtool.makehtml.txtsize(string, size)
Change the size of text
bdtool.makehtml.uline(string)

Return the string underlined

Parameter:string
Returns:HTML code for rendering string
Return type:HTML
bdtool.makehtml.ulist(list_obj, list_string=None)

Create un-ordered list

Can produce list to any desired depth. Just provide list_obj that contains lists.

Parameters:
  • list_obj (List) – Words to be formatted
  • list_string (None | List) – Container for the formatted html

4.7.6. misc Module

Miscellaneous Tools

This module provides miscellaneous functions that do not belong to any specific area or activity with regards to building design or construction.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
bdtool.misc.check_side_width(width)

Check that width for a side object is more than zero

All side objects must have a non-zero width or thickness. This routine helps to make sure of this.

Parameter:width (Float) – The width of the side in question
Returns:Whether width is a number and is more than zero value
Return type:Boolean
bdtool.misc.checkconnect(app, arg)

Check parameter for a snap and an edge designations.

Although a point mark object has “p” as part of its snap point designation, it does not have an edge. This routine returns false if a pointmark is used in the second argument.

Parameter:arg (List) – Contains a snap and an edge designation.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checkconnect_adj(app, arg)

Check parameter for a snap and an edge designation with adjustment.

Parameter:arg (List) – Contains a snap and an edge designation with a tuple.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checkconnect_edge(app, arg)

Check arg for a snap, edge and a float

Parameters:
  • app
  • arg
Returns:

Whether desired objects are found

Return type:

Boolean

bdtool.misc.checkconnect_edge_adj(app, arg)

Check arg for a snap, edge, float and adjustment

Parameters:
  • app
  • arg
Returns:

Whether variable were found

Return type:

Boolean

bdtool.misc.checkconnect_rel(app, arg)

Check arg for a snap, an edge and a relative angle designation.

Parameter:arg (List) – Contains snap, edge and relative angle designation.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checkconnect_rel_adj(app, arg)

Check arg for a snap, an edge, a relative angle and an adjustment.

Parameter:arg (List) – Contains snap, edge, relative angle and an adjustment.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checkedge(app, arg)

Check parameter for a string and a float.

Although a point mark object has “p” as part of its snap point designation, it does not have an edge. This routine returns a false when point mark objects are used.

Parameter:arg (List) – Contains a string and a number.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checkedge_adj(app, arg)

Check parameter for a string, a float and a tuple.

Parameter:arg (List) – Contains a string, a float and a tuple.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checkedge_rel(app, arg)

Check parameter for a snap, a relative angle designation.

Parameter:arg (List) – Contains a snap string and a relative angle designation.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checkedge_rel_adj(app, arg)

Check arg for a snap, a relative angle and an adjustment.

Parameter:arg (List) – Contains a snap string, a relative angle and an adjustment.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checkfit(app, arg)

Check parameter for two strings with snap designation.

If the two strings have a snap label or no label at all (in which case the origin is assumed), then return true otherwise false.

Parameter:arg (List) – Contains two snap designations.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checkfit_adj(app, arg)

Check parameter for two snap designations with adjustment.

Parameter:arg (List) – Two strings and a tuple.
Returns:Whether designations and adjustment are found.
Return type:Boolean
bdtool.misc.checkfit_sint(app, arg)

Check parameter for two snap designations and selected intersection.

Parameters:
  • app (Buildes) – Application object.
  • arg (List) – Three strings
Returns:

Whether snap designations and selected intersection are found.

Return type:

Boolean

bdtool.misc.checkfit_sint_adj(app, arg)

Check arg for two snaps, a selected intersection and an adjustment.

Parameters:
  • app (Buildes) – Application object.
  • arg (List) – Parameter of three strings and a tuple
Returns:

Whether desired objects are found.

Return type:

Boolean

bdtool.misc.checksnap(app, arg)

Checks arg for a string designating a snap.

Note

Snap at the origin is implied if snap label is None.

Parameter:arg (List) – Contains a snap designation.
Returns:Whether desired object are found.
Return type:Boolean
bdtool.misc.checksnap_adjust(app, arg)

Checks arg for a string designating a snap and a tuple.

Parameter:arg (List) – Contains a snap designation (string) and a tuple.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checksnap_rel(app, arg)

Checks arg for a snap and a relative angle designation.

Parameter:arg (List) – Contains a snap string and a relative angle designation.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.checksnap_rel_adj(app, arg)

Checks arg for a snap, a relative angle and an adjustment.

Parameter:arg (List) – Contains a snap, relative angle and a tuple.
Returns:Whether desired objects are found.
Return type:Boolean
bdtool.misc.if_fixed(app, arg)

Check if an object’s position is fixed due to another’s dependency.

Parameters:
  • app (Buildes) – Application object.
  • arg (String) – Name of object.
Returns:

Whether position can or cannot change.

Return type:

Boolean

bdtool.misc.if_installed(app, arg)

Check if an object has been installed in the design.

Parameters:
  • app
  • arg
Returns:

Whether an object can be moved (offset) in the design.

Return type:

Boolean

bdtool.misc.in_group(group_name, name)

Check whether first part of name contains group_name.

For an object to be part of a group, the first part of its name must designate the name of the group. This function checks to determine this.

Parameters:
  • group_name (String) – Name of the group.
  • name (String) – Name of the object
Returns:

Whether name belongs to the group with group_name.

Return type:

Boolean

bdtool.misc.is_number(arg)

Determine if arg is a number.

Parameter:arg (Variable) – Value to check
Returns:Whether the argument is a number
Return type:Boolean
bdtool.misc.is_string(arg)

Determine if arg is a string.

Parameter:arg (Variable) – Value to check
Returns:Whether the argument is a string.
Return type:Boolean
bdtool.misc.is_type(obj, obj_type)

Determines if object is an instance of object type.

Parameters:
  • obj (Type) – Type of object to check for.
  • obj_type (Type) – Built-in python object type
Returns:

Whether obj is of type obj_type.

Return type:

Boolean

bdtool.misc.name_available(app, name)

Check if provided name is available for a new object.

Names are used to uniquely identify objects in a model so this routine can be used to make sure a name is not being duplicated.

Parameters:
  • app
  • name
Returns:

Whether the name is already in use or not.

Return type:

Boolean

bdtool.misc.sep_name_parent(app, label)

Separates object and parent name from label.

TO BE REMOVED!

Parameter:label (String) – Combined parent, object name and may include snap name.
Returns:parent name.
Return type:String
bdtool.misc.sep_name_snap(app, label)

Separates object name and snap from label.

It returns a list of two ids. Returns None for snap if it does not exist.

Parameter:label (String) – Combined object name and snap name.
Returns:Snap name.
Return type:[String, None] | [String, String]
bdtool.misc.usr_coords(app, coords)

Formats user entered coordinates using left handed system.

Buildes allows the user to chooose a comfortable coordinate system for entering cooordinates. However it works internally using the left handed coordinate system similar to that used in POV-Ray. This function converts whatever entry system the user has selected appropriately.

Parameter:coords (Tuple) – Left or right handed coordinate system.
Returns:Left_handed coordinate system.
Return type:(Float, Float, Float)

4.7.7. modelview Module

Model View

Provides resource for viewing the building in BuildesGUI.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
class bdtool.modelview.ModelView(parent=None)

Bases: OCC.Display.qtDisplay.qtViewer3d

Specialization of the base Qt Widget for an OCC viewer.

add_highlight(color, shape)

Update the list of highlighted objects

Parameters:
  • color (PyOCE.Quantity) – PyOCC color designation for shapes
  • shape (PYOCE.OCC) – Pyoce shape object
get_highlight()

Returns a previously highlighed shape and its color

Returns:A previously highlighted object shape and color
Return type:List
get_zoom_window()
Get flag for zooming using a window designation
highLightObj(name)

Highlight object on the screen.

Parameter:name
initialize()
Initialization procedure for OCC window.
keyPressEvent(event)

Catch key press events.

Parameter:event (Integer) – KeypressEvent
mouseMoveEvent(event)

Catches and acts upon mouse movements by the user.

Parameter:event
mousePressEvent(event)

Catch and act upon the pressing of the mouse buttons

Parameter:event
mouseReleaseEvent(event)

Catch and act upon the release of mouse buttons.

Parameter:event
renderObject(obj, color)

Add the provided object in the model view

Parameter:obj
renderView(objs)

Render objects provided.

Every object that can be displayed should have a shape which will be rendered by ModelView.

Parameter:objs (Distionary) – Dict container for all object shapes
setContextView(view, arg=None)

Change to desired view orientation.

Parameters:
  • view (String) – Key in self.views dict.
  • arg (String) – Key in self.ccolors dictionary.
set_zoom_window(value)
Set flag for zooming using a window designation
zoomWindow
Get flag for zooming using a window designation

4.7.8. pyoce Module

PythonOCC industry module

Creates and returns PythonOCC objects for use in showing Buildes objects

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
bdtool.pyoce.al_fuse(wire_union, wire)

Fuse two wire objects

Parameters:
  • wire_union (OCC.BRepAlgoAPI.BRepAlgoAPI_Fuse) – A union object
  • wire (OCC.TopoDS.TopoDS_Wire) – A wire which has location and orientation
Returns:

A combined definition of two object wires

Return type:

OCC.BRepAlgoAPI.BRepAlgoAPI_Fuse

bdtool.pyoce.bu_edge(obj)

Describes an edge

Describes an edge which has an orientation for the underlying edge, in terms of its geometry (as opposed to orientation in relation to other shapes).

Parameter:obj (OCC.gp) – Object that can be described in 3D space
Returns:Edge of obj
Return type:OCC.TopoDS.TopoDS_Edge
bdtool.pyoce.bu_edge_va(obj)

Provides method to build edges

Parameter:obj (OCC.GC.GC_MakeSegment) – Object provides framework for describing a line segment
Returns:Edge of obj
Return type:OCC.BRepBuilderAPI.BRepBuilderAPI_MakeEdge
bdtool.pyoce.bu_face(wire)

Make a face based on wire.

Parameter:wire (OCC.BRepBuilderAPI.BRepBuilderAPI_MakeWire) – Contour object
Returns:Face objects
Return type:OCC.BRepBuilderAPI.BRepBuilderAPI_MakeFace
bdtool.pyoce.bu_wire(obj_edge)

Turn an objects edge into a wire

Parameter:obj_edge (OCC.TopoDS.TopoDS_Edge) – A description of an edge
Returns:A wire object
Return type:OCC.TopoDS.TopoDS_Wire
bdtool.pyoce.bu_wire_ed(obj_edge)

Buildes edges

Parameter:obj_edge (OCC.BRepBuilderAPI_MakeEdge) – Edge object
Returns:Edge of obj_edge
Return type:OCC.BRepBuilderAPI.BRepBuilderAPI_MakeWire
bdtool.pyoce.bu_wire_obj()

Wire container for adding more than one wire

Returns:Returns an empty wire object
Return type:OCC.BRepBuilderAPI.BRepBuilderAPI_MakeWire
bdtool.pyoce.gc_arc(start, mid, end)

Make an arc of a circle

Parameters:
  • start (OCC.gp.gp_Pnt) – start point of the arc
  • mid (OCC.gp.gp_Pnt) – Middle point of the arc
  • end (OCC.gp.gp_pnt) – End point of the arc
Returns:

A circle on the xy plane

Return type:

OCC.GC.GC_MakeArcOfCircle

bdtool.pyoce.gc_circle(pnt, rad, z_dir=None)

Create a freeform 3D circle

Create a Circle with its center and the normal of its plane and its radius.

Parameters:
  • pnt (OCC.gp.gp_Pnt) – 3D point
  • rad (Float) – Radius of circle
  • z_dir (OCC.gp.gp_Dir) – Desired orientation of circle. Vertical by default
Returns:

A circle on the xy plane

Return type:

OCC.GC.GC_MakeCircle

bdtool.pyoce.gc_segment(pnt1, pnt2)

Make a line segment between two given points in space

Parameters:
  • pnt1 (OCC.gp.gp_Pnt) – 3D location in space
  • pnt2 (OCC.gp.gp_Pnt) – 3D location in space
Returns:

A line segment between pnt1 and pnt2

Return type:

OCC.GC.GC_MakeSegment

bdtool.pyoce.get_color(name)

Provides color definition for the provided name

Parameter:name
Returns:Color value corresponding to name
Return type:Value
bdtool.pyoce.get_color_names()

Access to the color names

Returns:A list of all available color names
Return type:List
bdtool.pyoce.gp_circle(pnt, rad, z_dir=None)

Make a 3D circle oriented on the xy plane

A circle is defined by its radius and positioned in space with a coordinate system (a gp_Ax2 object).

Parameters:
  • pnt (OCC.gp.gp_Pnt) – 3D point
  • rad (Float) – rad of circle
  • z_dir (OCC.gp.gp_Dir) – Desired orientation of circle. Vertical by default
Returns:

A circle on the xy plane

Return type:

OCC.gp.gp_Circ

bdtool.pyoce.gp_direction(valx, valy, valz)

Returns a unit vector in 3D space. Also called “Direction”.

Creates a direction with its 3 cartesian coordinates.

Parameters:
  • valx (Float) – Distance in valx direction
  • valy (Float) – Distance in valy direction
  • valz (Float) – Distance in valz direction
Returns:

A point object

Return type:

OCC.gp.gp_Vec

bdtool.pyoce.gp_point(valx, valy, valz)

Make a single 3D point in space

Creates a point with its 3 cartesian’s coordinates

Parameters:
  • valx (Float) – Distance in valx direction
  • valy (Float) – Distance in valy direction
  • valz (Float) – Distance in valz direction
Returns:

A point object

Return type:

OCC.gp.gp_Pnt

bdtool.pyoce.gp_vector(valx, valy, valz)

Define a single 3D point in space

Creates a point with its three cartesian coordinates.

Parameters:
  • valx (Float) – Distance in valx direction
  • valy (Float) – Distance in valy direction
  • valz (Float) – Distance in valz direction
Returns:

A point object

Return type:

OCC.gp.gp_Vec

bdtool.pyoce.pr_prism(contour, vector)

Make a prism based on contour provided.

Parameters:
  • contour (OCC.BRepBuilderAPI.BRepBuilderAPI_MakeFace) – Closed object with a face
  • vector (OCC.gp.gp_Vec) – 3D vector showing direction of extrusion
Returns:

3D solid object

Return type:

OCC.BRepPrimAPI.BRepPrimAPI_MakePrism

4.7.9. qthelpers Module

PyQt helpers

Resources for additional/custom behaviour for PyQt framework used in Buildes.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
class bdtool.qthelpers.BDEditor(parent=None)

Bases: PyQt4.QtGui.QPlainTextEdit

Adapting word completion functionality from Neil at http://rowinggolfer.blogspot.com/2010_08_01_archive.html. Thanks a million mate.

focusInEvent(event)
Manage focusing
insertCompletion(completion)
Insert text for completion
keyPressEvent(event)
Reaction instructions to keyboard keys
setCompleter(completer)
Set up completer system
textUnderCursor()
Access to selected text to be completed
class bdtool.qthelpers.DictionaryCompleter(dictFiles, parent=None)

Bases: PyQt4.QtGui.QCompleter

Provides access to a list of words used for completing text in editor

class bdtool.qthelpers.ExtendedComboBox(parent=None)

Bases: PyQt4.QtGui.QComboBox

Customized combobox that allows completer actions

on_completer_activated(text)

React to completer being activated

On selection of an item from the completer, select the corresponding item from combobox

setModel(model)
On model change, update the models of the filter and completer as well.
setModelColumn(column)
On model column change, update the model column of the filter and completer as well
class bdtool.qthelpers.FindReplace(parent=None)

Bases: PyQt4.QtGui.QDialog, bdtool.qthelpers.FindReplaceDlg

Provide find and/or replace functionality for Buildes

Modified from “Rapid GUI Programming with Python and Qt” by Mark Summerfield.

makeRegex()
Make rules
on_findButton_clicked()
React to pressing find button
on_findLineEdit_textEdited(text)
Documentation goes here
on_replaceAllButton_clicked()
React to ‘replace all’ button being pressed
on_replaceButton_clicked()
React to ‘replace’ button being clicked
updateTextView(text)
Update editor to reflect replaced text
updateUi()
Reset the state of all ui components
class bdtool.qthelpers.FindReplaceDlg

Bases: object

Find and replace dialog class. Modified from “Rapid GUI Programming with Python and Qt” by Mark Summerfield.

retranslateUi(fr_dialog)
Standard QT function
setupUi(fr_dialog)
Setup ui for find and replace dialog
class bdtool.qthelpers.HelpTplDlg(tplText, dText, cText, parent=None)

Bases: PyQt4.QtGui.QDialog

Dialog ui for showing help on commands

keyPressEvent(event)
Ignore enter or return keyboard entries on dialog box
showComponent(name)

Show component help

Parameter:name (String) – Value from combobox
showDirective(name)

Show directive help

Parameter:name (String) – Value from combobox
showHelp(name)

Get and display help information

Parameter:name (String) – Component or directive name to get help information about
class bdtool.qthelpers.NumberBar(parent=None)

Bases: PyQt4.QtGui.QWidget

Extends editor by providing ability to number text lines

paintEvent(event)
React appropriately to paint events
update_on_scroll(rect, scroll)
React appropriately to scrolling
update_width(string)
Update width of number bar
class bdtool.qthelpers.PythonHighlighter(parent=None)

Bases: PyQt4.QtGui.QSyntaxHighlighter

Provide syntax highlighting.

highlightBlock(text)

Syntax higlights a block of code.

Parameter:text (QtCore.QString) – A string object delimited by a newline.
class bdtool.qthelpers.QueryLineEdit(parent=None)

Bases: PyQt4.QtGui.QLineEdit

QLineEdit widget

keyPressEvent(event)
Catch keyboard key presses for ‘up’, ‘down’
class bdtool.qthelpers.TextEdit(dictFiles, parent=None)

Bases: PyQt4.QtGui.QWidget

QPlainTextEditor that converts a tab to four spaces.

eventFilter(obj, event)

Change to 4 spaces if event is a tab keyboard press.

Parameters:
  • obj (Unknown) – not used
  • event (QtCore.QEvent.KeyPress) – Keyboard tab
Returns:

If event is a tab, handle it else return event

Return type:

Varies

paintEvent(event)

React to paint events

Parameter:event (Unknown) – Unused
updateCursorPos()
Updates BuildesUi status bar with current cursor position

4.7.10. transform Module

Translate

Provides the resources to manipulate objects from one position to the other.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
bdtool.transform.adjust_obj(app, func, obj, osnap, snap_label, adj=(0, 0, 0))

Make the final adjustment when object has been moved with offset.

Parameters:
  • app (Buildesapp) – Reference to Buildes object
  • func (String) – Function name sending the data
  • obj (String) – Name and possible snap label of object to be moved
  • osnap (Vector) – Object snap coordinates
  • snap_label (String) – Placement snap label
  • adj (Tuple) – 3D coordinates for adjusting final placement.
bdtool.transform.conn_edge_offset(app, sobj, sref1, eref2, dist, adj=(0, 0, 0))

Connect an object from a point (dist) along sref1 to edge of eref2

This is basically a combination of conn_offset and edge_offset. Like conn_offset, the length of ‘sobj’ is determined by a point on ‘sref1’ and a point on the provided edge of ‘eref2’. Like edge_offset, the point along ‘sref1’ is determined by ‘dist’. As usual, it is possible to adjust the final placement if ‘adj’ is provided.

Parameters:
  • app (Buildes) – Reference to buildes object.
  • sobj (String) – Name and possible snap label of object to be moved
  • sref1 (String) – Name and possible snap label of first reference
  • eref2 (String) – Name and edge label of second reference
  • dist (Float) – Distance along edge of first reference
  • adj (Tuple) – 3D coordinates for adjusting final placement
bdtool.transform.conn_offset(app, sobj, sref1, eref2, angle='abs', adj=(0, 0, 0))

Connect an object between a point and an edge.

Although a point mark object has “p” as part of the designation for its snap points, it does not have an edge. As a result it should not be acceptable in this routine.

Parameters:
  • app (Buildes) – Reference to Buildes object.
  • sobj (String) – Name and possible snap label of object to be moved.
  • sref1 (String) – Name and possible snap label of first reference.
  • eref2 (String) – Name and edge label of second reference.
  • angle (String) – Angle to use in connecting sobj to ref1.
  • adj (Tuple) – 3D coordinates for adjusting final placement.
bdtool.transform.edge_offset(app, sobj, sref, dist, angle='abs', adj=(0, 0, 0))

Move object along reference relative to its snap point with adjustment.

Parameters:
  • app (Buildes) – Reference to Buildes object
  • sobj (String) – Name and possible snap label of object to be moved.
  • sref (String) – Name and possible snap label of reference object.
  • dist (Float) – Distance along reference from origin or snap point.
  • adj (Tuple) – 3D coordinates for adjusting final placement.
bdtool.transform.finish_offset(app, nsnap_id, nobj, esnap_id, eobj)

Test if possible joint after offsetting need to be cleaned up.

The joints are specific to use and material of the objects. For example joints in furniture are different between those in buildings. This routine should be widened to test for appropriate need, based on the objects in question.

Parameters:
  • nsnap_id (String) – New object snap designation.
  • nobj (BuildesData) – New object being placed in design.
  • esnap_id (String) – Existing object snap designation.
  • eobj (BuildesData) – Existing object begin placed in design.
bdtool.transform.fit_offset(app, sobj, sref1, sref2, vloc='left', adj=(0, 0, 0))

Fit sobj between or at intersection of two reference points.

If sobj has a length then fit it between the provided reference points if however sobj is a pointmark, place it on the intersection between sref1 and sref2.

Parameters:
  • app (Buildes) – Reference to Buildes object
  • sobj (String) – Name and possible snap label of object to be moved.
  • sref1 (String) – Name and possible snap label of first reference.
  • sref2 (String) – Name and possible snap label of second reference.
  • vloc (String) – User preferred vector location if more than one intersection
  • adj (Tuple) – 3D coordinates for adjusting final placement.
bdtool.transform.get_line_int(app, obj1_list, obj2_list)

Get the coordinate where two line objects intersect

Parameters:
  • obj1_list
  • obj2_list
Returns:
Return type:
bdtool.transform.get_mixed_params(app, obj_list)

Get coordinate where two different objects intersect

Considering line and arc objects for now.

Parameter:obj_list
Returns:
Return type:
bdtool.transform.put(app, sobj, adj)

Move named object to absolute position.

Parameters:
  • app (Buildes) – Reference to Buildes object
  • sobj (String) – Name of object.
  • adj (Tuple) – Absolute position to move the named object.
bdtool.transform.snap_offset(app, sobj, sref, angle='abs', adj=(0, 0, 0))

Move named object relative to reference via snaps with adjustment.

Parameters:
  • app (Buildes) – Reference to Buildes object
  • sobj (String) – Name and possible snap label of object to be moved.
  • sref (String) – Name and possible snap label of reference object.
  • adj (Tuple) – 3D coordinates for adjusting final placement.

4.7.11. trim Module

Trim object

Resources for trimming connections between objects in buildes.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
class bdtool.trim.Trim(app=None)

Bases: object

Provides the common parameters for trimming object connections.

find_cint_on_a(edge_a, edge_b)

Select appropriate intersection between a line and a arc

Finds appropriate intersection on A edges (when a line) for given edge of B (when a arc). It does this by finding the closest intersection to the provided intersection point on the arc.

find_lint_on_a(edge_a, edge_b)

Select appropriate intersection point between arc and line edges

Finds the appropriate intersection on A edges (when an arc provided by edge_a) for given edge_b (when a line). It does this by finding the closet intersection on the arc to the provided intersection point on the line.

get_corners(new_id, old_id)

Returns the connecting corners of the two objects.

Depending on the mode of connection, this routine collects the relevant connecting edges of the two sides. It returns a list of two lists. Each contained list is made up of 2 strings designating the connecting ends and 4 vectors designating the coordinates of the four corners.

Parameter:obj2
Returns:Returns a list of two lists containing strings and vectors
Return type:[[String, String, Vector, ...], [String, String, Vector, ...]]
lcedge_cross1(edges_a, edges_b)

Find edge intersection information for line and arc sides.

This does the same as Trim.lledge_cross1() but calculates for connections between a line and a arc.

../_images/oneLCEdgeCross.png

If edges_a is line data, the content is a list like the following:

[“line”, edgeInt, oEndInt, oEdgeInt, oEdgeEndInt]

If edges_b is arc data, the content is a list like the following:

[“arc”, cen, rad1, rad2, edgeInt, oEndInt, oEdgeInt, oEdgeEndInt, mid1, mid2]

And vice versa. NOTE: the position of rad1 and rad2 depends on edgeInt (which is the connecting point selected by the user to connect the two objects). In the above example edgeInt is on the outer edge of the arc object however if it is on the inner the parameter for the arcd object will be instead:

[“arc”, cen, rad2, rad1, edgeInt, oEndInt, oEdgeInt, oEdgeEndInt, mid2, mid1]

Parameters:
  • edges_a (List) – Coords from two edges of object A.
  • edges_b (List) – Coords from two points on edges of B.
Returns:

Closest points where both edges of B intersect A.

Return type:

None | [Vector, Vector]

lcedge_cross2(edges_a, edges_b)

Find edge intersection information for line and arc sides.

Find the single appropriate point where edge from edges_b crosses edge from edges_a.

Parameters:
  • edges_a ([Vector, Vector, Float]) – Coords and the angle from two edges of A.
  • edges_b ([Vector, Vector, Float, Vector, Vector]) – Coords and the angle from two edges of B.
Returns:

Points where both edges from A and B crosses.

Return type:

[Vector, Vector]

lledge_cross1(edges_a, edges_b)

Find edge intersection information for two line sides.

Finds which edge of object A is closest to object B. Then it returns the intersection of the two edges of B to that closest edge of A. To find the closest edge of A, it gets the distance from one of the ends of B furthest from the intersection (1) to both edges of A (2, 3). See Figure.

../_images/oneLLEdgeCross.png

NOTE: In the two coordinates returned, the first is the connection with whatever edge is first in the edges_b list. While the second is connection with the second edge in edges_b list.

Parameters:
  • edges_a ([Vector, Vector, Float]) – Coords and angle from two edges of object A.
  • edges_b ([Vector, Vector, Float, Vector, Vector]) – Coords and angle from two points on edges of B.
Returns:

Closest points where both edges of B intersect A.

Return type:

[Vector, Vector]

lledge_cross2(edges_a, edges_b)

Find edge intersection information on two line sides.

Finds the two points where edges from edges_b crosses edges from edges_a.

Parameters:
  • edges_a ([Vector, Vector, Float]) – Coords and the angle from two edges of A.
  • edges_b ([Vector, Vector, Float, Vector, Vector]) – Coords and the angle from two edges of B.
Returns:

Points where both edges from A and B crosses.

Return type:

[Vector, Vector]

new_obj_info(new_id, new_obj, flag=None)

Get information about the object to be trimmed.

Parameters:
  • new_id (String) – Snap label for new object.
  • new_obj (BuildesData) – New object reference.
  • flag (Boolean) – Designates whether additional information is needed..
old_obj_info(old_id, old_obj, flag=None)

Get information about the object to be trimmed.

Parameters:
  • old_id (String) – Snap label for old object.
  • oldobj (BuildesData) – Old object reference.
  • flag (Boolean) – Designates whether additional information is needed..
other_obj_info(edge_id, obj, flag=None)

Get additional information about edge_id of obj.

Parameters:
  • edge_id (String) – Snap Label associated with object.
  • obj (BuildesData) – Reference to object to be trimmed.
  • flag (Boolean) – Whether to get information on all three edges of object.
Returns:

Information about the edges of the object.

Return type:

[String, String, Float, Float, String, String, Float, Float]

trim_corners1(coords, snap, obj)

Trim the corner of one object to provided coordinates.

Parameters:
  • coords (Vector) – Global coordinates at new corner.
  • snap (String) – Snap labels at corner to be adjusted.
  • obj (BuildesData) – Object with corner to be trimmed.
trim_corners2(coords, snaps, objs)

Trim the corners of two objects to provided coordinates.

Parameters:
  • coords (Vector) – Global coordinates at new common corner.
  • ids ([String, String]) – Snap labels for the two corners.
  • objs ([BuildesData, BuildesData]) – Objects with corners to be adjusted.
trim_edge1(coords, ids, obj)

Adjusts the edges of a single object to calculated intersection.

Parameters:
  • coords ([Vector, Vector]) – Global coordinates at the intersection point.
  • ids ([String, String]) – Snap labels for the corners to be trimmed.
  • obj (BuildesData) – Object that owns the corners to be trimmed.
trim_edges2(coords, ids, objs)

Adjust the two edges of two objects to provided coordinates.

Parameters:
  • coords ([Vector, Vector]) – Global coordinates at the intersection points.
  • ids ([string, string, string, string]) – Two sets of snap labels where the intersection occurs.
  • objs ([BuildesData, BuildesData]) – The objects that own the corners to be trimmed.

4.7.12. trimlinearc Module

TrimLineArc Object

Resources for trimming linear and curve connections in Buildes.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
class bdtool.trimlinearc.TrimLineArc(app=None)

Bases: bdtool.trim.Trim

Provides ability to trim line-arc connections for space sides.

init_trim(new_id, new_side, old_id, old_side)

Initiates the trimming of sides involving lines and arcs.

Parameters:
  • new_id (String) – Snap label for the new side.
  • new_side (BuildesData) – New side object reference.
  • old_id (String) – Snap label for the old (existing) side.
  • old_side (BuildesData) – Old side object reference.
trim_at_axis()
Trim connections where at least one side is connecting via axis
trim_at_ends()

Trim connections between ends for line and arc

This function handles connections where the corners of both ends are involved. There are two main types of connections that will be called CROSS and STRAIGHT. If newOEdgeInt is clockwise to oldInt and newOEdgeEnd is clockwise to newOEdgeInt, then we are dealing with a STRAIGHT connection. Also if the situation is anticlockwise and anticlockwise we are still dealing with a straight connection however if the situation is ever opposite such as clockwise and anticlockwise or anticlockwise and clockwise then we are dealing with a CROSS connection.

If we have a CROSS connection then we need to check the angle made by the connecting oldEdge and the end edge of the new side for two types of trimming. If this angle is less or equal to 90 then we trim one way. If the angle is more than 90 then we trim the other way. See diagram.

This solution should work for two line sides also, I think.

trim_endto_body()

Trim connections between end and body for line and arc

Provides function in two parts. First handles connections between end and body. Second calls another function that handles that between two ends.

In the first it deciphers the connection and calls oneLCEdgeCross function to make the connection and return the calculated coordinates for trimming the relevant edge. These coordinates are then sent to the one edge trimmer attribute (trimOneEdges) to get the job done.

trim_on_cleaned(new_id, old_id)

Clean new side against the already cleaned old side

Parameters:
  • new_id
  • old_id

4.7.13. trimlineline Module

TrimLineLine Object

Resources for trimming linear connections in Buildes.

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
class bdtool.trimlineline.TrimLineLine(app=None)

Bases: bdtool.trim.Trim

Provides ability to init_trim line connecting space sides.

init_trim(new_id, new_side, old_id, old_side)

Coordinates the trimming of two line sides.

Parameters:
  • new_id (String) – Snap label for the new side.
  • new_side (BuildesData) – New side object reference.
  • old_id (String) – Snap label for the old (existing) side.
  • old_side (BuildesData) – Old side object reference.
trim_at_axis()

Trim connections where at least one side is connecting via the axis.

Limitation:

There is a limitation when newInt != oldInt and newInt == oldOEndInt.

This means that the user is selecting a connection point but moves the new side to the other end of the selected intersection point on the old side. Although this can be trimmed however it creates a potential error prone code. For example, a solvable situation is when new_id == ‘a1’ but the user moves the new side along the ‘a’ edge of the old side to ‘a3’. A buggy situation exists when new_id == ‘a2’ but the user moves the new side to ‘a3’. ‘a2’ is not an end so there is no way to detect this situation without some ugly hacking. As it does not make sense, this has been omitted. This is an attempt to make things simple and easy.

trim_on_cleaned(new_id, old_id)

Clean new_side connected to a cleaned old side

Parameters:
  • new_id
  • old_id
trim_open(new_id, new_side, old_id, old_side)

Coordinates the trimming of line closeSide and openSide objects

Open sides trim to the nearest edge of the closed side.

  • Populate the trim space
  • Standardize snaps so code is simple
  • Find out which side is open and which side is closed
  • if new is open, find the closest old side and clean new to it
  • Do the same if old is open
Parameters:
  • share_id (String) – End axis snap of share where connection occurs
  • share (SpaceLineSide) – Share object
  • sideId
  • side
trim_share(share_id, share, side)

Coordinates trimming involving line shares

Trimming that involves shares is different from that between ordinary sides. First of all calculation is completed always using the axis but intersection occurs at the edges. Unfortunately the edge of the share that intersects is not clear so this has to be deciphered. To do this; determine which edge of the share that is intersected by the connecting side. The intersected edge of the share trims to the connecting edge of the side and the other edges trim to each other. Except of course sides don’t trim when trimming with shares but this is handled automatically.

Algorithm - get global snap at share_id - get global snap at side ‘a1’ = sA1 and ‘a3’ = sA3 - if share_id - sA1 < share_id - sA3 - if share_id == ‘a1’ - connection = L & R, R & L - elif share_id == ‘a3’ - connection = L & L, R & R - elif share_id - sA1 > share_id - sA3 - if share_id == ‘a1’ - connection = R & R, L & L - elif share_id == ‘a3’ - connection = L & R, R & L

Parameters:
  • share_id (String) – End axis snap of share where connection occurs
  • share (SpaceLineSide) – Share object
  • side
trim_slanted()
Trim connections where sides are vertical and slanted.
trim_slanted_at_end()
Trim connection at ends with one slanted and other vertical.
trim_ver_hor()

Trims connections where sides are vertical and horizontal.

Throughout this routine, the vertical object is the new_side while the horizontal object is the old_side.

This was done about 3 years ago. It was my first real effort with kobldes. It is slightly different from all the other newer calculations. It may even be the only solution but I spent a while solving it and it works so I am sticking to it.

4.7.14. uchelpers Module

UserCommandHelpers object

Provides resources for describing the commands in Buildes and Buildes Ui

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
class bdtool.uchelpers.UserCommandHelpers

Bases: object

View help for commands in the GUI ‘templates’ help dialog

Command names and the functions that compile help data about them are placed in a dictionary called ‘helper’. To use this class call the function get_help_data with a command name, this name is passed to helper which provides access to the appropriate help-compiling function. The compiled data is formatted in html and returned to the caller.

arc_mark_help()

Compiles arcMark component help data

Returns:HTML formatted data about arcMark component
Return type:String
arc_side_help()

Compiles arcSide component help data

Returns:HTML formatted data about arcSide component
Return type:String
build_session_help()

Compiles buildSession directive help data

Returns:HTML formatted data about buildSession directive
Return type:String
build_stop_help()

Compiles buildStop directive help data

Returns:HTML formatted data about buildStop directive
Return type:String
circle_mark_help()

Compiles circleMark component help data

Returns:HTML formatted data about circleMark component
Return type:String
color_help()

Compiles color directive help data

Returns:HTML formatted data about buildStop directive
Return type:String
description_sec(body)

Renders the description section of the command help

Parameter:body
Returns:Formated text
Return type:STRING
designer_help()

Compiles designer directive help data

Returns:HTML formatted data about designer directive
Return type:String
entry_coords_help()

Compiles entryCoords directive help data

Returns:HTML formatted data about entryCoords directive
Return type:String
format_sec(name, msg, syn1, syn2, descr, tbl=None)

Format the appropriate help sections

Parameters:
  • name (String) – Name of the command
  • msg (String) – Short description of the command
  • syn1 (String) – Synopsis for the main view
  • syn2 (String) – Synopsis for text body
  • descr (String) – Detailed description of the command
  • tbl (Table) – Description of all options for the command
Returns:

A spreadsheet object with the needed data to show

Return type:

SpreadSheet

get_help_data(string)

Call appropriate function to compile information with tag string

Parameter:string (String) – A command name
Returns:Result of calling appropriate help function
Return type:SpreadSheet
level_help()

Compiles level component help data

Returns:HTML formatted data about level component
Return type:String
line_mark_help()

Compiles lineMark component help data

Returns:HTML formatted data about lineMark component
Return type:String
line_open_help()

Compiles lineOpen component help data

Returns:HTML formatted data about lineOpen component
Return type:String
line_side_help()

Compiles lineSide component help data

Returns:HTML formatted data about lineSide component
Return type:String
location_help()

Compiles location directive help data

Returns:HTML formatted data about location directive
Return type:String
log_level_help()

Compiles logLevel directive help data

Returns:HTML formatted data about logLevel directive
Return type:String
marker_angle_gap_help()

Compiles markerAngleGap directive help data

Returns:HTML formatted data about markerAngleGap directive
Return type:String
marker_length_gap_help()

Compiles markerLengthGap directive help data

Returns:HTML formatted data about markerLengthGap directive
Return type:String
marker_size_help()

Compiles markerSize directive help data

Returns:HTML formatted data about markerSize directive
Return type:SpreadSheet
material_help()

Compiles material directive help data

Returns:HTML formatted data about buildStop directive
Return type:String
name_sec(name, descr)

Renders the name section of the command help

Parameters:
  • name (String) – Command name
  • descr (String) – A few words about command
Returns:

Formated text

Return type:

STRING

offset_help()

Compiles comm directive help data

Returns:HTML formatted data about comm directive
Return type:String
option_sec(table)

Renders the option section of the command help

Parameter:table
Returns:Formated text
Return type:STRING
point_mark_help()

Compiles pointMark component help data

Returns:HTML formatted data about pointMark component
Return type:String
set_level_help()

Compiles setLevel directive help data

Returns:HTML formatted data about setLevel directive
Return type:String
share_help()

Compiles share component help data

Returns:HTML formatted data about share component
Return type:String
show_open_side_help()

Compiles showOpenSide directive help data

Returns:HTML formatted data about showOpenSide directive
Return type:String
site_help()

Compiles site component help data

Returns:HTML formatted data about site component
Return type:String
skip_shape_help()

Compiles skipShape directive help data

Returns:HTML formatted data about skipShape directive
Return type:String
space_help()

Compiles space component help data

Returns:HTML formatted data about space component
Return type:String
synopsis_sec(syn_sec)

Renders the synopsis section of the command help

Parameter:syn_sec
Returns:Formated text
Return type:STRING
temp_func(help_string)

Compiles temporary data to designate that help does not exist

Returns:HTML formatted data about entryCoords directive
Return type:String
ui_angle_help()

Compiles angle ui command help data

Returns:HTML formatted data
Return type:SpreadSheet
ui_distance_help()

Compiles length ui command help data

Returns:HTML formatted data
Return type:SpreadSheet
ui_kalk_help()

Compiles kalk ui command help data

Returns:HTML formatted data
Return type:SpreadSheet
ui_label_help()

Compiles label ui command help data

Returns:HTML formatted data
Return type:SpreadSheet
ui_length_help()

Compiles length ui command help data

Returns:HTML formatted data
Return type:SpreadSheet

4.7.15. uihelpers Module

User Interface Helpers

Functions to extend the functionality of Buildes GUI

moduleauthor:Kene Meniru <Kene.Meniru@illom.org>
bdtool.uihelpers.angle(app, dic, snap_id)

Get the angle between the provided snap designations

Requires three snap-points. The angle between the two vectors is returned.

Parameters:
  • dic (Dict) – Buildes document holding all objects in the model
  • snap_id ([SnapId, SnapId, SnapId]) – Three snap points with the third as the connecting point.
Returns:

Angle between two vectors/line segments

Return type:

[True, String]

bdtool.uihelpers.calc(arg)

Mathematical calculations for buildesUi

Returns:
Return type:
bdtool.uihelpers.distance(app, dic, snap_id)

Get the length between the provided snap designations

Two object names with snap identifications are required. If snap identifications are not provided the first snap point is assumed.

Parameters:
  • dic (Dict) – Buildes document holding all objects in the model
  • snap_id
Returns:

Distance between two points

Return type:

[None, None] | [True, [String, Shape]]

bdtool.uihelpers.label()

Render labels for the provided objects

User can provide object names or object names and snap_ids. The snaps will be discarded.

Parameters:
  • dic (Dict) – Buildes document holding all objects in the model
  • objs ([String, ...]) – Names of objects to be labeled
Returns:

PythonOCC of provided objects.

Return type:

[None, PythonOCC.shape, ...]

bdtool.uihelpers.length(app, dic, snap_id)

Get the length between the provided snap designations

Two object names with snap identifications are required. If snap identifications are not provided the first snap point is assumed.

Parameters:
  • dic (Dict) – Buildes document holding all objects in the model
  • snap_id
Returns:

Distance between two points

Return type:

[None, None] | [True, [String, Shape]]

bdtool.uihelpers.make_arc(pnt1, pnt2, pnt3, hgt)

Create a PythonOCC arc between provided points

Parameters:
  • pnt1
  • pnt2
  • pnt3
  • hgt
Returns:

Wire definition of the line object

Return type:

PythonOcc.Wire

bdtool.uihelpers.make_line(pnt1, pnt2, hgt)

Create a PythonOCC line between provided points

Parameters:
  • pnt1
  • pnt2
  • hgt
Returns:

Wire definition of the line object

Return type:

PythonOcc.Wire

bdtool.uihelpers.make_marker(pnt, hgt, size)

Create a marker centered on provided point

Parameter:pnt
Returns:
Return type: