Sample Code Revit Batch Processor 1.1.15 documentation

Contents:

This Page

duHast.Revit.Common.Geometry package

Submodules

duHast.Revit.Common.Geometry.curve module

Revit curve helper functions

duHast.Revit.Common.Geometry.curve.is_curve_is_within_curve(curve_one, curve_two)

Checks whether one curve is completely within another curve.

Args:

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).

Returns:

The curve that is completely within the other curve, or None if the curves are overlapping.

Example Usage:

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.

duHast.Revit.Common.Geometry.curve.calculate_lengthened_curve_geometry(curve_one, curve_two)

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!

duHast.Revit.Common.Geometry.curve.calculate_shortened_curve_geometry(curve_one, curve_two)

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!

duHast.Revit.Common.Geometry.curve.modify_model_line_action(existing_curve, new_curve, override_joins=True)

Modify the geometry of an existing curve by setting it to a new curve.

Args:

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.

Returns:

object: An instance of the Result class that contains information about the success or failure of the geometry modification.

duHast.Revit.Common.Geometry.curve.translate_curves_in_elevation(doc, original_curves, source_elevation, target_elevation)
duHast.Revit.Common.Geometry.curve.get_perpendicular_line_through_point(original_line, rotation_axis, rotation_point)

Returns a line rotated by 90 degree around the rotation point.

Parameters:
  • 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

Returns:

The rotated line.

Return type:

Autodesk.Revit.DB.Line

duHast.Revit.Common.Geometry.curve.get_curve_level(doc, curve)

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.

Args:

doc (Document): The current model document. area_lines (list): A list of area lines.

Returns:

dict: A dictionary where the keys are the level names and the values are lists of area lines.

duHast.Revit.Common.Geometry.curve.are_lines_parallel(line_one, line_two)

Check if two lines are parallel.

Args:

line_one (object): The first line to compare. line_two (object): The second line to compare.

Returns:

bool: True if the lines are parallel, False otherwise.

duHast.Revit.Common.Geometry.curve.are_lines_perpendicular(line_one, line_two)

Check if two lines are perpendicular.

Args:

line_one (object): The first line to compare. line_two (object): The second line to compare.

Returns:

bool: True if the lines are perpendicular, False otherwise.

duHast.Revit.Common.Geometry.curve.offset_curve(curve, normal_vector, offset_distance)

Offsets a curve in the direction of the normal vector by a specified distance.

Parameters:
  • curve (Autodesk.Revit.DB.Curve) – The curve to be offset.

  • normal_vector (Autodesk.Revit.DB.XYZ) – The normal vector indicating the offset direction.

  • offset_distance (float) – The distance to offset the curve.

Returns:

The offset curve.

Return type:

Autodesk.Revit.DB.Curve

duHast.Revit.Common.Geometry.curve_loops module

Revit curve loops helper functions

duHast.Revit.Common.Geometry.curve_loops.create_curve_loops_through_transform(curve_loops, transform, convert_net_list=False)

Creates a new curve loop by transforming the existing curve loops using the provided transform.

Parameters:
  • curve_loops (list of Autodesk.Revit.DB.CurveLoop) – The curve loops to be transformed.

  • transform (Autodesk.Revit.DB.Transform) – The transform to be applied to the curve loops.

  • convert_net_list (bool) – Flag to indicate whether to convert the curve loops to a .net List of curves (true) or python list (false).

Returns:

A list of transformed curve loops.

Return type:

.net List of Autodesk.Revit.DB.CurveLoop or python list of Autodesk.Revit.DB.CurveLoop

duHast.Revit.Common.Geometry.curve_loops.create_curve_loop_through_offset(curve_loop, offset_distance, offset_to_inside=True)

Creates a new curve loop by offsetting it a given distance.

Some

Parameters:
  • curve_loop (Autodesk.Revit.DB.CurveLoop) – The curve loop to be transformed.

  • offset_distance (float) – The distance to offset the curve loop.

  • offset_normal (Autodesk.Revit.DB.XYZ) – The normal vector to offset the curve loop.

Returns:

A transformed curve loops.

Return type:

Autodesk.Revit.DB.CurveLoop

duHast.Revit.Common.Geometry.curve_loops.get_area_from_closed_curve_loop(doc, view, curve_loop, filled_region_type_id)

