Sample Code Revit Batch Processor 1.1.16 documentation
Covers placed family instances belonging to a caller-supplied list of categories (furniture, equipment, specialty equipment, etc.). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Extracts the placement location and orientation of a family instance and
returns them as a populated DataGeometryBase instance.
translation_coord - x/y/z position converted to metric mm (Point3)
rotation_coord - 3 x 3 rotation matrix derived from the instance’slocal transform (each row is a basis vector [x, y, z])
Only Autodesk.Revit.DB.LocationPoint instances are supported.
Line-based placements (LocationCurve) return None.
revit_family_instance (Autodesk.Revit.DB.FamilyInstance) – A placed Revit family instance.
A populated location data object, or None if the location type is not a point.
DataGeometryBase or None
Returns a list of unique room element ids that the family instance belongs to, resolved across all project phases.
Lookup strategy (in order):
Phase-aware - iterates doc.Phases and calls
FamilyInstance.get_Room(phase) for each phase. This is the primary
source and correctly handles items whose room assignment changes between
construction phases.
Direct property - FamilyInstance.Room is tried when the phase
loop yields nothing (e.g. older family hosting types).
Point fallback - if both of the above return nothing, the instance’s
LocationPoint is used with Document.GetRoomAtPoint to perform a
spatial lookup against the last project phase.
Note
Doors and windows should use FamilyInstance.FromRoom /
FamilyInstance.ToRoom instead. Those categories are not included
in DEFAULT_ITEM_CATEGORIES, so this function does not handle
that case.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revit_family_instance (Autodesk.Revit.DB.FamilyInstance) – A placed Revit family instance.
Unique room element ids (integers), may be empty.
list[int]
Determines the nearest level below a family instance by comparing the lowest Z coordinate of its solid geometry against the ascending list of project levels.
Algorithm:
Compute the solid-based bounding box of the instance.
Take bbox.Min.Z (internal Revit feet) as the bottom of the item.
Walk all levels sorted ascending by ProjectElevation and keep the
last one whose elevation is at or below bbox.Min.Z.
If the item sits below every level (e.g. underground) the lowest level is used as a fallback.
offset_from_level = bbox.Min.Z - level.ProjectElevation, converted
to metric mm.
Returns a default empty DataLevel when no solid geometry or no
levels are found in the document.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revit_family_instance (Autodesk.Revit.DB.FamilyInstance) – A placed Revit family instance.
A populated data level instance.
Returns a DataItem populated from a single placed family instance.
Populated fields:
instance id and instance parameters
type name and type parameters
level name, level id, and offset from level
location point (x/y/z in mm) and rotation matrix
phasing (created / demolished)
design set / option membership
model name
Returns None when the instance has no valid LocationPoint
(e.g. line-based families).
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revit_family_instance (Autodesk.Revit.DB.FamilyInstance) – A placed Revit family instance.
A populated data item object, or None.
DataItem or None
Collects all placed Autodesk.Revit.DB.FamilyInstance elements
belonging to the given list of categories and returns a list of
DataItem objects.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
categories (list[Autodesk.Revit.DB.BuiltInCategory] or None) – List of Autodesk.Revit.DB.BuiltInCategory values
to collect from. Defaults to DEFAULT_ITEM_CATEGORIES when
None is supplied.
A list of populated data item instances.
list[DataItem]