__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.
The doc module provides the Doc object which is used to store all building components created when buildes is executed.
Document Tools
Manages the storage of objects for use in Buildes.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: object
Provides objects to manage the storage of building components.
Adds the provided object to storage.
Parameter: | obj (object) – Building component |
---|
Adjust count for object type.
Parameter: | 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. |
---|
Returns an object in storage
Parameter: | name (String) – Unique identifier for an object |
---|---|
Returns: | An object in storage |
Return type: | object |
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: |
|
---|
Kalk-ulations
Provides calculations necessary to create building information using buildes.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: object
Spreadsheet object.
Return formula for the given key (cell).
Parameter: | key – |
---|---|
Returns: | Cell content that is a formula |
Return type: | Math |
Return formula for the given key (cell).
Parameter: | key – |
---|---|
Returns: | Cell content that is a formula |
Return type: | Math |
Dummy method to keep pylint at bay for now
Parameter: | formula – |
---|
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.
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 (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 (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 |
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: |
|
---|---|
Returns: | Less than 0 if CW, more than 0 if CCW and 0 if collinear. |
Return type: | <0 | >0 | 0 |
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 |
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 |
Check if self is below vec.
Parameter: | vec (Vector) – Coordinate with placement to be determined. |
---|---|
Returns: | True or false. |
Return type: | Boolean |
Check if self is above vec.
Parameter: | vec (Vector) – Coordinate with placement to be determined. |
---|---|
Returns: | True or false. |
Return type: | Boolean |
Middle coordinates of a line segment
Parameter: | vec – |
---|---|
Returns: | x and y coordinates at midpoint |
Return type: | ? |
Orientation (0 - 360 degrees) of a line defined by two coords.
This assumes that the vertical, parallel to y axis, is at 0 degrees.
Calculate the intersection between two 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: |
|
---|---|
Returns: | A boolean with one or two vectors. |
Return type: | None | [True, Vector, Vector] |
Returns length of arc
Parameters: |
|
---|---|
Returns: | A numberic value |
Return type: | Float |
Returns the mid point of provided arc
Parameters: |
|
---|---|
Returns: | Coordinates at the mid point of arc |
Return type: | Vector |
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: |
|
---|---|
Returns: | Whether the edges are parallel. |
Return type: | Boolean |
Test to see if two floats are equal.
Parameters: |
|
---|---|
Returns: | Whether the provided floats are equal. |
Return type: | Boolean |
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: |
|
---|---|
Returns: | Whether afloat is greater than bfloat. |
Return type: | Boolean |
Returns the horizontal placement of vec in relation to others in list.
Parameters: |
|
---|---|
Returns: | Horizontal position as ‘left’, ‘right’ or ‘none’. |
Return type: | String |
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: |
|
---|---|
Returns: | Whether point is inside the polygon. |
Return type: | Boolean |
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
Parameters: |
|
---|---|
Returns: | Whether point (pnt0) is on arc (pnt1, pnt2) with center at cen. |
Return type: | Boolean |
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
degrees. If your sectors can span a larger angle, you’ll have to modify it.
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: |
|
---|---|
Returns: | Whether pnt is inside sector |
Return type: | Boolean |
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: |
|
---|---|
Returns: | Number of intersections and 2D points of intersection. |
Return type: | None | [1, Vector] | [2, Vector, Vector] |
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)
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: |
|
---|---|
Returns: | Whether float afloat is less than float bfloat. |
Return type: | Boolean |
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: |
|
---|---|
Returns: | Whether point (pnt0) is on arc (pnt1, pnt2) with center at cen. |
Return type: | Boolean |
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: |
|
---|---|
Returns: | Whether point (pnt0) is anywhere on line (pnt1, pnt2). |
Return type: | Boolean |
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) |
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 |
Calculates 2D coordinates of point at length and angle.
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: |
|
---|---|
Returns: | 2D coordinates at point B. |
Return type: | Vector |
Returns area of a sector
Parameters: |
|
---|---|
Returns: | A numberic value |
Return type: | Float |
Returns area of a segment of a circle
Parameters: |
|
---|---|
Returns: | A numberic value |
Return type: | Float |
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) |
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) |
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) |
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) |
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.
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: |
|
---|---|
Returns: | A flag and a coordinate point. |
Return type: | None | (True, Vector) |
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 |
Returns the vertical placement of vec in relation to others in list.
Parameters: |
|
---|---|
Returns: | Vertical position as ‘up’, ‘down’ or ‘none’. |
Return type: | String |
Buildes Exceptions
Provides exception definitions for buildes.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
MakeHTML
Has the resources to make html code for buildes program
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: object
Provides the resources to create an html table
Value for the borders
Parameter: | val – |
---|---|
Returns: | |
Return type: |
Value for the borders
Parameter: | val – |
---|---|
Returns: | |
Return type: |
Create header for the table
Parameter: | headers – |
---|---|
Returns: | |
Return type: |
Create header for the table
Parameter: | headers – |
---|---|
Returns: | |
Return type: |
Value for the borders
Parameter: | val – |
---|---|
Returns: | |
Return type: |
Adds a new row to the table body
Parameter: | cols – |
---|---|
Returns: | |
Return type: |
Adds a new row to the table body
Parameter: | cols – |
---|---|
Returns: | |
Return type: |
Value for the borders
Parameter: | val – |
---|---|
Returns: | |
Return type: |
Returns a table body
Returns: | |
---|---|
Return type: |
Return a header line for selected level
Level 1 is the default if no level is provided.
Parameters: |
|
---|---|
Returns: | HTML code for rendering string |
Return type: | HTML |
Return space codes for the desired number
Parameter: | number – |
---|---|
Returns: | |
Return type: |
Return internet url with provided information
The url link created opens in the parent browser window
Parameters: |
|
---|---|
Returns: | HTML code for rendering URL |
Return type: | HTML |
Create an ordered list
Can produce list to any desired depth. Just provide list_obj that contains lists.
Parameters: |
|
---|
Return symbol for provided string
Parameter: | string – |
---|---|
Returns: | HTML code for rendering String |
Return type: | HTML |
Return the string underlined
Parameter: | string – |
---|---|
Returns: | HTML code for rendering string |
Return type: | HTML |
Create un-ordered list
Can produce list to any desired depth. Just provide list_obj that contains lists.
Parameters: |
|
---|
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> |
---|
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 |
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 |
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 |
Check arg for a snap, edge and a float
Parameters: |
|
---|---|
Returns: | Whether desired objects are found |
Return type: | Boolean |
Check arg for a snap, edge, float and adjustment
Parameters: |
|
---|---|
Returns: | Whether variable were found |
Return type: | Boolean |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Check parameter for two snap designations and selected intersection.
Parameters: |
|
---|---|
Returns: | Whether snap designations and selected intersection are found. |
Return type: | Boolean |
Check arg for two snaps, a selected intersection and an adjustment.
Parameters: |
|
---|---|
Returns: | Whether desired objects are found. |
Return type: | Boolean |
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 |
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 |
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 |
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 |
Check if an object’s position is fixed due to another’s dependency.
Parameters: |
|
---|---|
Returns: | Whether position can or cannot change. |
Return type: | Boolean |
Check if an object has been installed in the design.
Parameters: |
|
---|---|
Returns: | Whether an object can be moved (offset) in the design. |
Return type: | Boolean |
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: |
|
---|---|
Returns: | Whether name belongs to the group with group_name. |
Return type: | Boolean |
Determine if arg is a number.
Parameter: | arg (Variable) – Value to check |
---|---|
Returns: | Whether the argument is a number |
Return type: | Boolean |
Determine if arg is a string.
Parameter: | arg (Variable) – Value to check |
---|---|
Returns: | Whether the argument is a string. |
Return type: | Boolean |
Determines if object is an instance of object type.
Parameters: |
|
---|---|
Returns: | Whether obj is of type obj_type. |
Return type: | Boolean |
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: |
|
---|---|
Returns: | Whether the name is already in use or not. |
Return type: | Boolean |
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 |
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] |
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) |
Model View
Provides resource for viewing the building in BuildesGUI.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: OCC.Display.qtDisplay.qtViewer3d
Specialization of the base Qt Widget for an OCC viewer.
Update the list of highlighted objects
Parameters: |
|
---|
Returns a previously highlighed shape and its color
Returns: | A previously highlighted object shape and color |
---|---|
Return type: | List |
Highlight object on the screen.
Parameter: | name – |
---|
Catch key press events.
Parameter: | event (Integer) – KeypressEvent |
---|
Catches and acts upon mouse movements by the user.
Parameter: | event – |
---|
Catch and act upon the pressing of the mouse buttons
Parameter: | event – |
---|
Catch and act upon the release of mouse buttons.
Parameter: | event – |
---|
Add the provided object in the model view
Parameter: | obj – |
---|
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 |
---|
Change to desired view orientation.
Parameters: |
|
---|
PythonOCC industry module
Creates and returns PythonOCC objects for use in showing Buildes objects
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Fuse two wire objects
Parameters: |
|
---|---|
Returns: | A combined definition of two object wires |
Return type: | OCC.BRepAlgoAPI.BRepAlgoAPI_Fuse |
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 |
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 |
Make a face based on wire.
Parameter: | wire (OCC.BRepBuilderAPI.BRepBuilderAPI_MakeWire) – Contour object |
---|---|
Returns: | Face objects |
Return type: | OCC.BRepBuilderAPI.BRepBuilderAPI_MakeFace |
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 |
Buildes edges
Parameter: | obj_edge (OCC.BRepBuilderAPI_MakeEdge) – Edge object |
---|---|
Returns: | Edge of obj_edge |
Return type: | OCC.BRepBuilderAPI.BRepBuilderAPI_MakeWire |
Wire container for adding more than one wire
Returns: | Returns an empty wire object |
---|---|
Return type: | OCC.BRepBuilderAPI.BRepBuilderAPI_MakeWire |
Make an arc of a circle
Parameters: |
|
---|---|
Returns: | A circle on the xy plane |
Return type: | OCC.GC.GC_MakeArcOfCircle |
Create a freeform 3D circle
Create a Circle with its center and the normal of its plane and its radius.
Parameters: |
|
---|---|
Returns: | A circle on the xy plane |
Return type: | OCC.GC.GC_MakeCircle |
Make a line segment between two given points in space
Parameters: |
|
---|---|
Returns: | A line segment between pnt1 and pnt2 |
Return type: | OCC.GC.GC_MakeSegment |
Provides color definition for the provided name
Parameter: | name – |
---|---|
Returns: | Color value corresponding to name |
Return type: | Value |
Access to the color names
Returns: | A list of all available color names |
---|---|
Return type: | List |
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: |
|
---|---|
Returns: | A circle on the xy plane |
Return type: | OCC.gp.gp_Circ |
Returns a unit vector in 3D space. Also called “Direction”.
Creates a direction with its 3 cartesian coordinates.
Parameters: |
|
---|---|
Returns: | A point object |
Return type: | OCC.gp.gp_Vec |
Make a single 3D point in space
Creates a point with its 3 cartesian’s coordinates
Parameters: |
|
---|---|
Returns: | A point object |
Return type: | OCC.gp.gp_Pnt |
Define a single 3D point in space
Creates a point with its three cartesian coordinates.
Parameters: |
|
---|---|
Returns: | A point object |
Return type: | OCC.gp.gp_Vec |
Make a prism based on contour provided.
Parameters: |
|
---|---|
Returns: | 3D solid object |
Return type: | OCC.BRepPrimAPI.BRepPrimAPI_MakePrism |
PyQt helpers
Resources for additional/custom behaviour for PyQt framework used in Buildes.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: PyQt4.QtGui.QPlainTextEdit
Adapting word completion functionality from Neil at http://rowinggolfer.blogspot.com/2010_08_01_archive.html. Thanks a million mate.
Bases: PyQt4.QtGui.QCompleter
Provides access to a list of words used for completing text in editor
Bases: PyQt4.QtGui.QComboBox
Customized combobox that allows completer actions
React to completer being activated
On selection of an item from the completer, select the corresponding item from combobox
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.
Bases: object
Find and replace dialog class. Modified from “Rapid GUI Programming with Python and Qt” by Mark Summerfield.
Bases: PyQt4.QtGui.QDialog
Dialog ui for showing help on commands
Show component help
Parameter: | name (String) – Value from combobox |
---|
Show directive help
Parameter: | name (String) – Value from combobox |
---|
Get and display help information
Parameter: | name (String) – Component or directive name to get help information about |
---|
Bases: PyQt4.QtGui.QWidget
Extends editor by providing ability to number text lines
Bases: PyQt4.QtGui.QSyntaxHighlighter
Provide syntax highlighting.
Syntax higlights a block of code.
Parameter: | text (QtCore.QString) – A string object delimited by a newline. |
---|
Bases: PyQt4.QtGui.QLineEdit
QLineEdit widget
Bases: PyQt4.QtGui.QWidget
QPlainTextEditor that converts a tab to four spaces.
Change to 4 spaces if event is a tab keyboard press.
Parameters: |
|
---|---|
Returns: | If event is a tab, handle it else return event |
Return type: | Varies |
React to paint events
Parameter: | event (Unknown) – Unused |
---|
Translate
Provides the resources to manipulate objects from one position to the other.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Make the final adjustment when object has been moved with offset.
Parameters: |
|
---|
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: |
|
---|
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: |
|
---|
Move object along reference relative to its snap point with adjustment.
Parameters: |
|
---|
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: |
|
---|
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: |
|
---|
Get the coordinate where two line objects intersect
Parameters: |
|
---|---|
Returns: | |
Return type: |
Get coordinate where two different objects intersect
Considering line and arc objects for now.
Parameter: | obj_list – |
---|---|
Returns: | |
Return type: |
Move named object to absolute position.
Parameters: |
|
---|
Move named object relative to reference via snaps with adjustment.
Parameters: |
|
---|
Trim object
Resources for trimming connections between objects in buildes.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: object
Provides the common parameters for trimming object connections.
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.
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.
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, ...]] |
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.
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: |
|
---|---|
Returns: | Closest points where both edges of B intersect A. |
Return type: | None | [Vector, Vector] |
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: |
|
---|---|
Returns: | Points where both edges from A and B crosses. |
Return type: | [Vector, Vector] |
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.
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: |
|
---|---|
Returns: | Closest points where both edges of B intersect A. |
Return type: | [Vector, Vector] |
Find edge intersection information on two line sides.
Finds the two points where edges from edges_b crosses edges from edges_a.
Parameters: |
|
---|---|
Returns: | Points where both edges from A and B crosses. |
Return type: | [Vector, Vector] |
Get information about the object to be trimmed.
Parameters: |
|
---|
Get information about the object to be trimmed.
Parameters: |
|
---|
Get additional information about edge_id of obj.
Parameters: |
|
---|---|
Returns: | Information about the edges of the object. |
Return type: | [String, String, Float, Float, String, String, Float, Float] |
Trim the corner of one object to provided coordinates.
Parameters: |
|
---|
Trim the corners of two objects to provided coordinates.
Parameters: |
|
---|
Adjusts the edges of a single object to calculated intersection.
Parameters: |
|
---|
Adjust the two edges of two objects to provided coordinates.
Parameters: |
|
---|
TrimLineArc Object
Resources for trimming linear and curve connections in Buildes.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: bdtool.trim.Trim
Provides ability to trim line-arc connections for space sides.
Initiates the trimming of sides involving lines and arcs.
Parameters: |
|
---|
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 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.
Clean new side against the already cleaned old side
Parameters: |
|
---|
TrimLineLine Object
Resources for trimming linear connections in Buildes.
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Bases: bdtool.trim.Trim
Provides ability to init_trim line connecting space sides.
Coordinates the trimming of two line sides.
Parameters: |
|
---|
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.
Clean new_side connected to a cleaned old side
Parameters: |
|
---|
Coordinates the trimming of line closeSide and openSide objects
Open sides trim to the nearest edge of the closed side.
Parameters: |
|
---|
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: |
|
---|
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.
UserCommandHelpers object
Provides resources for describing the commands in Buildes and Buildes Ui
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
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.
Compiles arcMark component help data
Returns: | HTML formatted data about arcMark component |
---|---|
Return type: | String |
Compiles arcSide component help data
Returns: | HTML formatted data about arcSide component |
---|---|
Return type: | String |
Compiles buildSession directive help data
Returns: | HTML formatted data about buildSession directive |
---|---|
Return type: | String |
Compiles buildStop directive help data
Returns: | HTML formatted data about buildStop directive |
---|---|
Return type: | String |
Compiles circleMark component help data
Returns: | HTML formatted data about circleMark component |
---|---|
Return type: | String |
Compiles color directive help data
Returns: | HTML formatted data about buildStop directive |
---|---|
Return type: | String |
Renders the description section of the command help
Parameter: | body – |
---|---|
Returns: | Formated text |
Return type: | STRING |
Compiles designer directive help data
Returns: | HTML formatted data about designer directive |
---|---|
Return type: | String |
Compiles entryCoords directive help data
Returns: | HTML formatted data about entryCoords directive |
---|---|
Return type: | String |
Format the appropriate help sections
Parameters: |
|
---|---|
Returns: | A spreadsheet object with the needed data to show |
Return type: | SpreadSheet |
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 |
Compiles level component help data
Returns: | HTML formatted data about level component |
---|---|
Return type: | String |
Compiles lineMark component help data
Returns: | HTML formatted data about lineMark component |
---|---|
Return type: | String |
Compiles lineOpen component help data
Returns: | HTML formatted data about lineOpen component |
---|---|
Return type: | String |
Compiles lineSide component help data
Returns: | HTML formatted data about lineSide component |
---|---|
Return type: | String |
Compiles location directive help data
Returns: | HTML formatted data about location directive |
---|---|
Return type: | String |
Compiles logLevel directive help data
Returns: | HTML formatted data about logLevel directive |
---|---|
Return type: | String |
Compiles markerAngleGap directive help data
Returns: | HTML formatted data about markerAngleGap directive |
---|---|
Return type: | String |
Compiles markerLengthGap directive help data
Returns: | HTML formatted data about markerLengthGap directive |
---|---|
Return type: | String |
Compiles markerSize directive help data
Returns: | HTML formatted data about markerSize directive |
---|---|
Return type: | SpreadSheet |
Compiles material directive help data
Returns: | HTML formatted data about buildStop directive |
---|---|
Return type: | String |
Renders the name section of the command help
Parameters: |
|
---|---|
Returns: | Formated text |
Return type: | STRING |
Compiles comm directive help data
Returns: | HTML formatted data about comm directive |
---|---|
Return type: | String |
Renders the option section of the command help
Parameter: | table – |
---|---|
Returns: | Formated text |
Return type: | STRING |
Compiles pointMark component help data
Returns: | HTML formatted data about pointMark component |
---|---|
Return type: | String |
Compiles setLevel directive help data
Returns: | HTML formatted data about setLevel directive |
---|---|
Return type: | String |
Compiles share component help data
Returns: | HTML formatted data about share component |
---|---|
Return type: | String |
Compiles showOpenSide directive help data
Returns: | HTML formatted data about showOpenSide directive |
---|---|
Return type: | String |
Compiles site component help data
Returns: | HTML formatted data about site component |
---|---|
Return type: | String |
Compiles skipShape directive help data
Returns: | HTML formatted data about skipShape directive |
---|---|
Return type: | String |
Compiles space component help data
Returns: | HTML formatted data about space component |
---|---|
Return type: | String |
Renders the synopsis section of the command help
Parameter: | syn_sec – |
---|---|
Returns: | Formated text |
Return type: | STRING |
Compiles temporary data to designate that help does not exist
Returns: | HTML formatted data about entryCoords directive |
---|---|
Return type: | String |
Compiles angle ui command help data
Returns: | HTML formatted data |
---|---|
Return type: | SpreadSheet |
Compiles length ui command help data
Returns: | HTML formatted data |
---|---|
Return type: | SpreadSheet |
Compiles kalk ui command help data
Returns: | HTML formatted data |
---|---|
Return type: | SpreadSheet |
Compiles label ui command help data
Returns: | HTML formatted data |
---|---|
Return type: | SpreadSheet |
Compiles length ui command help data
Returns: | HTML formatted data |
---|---|
Return type: | SpreadSheet |
User Interface Helpers
Functions to extend the functionality of Buildes GUI
moduleauthor: | Kene Meniru <Kene.Meniru@illom.org> |
---|
Get the angle between the provided snap designations
Requires three snap-points. The angle between the two vectors is returned.
Parameters: |
|
---|---|
Returns: | Angle between two vectors/line segments |
Return type: | [True, String] |
Mathematical calculations for buildesUi
Returns: | |
---|---|
Return type: |
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: |
|
---|---|
Returns: | Distance between two points |
Return type: | [None, None] | [True, [String, Shape]] |
Render labels for the provided objects
User can provide object names or object names and snap_ids. The snaps will be discarded.
Parameters: |
|
---|---|
Returns: | PythonOCC of provided objects. |
Return type: | [None, PythonOCC.shape, ...] |
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: |
|
---|---|
Returns: | Distance between two points |
Return type: | [None, None] | [True, [String, Shape]] |
Create a PythonOCC arc between provided points
Parameters: |
|
---|---|
Returns: | Wire definition of the line object |
Return type: | PythonOcc.Wire |
Create a PythonOCC line between provided points
Parameters: |
|
---|---|
Returns: | Wire definition of the line object |
Return type: | PythonOcc.Wire |
Create a marker centered on provided point
Parameter: | pnt – |
---|---|
Returns: | |
Return type: |