Calculates the area of a closed curve loop in a given view.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The Revit document.

  • view (Autodesk.Revit.DB.View) – The view in which the curve loop is located.

  • curve_loop (Autodesk.Revit.DB.CurveLoop) – The closed curve loop.

Returns:

The area of the closed curve loop.

Return type:

float

duHast.Revit.Common.Geometry.curve_loops.convert_loop_to_curve_array(curve_loop)

Convert a curve loop to a CurveArray object. Curve loop can not contain nested loops.

Parameters:

curve_loop (Autodesk.Revit.DB.CurveLoop) – The curve loop to convert.

Returns:

CurveArray object

duHast.Revit.Common.Geometry.curve_loops.convert_curve_loops_to_curve_arr_array(curve_loops)

Convert a list of curve loops to a CurveArrArray object. This is used to create a new extrusion in the family document.

Parameters:

curve_loops – list of curve loops

Returns:

CurveArrArray object

duHast.Revit.Common.Geometry.curve_loops.get_curve_loop_centroid(curve_loop)

Finds an approximate centroid inside the given CurveLoop. The curve loop is assumed to be closed and planar.

Parameters:

original_loop (Autodesk.Revit.DB.CurveLoop) – The CurveLoop to find the centroid of.

Returns:

The centroid point of the CurveLoop.

Return type:

Autodesk.Revit.DB.XYZ

duHast.Revit.Common.Geometry.curve_loops.get_curve_loop_by_offset_towards_centroid(curve_loop, offset_distance)

Creates a new curve loop by offsetting the original curve loop towards its centroid. This is not a size change but a position change!

Parameters:
  • curve_loop (Autodesk.Revit.DB.CurveLoop) – The original CurveLoop to be offset.

  • offset_distance (float) – The distance to offset the curve loop.

Returns:

A new CurveLoop that is offset from the original.

Return type:

Autodesk.Revit.DB.CurveLoop

duHast.Revit.Common.Geometry.geometry module

Revit geometry extraction helper functions

duHast.Revit.Common.Geometry.geometry.get_edge_as_string(edge)

Returns a revit edge as a string.

Parameters:

edge (Autodesk.Revit.DB.Edge) – A revit edge.

Returns:

String where each row represents a point on the edge.

Return type:

str

duHast.Revit.Common.Geometry.geometry.UV_pt_list_from_crv_list(curve_list)

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

duHast.Revit.Common.Geometry.geometry.point_in_polygon(point, polygon)

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

duHast.Revit.Common.Geometry.geometry.flatten_xyz_point_list(polygon)

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

Parameters:

polygon (list Autodesk.Revit.DB.XYZ) – list of XYZ points

Returns:

list of UV points

Return type:

list Autodesk.Revit.DB.UV

duHast.Revit.Common.Geometry.geometry.flatten_xyz_point_list_of_lists(polygons)

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

Parameters:

polygon (list [list Autodesk.Revit.DB.XYZ]) – list of lists of XYZ points

Returns:

list of lists of UV points

Return type:

list [list Autodesk.Revit.DB.UV]

duHast.Revit.Common.Geometry.geometry.get_coordinate_system_translation_and_rotation(doc)

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.

Parameters:

doc (_type_) – _description_

Returns:

3 x 3 matrix describing rotation, 1 x 3 matrix describing translation

Return type:

list (3) [list(3) int], list [int]

duHast.Revit.Common.Geometry.geometry.get_quadrant(vertex, p)

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

Parameters:
  • vertex (Autodesk.Revit.DB.UV) – Revit UV element describing a vertex

  • p (Autodesk.Revit.DB.UV) – Revit UV point

Returns:

An integer of range 0 - 4 describing the quadrant.

Return type:

int

duHast.Revit.Common.Geometry.geometry.x_intercept(p, q, y)

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

Parameters:
  • p (Autodesk.Revit.DB.UV) – Revit UV point

  • q (Autodesk.Revit.DB.UV) – Revit UV point

  • y (double) – _description_

Returns:

_description_

Return type:

double

duHast.Revit.Common.Geometry.geometry.adjust_delta(delta, vertex, next_vertex, p)

https://thebuildingcoder.typepad.com/blog/2010/12/point-in-polygon-containment-algorithm.html

Parameters:
  • delta (_type_) – _description_

  • vertex (_type_) – _description_

  • next_vertex (_type_) – _description_

  • p (_type_) – _description_

Returns:

_description_

Return type:

_type_

