Sample Code Revit Batch Processor 1.1.11 documentation
Checks whether one curve is completely within another curve.
curve_one: The first curve to compare (can be an arc or a line). curve_two: The second curve to compare (can be an arc or a line).
The curve that is completely within the other curve, or None if the curves are overlapping.
curve_one = … curve_two = … result = check_curve_is_within_curve(curve_one, curve_two) print(result)
Output: - If the curves are identical, it will return curve_one. - If curve_two is completely within curve_one, it will return curve_two. - If curve_one is completely within curve_two, it will return curve_one. - If the curves are overlapping, it will return None.
Two options when lines are overlapping:
extend the longer line to the end of the shorter line not overlapping and delete the shorter line or
shorten shorter line to move the endpoint currently overlapping to the end point of the longer line, therefore removing the overlap
First option will shorten number of room separation lines in model. However when multiple lines overlap a single long line this code will delete a shorter overlapping line still required!
returns two values: first one is the curve to change in length, second one is the curve to delete!
Two options when lines are overlapping:
extend the longer line to the end of the shorter line not overlapping and delete the shorter line or
shorten shorter line to move the endpoint currently overlapping to the end point of the longer line, therefore removing the overlap
This is an attempt on option 2
returns the curve of which to change the length!
Modify the geometry of an existing curve by setting it to a new curve.
existing_curve (object): The existing curve that needs to be modified. new_curve (object): The new curve that will replace the existing curve. override_joins (bool, optional): Flag to indicate whether to override the joins between adjoining model lines. Defaults to True.
object: An instance of the Result class that contains information about the success or failure of the geometry modification.
Returns a line rotated by 90 degree around the rotation point.
original_line (Autodesk.Revit.DB.Line) – The original line to be rotated
rotation_point (Autodesk.Revit.DB.XYZ) – The point to rotate around.
rotation_axis (Autodesk.Revit.DB.XYZ) – The axis around to rotate the line
The rotated line.
Autodesk.Revit.DB.Line
Sorts the area lines based on their associated level names and returns a dictionary where the keys are the level names and the values are lists of area lines.
doc (Document): The current model document. area_lines (list): A list of area lines.
dict: A dictionary where the keys are the level names and the values are lists of area lines.
Check if two lines are parallel.
line_one (object): The first line to compare. line_two (object): The second line to compare.
bool: True if the lines are parallel, False otherwise.
Check if two lines are perpendicular.
line_one (object): The first line to compare. line_two (object): The second line to compare.
bool: True if the lines are perpendicular, False otherwise.
Returns a revit edge as a string.
edge (Autodesk.Revit.DB.Edge) – A revit edge.
String where each row represents a point on the edge.
str
Returns a list of UV points from a list of curves :param curve_list: A list of curves :param type: list :return: A list of UV points :rtype: list
Returns True if a point is inside a polygon, and False if it is not :param point: The point to check :type point: list, tuple, or set :param polygon: The polygon to check :type polygon: list, tuple, or set :return: True if the point is inside the polygon, False if it is not :rtype: bool
Flattens a list of XYZ points to a list of UV points by omitting the Z value of each XYZ.
https://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html
polygon (list Autodesk.Revit.DB.XYZ) – list of XYZ points
list of UV points
list Autodesk.Revit.DB.UV
Flattens a list lists of XYZ points to a list of lists of UV points by omitting the Z value of each XYZ.
https://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html
polygon (list [list Autodesk.Revit.DB.XYZ]) – list of lists of XYZ points
list of lists of UV points
list [list Autodesk.Revit.DB.UV]
Returns the rotation as a 3 x 3 matrix and the translation as a 1 x 3 matrix of the shared coordinate system active in document.
doc (_type_) – _description_
3 x 3 matrix describing rotation, 1 x 3 matrix describing translation
list (3) [list(3) int], list [int]
Determines the quadrant of a polygon vertex relative to the test point.
https://thebuildingcoder.typepad.com/blog/2010/12/point-in-polygon-containment-algorithm.html
vertex (Autodesk.Revit.DB.UV) – Revit UV element describing a vertex
p (Autodesk.Revit.DB.UV) – Revit UV point
An integer of range 0 - 4 describing the quadrant.
int
Determine the X intercept of a polygon edge with a horizontal line at the Y value of the test point.
https://thebuildingcoder.typepad.com/blog/2010/12/point-in-polygon-containment-algorithm.html
p (Autodesk.Revit.DB.UV) – Revit UV point
q (Autodesk.Revit.DB.UV) – Revit UV point
y (double) – _description_
_description_
double
https://thebuildingcoder.typepad.com/blog/2010/12/point-in-polygon-containment-algorithm.html
delta (_type_) – _description_
vertex (_type_) – _description_
next_vertex (_type_) – _description_
p (_type_) – _description_
_description_
_type_
Checks whether a point is within a polygon.
https://thebuildingcoder.typepad.com/blog/2010/12/point-in-polygon-containment-algorithm.html odd number of windings rule: if (angle & 4) return INSIDE else return OUTSIDE non-zero winding rule: if (angle != 0) return INSIDE else return OUTSIDE
polygon (list of Autodesk.Revit.DB.UV) – A polygon
point (Autodesk.Revit.DB.UV) – A point
Refer winding rules above.
bool
Calculates the area of a signed UV polygon.
https://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html
uv_points (list Autodesk.Revit.DB.UV) – list of points defining the polygon.
The area of the polygon.
double
Converts an edge array into a list of list of revit XYZ points.
edge_arrays (Autodesk.Revit.DB.EdgeArrayArray ( no not a spelling mistake :) )) – A revit edge array.
A List of list of revit XYZ points.
list of list Autodesk.Revit.DB.XYZ
Retrieves the revit XYZ points defining an edge (curves get tessellated!)
edge (Autodesk.Revit.DB.Edge) – An edge of a solid.
A list of revit XYZ points.
list Autodesk.Revit.DB.XYZ
Checks whether a collection contains a given edge and returns True if that is the case.
edges (list of Autodesk.Revit.DB.Edge) – List of edges toi check against.
edge (Autodesk.Revit.DB.Edge) – An edge
True if edge is already in collection, otherwise False.
bool
Checks if points making up a solid have multiple Z values.
solid (Autodesk.Revit.DB.Solid) – A revit solid object.
False if points collection of a solid has multiple z values, True if only one Z value in points collection (2D solid…??)
bool
Checks if points making up a edges have multiple Z values.
edges (list Autodesk.Revit.DB.Edge) – A list of edges.
False if points collection of a edges has multiple z values, True if only one Z value in points collection (2D edges…??)
bool
Gets the lowest Z value in a solids point collection.
solid (Autodesk.Revit.DB.Solid) – A solid.
The lowest Z value of any point in the solids vertex collection.
double
Gets the lowest Z value in a edges collection
edges (list Autodesk.Revit.DB.Edge) – A list of edges.
The lowest Z value of any point in the edges vertex collection.
double
Checks whether edges are connected by comparing their points. If there is an identical point in both then they are connected.
Revit solids dont have crossing edges!
edge1 (Autodesk.Revit.DB.Edge) – An edge.
edge2 (Autodesk.Revit.DB.Edge) – Another edge.
_description_
bool
Returns all faces from a solid sorted descending from biggest to smallest by area.
solid (Autodesk.Revit.DB.Solid) – A solid.
A list of faces, sorted biggest to smallest by area.
list Autodesk.Revit.DB.Face
Returns a list of lists of face pairs, where a nested list contains faces with the same measured area.
Sample would be a ceiling solid. The top and bottom face of that ceiling would be an area pair.
faces (list Autodesk.Revit.DB.Face) – A list of faces.
A list of lists of faces.
list of list Autodesk.Revit.DB.Face
Gets the face with the lowest Z value from list of faces.
face_pairs (list of list Autodesk.Revit.DB.Face) – A list of lists of face pairs, where a nested list contains faces with the same measured area.
A list of faces.
list Autodesk.Revit.DB.Face
Filters out any horizontal faces from list of faces past in.
Will also further filter by: faces with the same area only the face with the lower Z value will be returned. Note: works only on planar faces
TODO: It could be way simpler just to check for the face with a negative face normal Z value…
faces (list Autodesk.Revit.DB.Face) – A list of faces.
A list of faces.
list Autodesk.Revit.DB.Face
Checks whether any of the other loops is within the exterior loop and if so if it is not also within one of the holeLoops …that would be an island
exterior_loop (list of Autodesk.Revit.DB.UV) – A polygon loop describing the external boundary of a face.
other_loop (list of Autodesk.Revit.DB.UV) – A polygon loop which is to be checked as to whether it is within the exterior loop and the any hole loops.
hole_loops (namedtuple('uvLoop', 'loop area id threeDPoly') .Loop is a list of UV points defining a polygon loop .area is a double describing the polygon area .id is an integer .threeDPoly is an edge loop) – A list of named tuples containing .loop property which is a list of UV points forming a polygon which have been identified as creating a hole in the exteriorLoop.
True if within exterior loop but not within hole loops, otherwise False.
bool
Will return a dic where:
key is the outer loop of a polygon id
values is a list of tuples describing holes in the key polygon
loops (list[namedtuple('uvLoop', 'loop area id threeDPoly')]) – A list of named tuples describing polygons. .Loop is a list of UV points defining a polygon loop .area is a double describing the polygon area .id is an integer .threeDPoly is an edge loop
A dictionary.
dic {int: list[namedtuple(‘uvLoop’, ‘loop area id threeDPoly’)]}
Negates the direction of a given vector :param vector: The vector to negate :type vector: list or tuple :return: The negated vector :rtype: list
Merges two bounding boxes into one. :param bounding_box_xyz_0: The first bounding box :type bounding_box_xyz_0: BoundingBoxXYZ :param bounding_box_xyz_1: The second bounding box :type bounding_box_xyz_1: BoundingBoxXYZ
The merged bounding box
BoundingBoxXYZ
Rotates a point around the Z-axis with a given origin and angle in radians. Returns the rotated point.
point (Autodesk.Revit.DB.XYZ) – The point to rotate.
origin (Autodesk.Revit.DB.XYZ) – The origin of the rotation.
angle_in_radians (float) – The angle in radians to rotate the point.
The rotated point.
Autodesk.Revit.DB.XYZ
Transforms a point by an element transform :param pt: The point to transform :type pt: XYZ :param transform: The transform to use :type transform: Transform :return: The transformed point :rtype: XYZ
Takes BoundingBox or Outline Min and Max points and returns the true Min and Max points. This is to ensure no zero thickness geometries are created. :param min_pt: The minimum point :type min_pt: XYZ :param max_pt: The maximum point :type max_pt: XYZ :return: The sorted points :rtype: tuple
Converts a revit XYZ to a list of doubles in order x,y,z.
point (Autodesk.Revit.DB.XYZ) – A revit point.
List of doubles in order of x,y,z
list double
Converts a list of doubles to a revit XYZ.
doubles (list double) – List of doubles in order of x,y,z
A revit point.
Autodesk.Revit.DB.XYZ
Converts a list of doubles to a revit XYZ. The first two doubles are the x,y coordinates of the point. The third double is the z coordinate of the point to which 1 is added.
doubles (list double) – List of doubles in order of x,y,z
A revit point.
Autodesk.Revit.DB.XYZ
Flattens a XYZ point to a UV by omitting the Z value of the XYZ.
https://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html
point (Autodesk.Revit.DB.XYZ) – A revit point.
A 2D point (UV)
Autodesk.Revit.DB.UV
Compares the X,Y,Z values of two revit point and returns True if they are the same, otherwise False
p1 (Autodesk.Revit.DB.XYZ) – A revit point.
p2 (Autodesk.Revit.DB.XYZ) – A revit point.
True if they are the same, otherwise False.
bool
Checks whether a collection of points contains another given point and returns True if that is the case.
points (list Autodesk.Revit.DB.XYZ) – List of revit points
point (Autodesk.Revit.DB.XYZ) – A revit point.
True if point is in collection, otherwise False.
bool
If d<0 then the point lies on one side of the line, and if d>0 then it lies on the other side. If d=0 then the point lies exactly line.
line (Autodesk.Revit.DB.Line) – Line to check which side a point is on.
point (Autodesk.Revit.DB.XYZ) – The point to check;
double
double
Returns the distance between two points.
p1 (Autodesk.Revit.DB.XYZ) – First point.
p2 (Autodesk.Revit.DB.XYZ) – Second point.
The distance between points
double
Returns Revit point as a string.
point (Autodesk.Revit.DB.XYZ) – A revit point.
String in format ‘X:Y:Z’
str
Converts a Revit XYZ to a duHast point3 instance. X,Y,Z coordinates are converted to metric mm.
point_xyz (Autodesk.Revit.DB.XYZ) – A revit 3D point
A point3 instance
Converts a Revit XYZ to a duHast point2 instance. X,Y coordinates are converted to metric mm. Z is dropped.
point_xyz (Autodesk.Revit.DB.XYZ) – A revit 3D point
A point2 instance
Returns a list of lists of data geometry instances representing the flattened (2D geometry) of the Element List of Lists because an element can be made up of multiple solids. Each nested list represents one element solid. Does not work with in place elements.
element (Autodesk.Revit.DB.Element) – A revit element instance.
A list of data geometry instances.
list of DataGeometry
Returns a bounding box from a solid.
solid (Autodesk.Revit.DB.Solid) – The solid to get the bounding box from.
The bounding box of the solid.
Autodesk.Revit.DB.BoundingBoxXYZ
Returns a bounding box from the families solid elements geometry only. This is different from the family instance bounding box!
geometry_element (Autodesk.Revit.DB.GeometryElement) – The geometry element of a family instance.
The bounding box of the family geometry.
Autodesk.Revit.DB.BoundingBoxXYZ
Converts a solid into a 2D polygon by projecting it onto a plane.( Removes Z values…)
First nested list is the outer loop, any other following lists describe holes within the area of the polygon defined be points in first list.
Arcs, circles will be tessellated to polygons.
:param solid: A solid.
:type solid: Autodesk.Revit.DB.Solid
:return: A list of data geometry instances.
:rtype: list of DataGeometryPolygon
Converts Revit XYZ objects stored in a data geometry object into groups of doubles for inner and outer loops and stores them in new data geometry object. It also populates translation and rotation matrix data of coordinate system information.
:param doc: _description_
:type doc: _type_
:param dgObject: A data geometry object.
:type dgObject: DataGeometryPolygon
:return: A data geometry object.
:rtype: DataGeometryPolygon
Converts a bounding box into a 2D polygon by projecting it onto a plane.( Removes Z values…)
:param bounding_box: A bounding box.
:type bounding_box: Autodesk.Revit.DB.BoundingBoxXYZ
:return: A list of data geometry instances.
:rtype: list of DataGeometryPolygon
Returns a list of lists of points representing the flattened(2D geometry) of the elements List of Lists because a elements can be made up of multiple solids. Each nested list represents one solid within the elements geometry. Does not work with in place elements.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
element_instance_getter (func(doc)) – Function returning all element instances of a particular category in the model as an element collector
A list of data geometry instances.
list of DataGeometry