duHast.Revit.Common.Geometry.geometry.is_point_within_polygon(polygon, point)

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

Parameters:
  • polygon (list of Autodesk.Revit.DB.UV) – A polygon

  • point (Autodesk.Revit.DB.UV) – A point

Returns:

Refer winding rules above.

Return type:

bool

duHast.Revit.Common.Geometry.geometry.get_signed_polygon_area(uv_points)

Calculates the area of a signed UV polygon.

https://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html

Parameters:

uv_points (list Autodesk.Revit.DB.UV) – list of points defining the polygon.

Returns:

The area of the polygon.

Return type:

double

duHast.Revit.Common.Geometry.geometry.convert_edge_arrays_into_list_of_points(edge_arrays)

Converts an edge array into a list of list of revit XYZ points.

Parameters:

edge_arrays (Autodesk.Revit.DB.EdgeArrayArray ( no not a spelling mistake :) )) – A revit edge array.

Returns:

A List of list of revit XYZ points.

Return type:

list of list Autodesk.Revit.DB.XYZ

duHast.Revit.Common.Geometry.geometry.get_edge_points(edge)

Retrieves the revit XYZ points defining an edge (curves get tessellated!)

Parameters:

edge (Autodesk.Revit.DB.Edge) – An edge of a solid.

Returns:

A list of revit XYZ points.

Return type:

list Autodesk.Revit.DB.XYZ

duHast.Revit.Common.Geometry.geometry.check_duplicate_edge(edges, edge)

Checks whether a collection contains a given edge and returns True if that is the case.

Parameters:
  • edges (list of Autodesk.Revit.DB.Edge) – List of edges toi check against.

  • edge (Autodesk.Revit.DB.Edge) – An edge

Returns:

True if edge is already in collection, otherwise False.

Return type:

bool

duHast.Revit.Common.Geometry.geometry.check_solid_is_zero_height(solid)

Checks if points making up a solid have multiple Z values.

Parameters:

solid (Autodesk.Revit.DB.Solid) – A revit solid object.

Returns:

False if points collection of a solid has multiple z values, True if only one Z value in points collection (2D solid…??)

Return type:

bool

duHast.Revit.Common.Geometry.geometry.check_edges_are_zero_height(edges)

Checks if points making up a edges have multiple Z values.

Parameters:

edges (list Autodesk.Revit.DB.Edge) – A list of edges.

Returns:

False if points collection of a edges has multiple z values, True if only one Z value in points collection (2D edges…??)

Return type:

bool

duHast.Revit.Common.Geometry.geometry.get_lowest_z_from_solid(solid)

Gets the lowest Z value in a solids point collection.

Parameters:

solid (Autodesk.Revit.DB.Solid) – A solid.

Returns:

The lowest Z value of any point in the solids vertex collection.

Return type:

double

duHast.Revit.Common.Geometry.geometry.get_lowest_z_from_edges_point_collection(edges)

Gets the lowest Z value in a edges collection

Parameters:

edges (list Autodesk.Revit.DB.Edge) – A list of edges.

Returns:

The lowest Z value of any point in the edges vertex collection.

Return type:

double

duHast.Revit.Common.Geometry.geometry.edges_are_connected(edge1, edge2)

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!

Parameters:
  • edge1 (Autodesk.Revit.DB.Edge) – An edge.

  • edge2 (Autodesk.Revit.DB.Edge) – Another edge.

Returns:

_description_

Return type:

bool

duHast.Revit.Common.Geometry.geometry.get_faces_sorted_by_area_from_solid(solid)

Returns all faces from a solid sorted descending from biggest to smallest by area.

Parameters:

solid (Autodesk.Revit.DB.Solid) – A solid.

Returns:

A list of faces, sorted biggest to smallest by area.

Return type:

list Autodesk.Revit.DB.Face

duHast.Revit.Common.Geometry.geometry.pair_faces_by_area(faces)

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.

Parameters:

faces (list Autodesk.Revit.DB.Face) – A list of faces.

Returns:

A list of lists of faces.

Return type:

list of list Autodesk.Revit.DB.Face

duHast.Revit.Common.Geometry.geometry.get_faces_with_lowest_z_from_pairs(face_pairs)

Gets the face with the lowest Z value from list of faces.

Parameters:

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.

Returns:

A list of faces.

Return type:

list Autodesk.Revit.DB.Face

duHast.Revit.Common.Geometry.geometry.get_unique_horizontal_faces(faces)

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…

Parameters:

faces (list Autodesk.Revit.DB.Face) – A list of faces.

Returns:

A list of faces.

Return type:

list Autodesk.Revit.DB.Face

duHast.Revit.Common.Geometry.geometry.is_loop_within_other_loop_but_not_reference_loops(exterior_loop, other_loop, hole_loops)

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

Parameters:
  • 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.

Returns:

True if within exterior loop but not within hole loops, otherwise False.

Return type:

bool

duHast.Revit.Common.Geometry.geometry.build_loops_dictionary(loops)

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

Parameters:

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

Returns:

A dictionary.

Return type:

dic {int: list[namedtuple(‘uvLoop’, ‘loop area id threeDPoly’)]}

duHast.Revit.Common.Geometry.geometry.negate_vector(vector)

Negates the direction of a given vector :param vector: The vector to negate :type vector: list or tuple :return: The negated vector :rtype: list

duHast.Revit.Common.Geometry.geometry.merge_bounding_box_xyz(bounding_box_xyz_0, bounding_box_xyz_1)

Merges two bounding boxes into one.

Parameters:
  • bounding_box_xyz_0 (BoundingBoxXYZ) – The first bounding box

  • bounding_box_xyz_1 (BoundingBoxXYZ) – The second bounding box

Returns:

The merged bounding box

Return type:

BoundingBoxXYZ

duHast.Revit.Common.Geometry.geometry.get_bounding_box_centre(bounding_box)

Get the center of a bounding box. :param bounding_box: The bounding box :type bounding_box: Autodesk.Revit.DB.BoundingBoxXYZ :return: The center point of the bounding box :rtype: Autodesk.Revit.DB.XYZ

duHast.Revit.Common.Geometry.points module

Revit points helper functions

duHast.Revit.Common.Geometry.points.rotate_point_around_z_with_origin(point, origin, angle_in_radians)

Rotates a point around the Z-axis with a given origin and angle in radians. Returns the rotated point.

Parameters:
  • 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.

Returns:

The rotated point.

Return type:

Autodesk.Revit.DB.XYZ

duHast.Revit.Common.Geometry.points.transform_point_by_elem_transform(pt, transform)

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

duHast.Revit.Common.Geometry.points.sort_points_by_min_and_max(min_pt, max_pt)

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

duHast.Revit.Common.Geometry.points.get_point_as_doubles(point, include_z=False)

Converts a revit XYZ to a list of doubles in order x,y,z.

Parameters:

point (Autodesk.Revit.DB.XYZ) – A revit point.

Returns:

List of doubles in order of x,y,z

Return type:

list double

duHast.Revit.Common.Geometry.points.get_doubles_as_xyz(doubles, include_z=False)

Converts a list of doubles to a revit XYZ.

Parameters:

doubles (list double) – List of doubles in order of x,y,z

Returns:

A revit point.

Return type:

Autodesk.Revit.DB.XYZ

duHast.Revit.Common.Geometry.points.get_rotation_around_z_as_xyz(doubles)

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.

Parameters:

doubles (list double) – List of doubles in order of x,y,z

Returns:

A revit point.

Return type:

Autodesk.Revit.DB.XYZ

duHast.Revit.Common.Geometry.points.flatten_xyz_point(point)

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

Parameters:

point (Autodesk.Revit.DB.XYZ) – A revit point.

Returns:

A 2D point (UV)

Return type:

Autodesk.Revit.DB.UV

duHast.Revit.Common.Geometry.points.are_points_identical(p1, p2)

Compares the X,Y,Z values of two revit point and returns True if they are the same, otherwise False

Parameters:
  • p1 (Autodesk.Revit.DB.XYZ) – A revit point.

  • p2 (Autodesk.Revit.DB.XYZ) – A revit point.

Returns:

True if they are the same, otherwise False.

Return type:

bool

duHast.Revit.Common.Geometry.points.check_duplicate_point(points, point)

Checks whether a collection of points contains another given point and returns True if that is the case.

Parameters:
  • points (list Autodesk.Revit.DB.XYZ) – List of revit points

  • point (Autodesk.Revit.DB.XYZ) – A revit point.

Returns:

True if point is in collection, otherwise False.

Return type:

bool

duHast.Revit.Common.Geometry.points.on_which_side_of_line_is_point(line, point)

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.

Refer https://math.stackexchange.com/questions/274712/calculate-on-which-side-of-a-straight-line-is-a-given-point-located

Parameters:
  • line (Autodesk.Revit.DB.Line) – Line to check which side a point is on.

  • point (Autodesk.Revit.DB.XYZ) – The point to check;

Returns:

double

Return type:

double

duHast.Revit.Common.Geometry.points.distance_between_two_points(p1, p2)

Returns the distance between two points.

Parameters:
  • p1 (Autodesk.Revit.DB.XYZ) – First point.

  • p2 (Autodesk.Revit.DB.XYZ) – Second point.

Returns:

The distance between points

Return type:

double

duHast.Revit.Common.Geometry.points.get_point_as_string(point)

Returns Revit point as a string.

Parameters:

point (Autodesk.Revit.DB.XYZ) – A revit point.

Returns:

String in format ‘X:Y:Z’

Return type:

str

duHast.Revit.Common.Geometry.points.convert_XYZ_to_point3(point_xyz)

Converts a Revit XYZ to a duHast point3 instance. X,Y,Z coordinates are converted to metric mm.

Parameters:

point_xyz (Autodesk.Revit.DB.XYZ) – A revit 3D point

Returns:

A point3 instance

Return type:

Point3

duHast.Revit.Common.Geometry.points.convert_XYZ_to_point2(point_xyz)

Converts a Revit XYZ to a duHast point2 instance. X,Y coordinates are converted to metric mm. Z is dropped.

Parameters:

point_xyz (Autodesk.Revit.DB.XYZ) – A revit 3D point

Returns:

A point2 instance

Return type:

Point2

duHast.Revit.Common.Geometry.points.convert_point3_to_xyz(point_3)

Converts duHast point_3 (metric mm) to Revit XYZ (imperial feet).

Parameters:

point_3 (Point3) – a duHast 3D point

Returns:

A revit XYZ instance

Return type:

Autodesk.Revit.DB.XYZ

duHast.Revit.Common.Geometry.solids module

Revit solids helper functions

duHast.Revit.Common.Geometry.solids.get_2d_points_from_solid(element)

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.

Parameters:

element (Autodesk.Revit.DB.Element) – A revit element instance.

Returns:

A list of data geometry instances.

Return type:

list of DataGeometry

duHast.Revit.Common.Geometry.solids.get_solid_bounding_box(solid)

Returns a bounding box from a solid.

Parameters:

solid (Autodesk.Revit.DB.Solid) – The solid to get the bounding box from.

Returns:

The bounding box of the solid.

Return type:

Autodesk.Revit.DB.BoundingBoxXYZ

duHast.Revit.Common.Geometry.solids.get_bounding_box_from_family_geometry(geometry_element)

Returns a bounding box from the families solid elements geometry only. This is different from the family instance bounding box!

Parameters:

geometry_element (Autodesk.Revit.DB.GeometryElement) – The geometry element of a family instance.

Returns:

The bounding box of the family geometry.

Return type:

Autodesk.Revit.DB.BoundingBoxXYZ

duHast.Revit.Common.Geometry.solids.convert_solid_to_flattened_2d_points(solid)

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

duHast.Revit.Common.Geometry.to_data_conversion module

Revit Geometry to data geometry conversion helper functions.

duHast.Revit.Common.Geometry.to_data_conversion.convert_xyz_in_data_geometry_polygons(doc, dgObject)

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

duHast.Revit.Common.Geometry.to_data_conversion.convert_bounding_box_to_flattened_2d_points(bounding_box)

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

duHast.Revit.Common.Geometry.to_data_conversion.get_2d_points_from_revit_element_type_in_model(doc, element_instance_getter)

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.

Parameters:
  • 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

Returns:

A list of data geometry instances.

Return type:

list of DataGeometry

duHast.Revit.Common.Geometry.to_data_conversion.convert_revit_bounding_box_to_geometry2_bounding_box(bounding_box)

duHast.Revit.Common.Geometry.transforms module

Revit transform helper functions

duHast.Revit.Common.Geometry.transforms.move_xyz_to_zero(point)

Moves the given XYZ point to the origin (0, 0, 0) by creating a translation transform.

Parameters:

xyz (Autodesk.Revit.DB.XYZ) – The XYZ point to move.

Returns:

A Transform object representing the translation to move the point to the origin.

Return type:

Autodesk.Revit.DB.Transform

Module contents