create
Database objects creation functions.
The model, view and drawing helpers accept points as DB.XYZ or
(x, y[, z]) tuples, and lengths as feet or as strings that
units.parse_length reads, such as 32'-6" or 900mm.
Note
Every helper that changes the document must be called inside a transaction.
Attributes
mlogger = get_logger(__name__)
module-attribute
PARAM_VALUE_EVALUATORS = {'startswith': (DB.FilterStringBeginsWith, DB.FilterStringBeginsWith), 'contains': (DB.FilterStringContains, DB.FilterStringContains), 'endswith': (DB.FilterStringEndsWith, DB.FilterStringEndsWith), '==': (DB.FilterStringEquals, DB.FilterNumericEquals), '>': (DB.FilterStringGreater, DB.FilterNumericGreater), '>=': (DB.FilterStringGreaterOrEqual, DB.FilterNumericGreaterOrEqual), '<': (DB.FilterStringLess, DB.FilterNumericLess), '<=': (DB.FilterStringLessOrEqual, DB.FilterNumericLessOrEqual)}
module-attribute
ELEVATION_SIDES = {'south': (0.0, -1.0), 'north': (0.0, 1.0), 'east': (1.0, 0.0), 'west': (-1.0, 0.0)}
module-attribute
SHEET_ANCHORS = ('top_left', 'top_right', 'bottom_left', 'bottom_right', 'center')
module-attribute
Classes
FamilyLoaderOptionsHandler(overwriteParameterValues=True)
Bases: IFamilyLoadOptions
Family loader options handler.
Source code in pyrevitlib/pyrevit/revit/db/create.py
Methods:
OnFamilyFound(familyInUse, overwriteParameterValues)
A method called when the family was found in the target document.
The interface declares ref parameters: IronPython passes a StrongBox to mutate; pythonnet expects the updated values returned in a tuple after the return value.
Source code in pyrevitlib/pyrevit/revit/db/create.py
OnSharedFamilyFound(sharedFamily, familyInUse, source, overwriteParameterValues)
Source code in pyrevitlib/pyrevit/revit/db/create.py
CopyUseDestination
Bases: IDuplicateTypeNamesHandler
Handle copy and paste errors.
Methods:
OnDuplicateTypeNamesFound(args)
Functions:
create_param_from_definition(param_def, category_list, builtin_param_group, type_param=False, allow_vary_betwen_groups=False, doc=None)
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_shared_param(param_id_or_name, category_list, builtin_param_group, type_param=False, allow_vary_betwen_groups=False, doc=None)
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_new_project(template=None, imperial=True)
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_revision(description=None, by=None, to=None, date=None, alphanum=False, nonum=False, doc=None)
Create a revision.
Note
On Revit 2023+, numbering comes from a RevisionNumberingSequence, so
alphanum assigns the document's first alphanumeric sequence and
nonum clears the sequence.
Raises:
| Type | Description |
|---|---|
PyRevitException
|
|
Source code in pyrevitlib/pyrevit/revit/db/create.py
copy_elements(element_ids, src_doc, dest_doc, return_ids=False)
Source code in pyrevitlib/pyrevit/revit/db/create.py
copy_revisions(revisions, src_doc, dest_doc)
Source code in pyrevitlib/pyrevit/revit/db/create.py
copy_all_revisions(src_doc, dest_doc)
copy_viewtemplates(viewtemplates, src_doc, dest_doc)
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_sheet(sheet_num, sheet_name, titleblock_id=DB.ElementId.InvalidElementId, doc=None)
Create a sheet with a number and a name.
Must run inside a transaction. Raises if the sheet number is already used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sheet_num
|
str
|
sheet number, unique in the document. |
required |
sheet_name
|
str
|
sheet name. |
required |
titleblock_id
|
ElementId
|
title block type id; the default creates a sheet without a title block. |
InvalidElementId
|
doc
|
Document
|
target document; defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
|
DB.ViewSheet: the new sheet. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_3d_view(view_name, isometric=True, doc=None)
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_revision_sheetset(revisions, name_format='Revision {}', match_any=True, doc=None)
Source code in pyrevitlib/pyrevit/revit/db/create.py
load_family(family_file, doc=None)
Loads Family from specified file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
family_file
|
str
|
Required. Fully qualified filename of the Family file, usually ending in .rfa. |
required |
doc
|
Document
|
Optional. If not specified DOCS.doc used. |
None
|
Returns:
| Type | Description |
|---|---|
|
list[DB.FamilySymbol]: list of all Family symbols. Returns symbols whether the family |
|
|
was just loaded or already existed in the document. Returns empty list only if the |
|
|
family file cannot be loaded and the family is not found in the document. |
WARNING! This function MUST be used within a transaction!
Important
A non-empty list does not prove Revit loaded the file; it can contain
symbols from a matching family already in the document. Call
:func:load_family_with_result when the direct Revit load result is
required.
Example
from pyrevit.revit.db import create, transaction
family_path = r"C:\Families\MyFamily.rfa" with transaction.Transaction('Load Family'): symbols = create.load_family(family_path) if symbols: print("Found {} symbol(s)".format(len(symbols))) for symbol in symbols: print(" - {}".format(symbol.Family.Name)) else: print("Family file not found or failed to load")
Source code in pyrevitlib/pyrevit/revit/db/create.py
load_family_with_result(family_file, doc=None)
Load a family and return Revit's result with its available symbols.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
family_file
|
str
|
Fully qualified path to the family file. |
required |
doc
|
Document
|
Target document. Defaults to the active document. |
None
|
Returns:
| Type | Description |
|---|---|
|
tuple[bool, list[DB.FamilySymbol]]: The direct Revit load result and |
|
|
symbols from the loaded or matching existing family. |
Important
A false result can still include symbols when Revit refuses the file because a matching family is already present. Callers that report an overwrite must use the boolean result rather than symbol-list truthiness.
Source code in pyrevitlib/pyrevit/revit/db/create.py
load_family_symbol(family_file, symbol_name, doc=None)
Load one family symbol through the engine-specific out-param bridge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
family_file
|
str
|
Fully qualified path to the family file. |
required |
symbol_name
|
str
|
Family type name to load. |
required |
doc
|
Document
|
Target document. Defaults to the active document. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True when Revit loads the requested symbol. |
Important
The caller must have an open Revit transaction.
Source code in pyrevitlib/pyrevit/revit/db/create.py
enable_worksharing(levels_workset_name='Shared Levels and Grids', default_workset_name='Workset1', doc=None)
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_workset(workset_name, doc=None)
create_filledregion(filledregion_name, fillpattern_element, doc=None)
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_text_type(name, font_name=None, font_size=0.01042, tab_size=0.02084, bold=False, italic=False, underline=False, width_factor=1.0, doc=None)
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_param_value_filter(filter_name, param_id, param_values, evaluator, match_any=True, case_sensitive=False, exclude=False, category_list=None, doc=None)
Source code in pyrevitlib/pyrevit/revit/db/create.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | |
to_xyz(point, z=None)
Return a DB.XYZ from an XYZ or an (x, y[, z]) tuple.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
XYZ | tuple
|
point; tuple values may be length strings. |
required |
z
|
float
|
elevation that replaces the point's own Z. |
None
|
Returns:
| Type | Description |
|---|---|
XYZ
|
the point. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
rectangle_points(x1, y1, x2, y2)
Return the corners of an axis-aligned rectangle, counter-clockwise.
The two points may be any pair of opposite corners; the corners are returned from the south-west one. Edge 0 is the south edge, edge 1 the east, edge 2 the north and edge 3 the west; the roof functions refer to edges by index.
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_curve_loop(points, z=0.0)
Return a closed DB.CurveLoop of lines through points at elevation z.
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_curve_array(points, z=0.0, closed=True)
Return a DB.CurveArray of lines through points at elevation z.
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_wall(start, end, wall_type, level=None, height=10.0, top_level=None, base_offset=0.0, structural=False, doc=None)
Create a straight wall along its location line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
XYZ | tuple
|
location line start (plan point). |
required |
end
|
XYZ | tuple
|
location line end. |
required |
wall_type
|
WallType | str
|
wall type or its name. |
required |
level
|
Level | str
|
base level, defaults to the active plan's level or the lowest level. |
None
|
height
|
float | str
|
unconnected height. |
10.0
|
top_level
|
Level | str
|
make the top follow this level instead of an unconnected height. |
None
|
base_offset
|
float | str
|
offset from the base level. |
0.0
|
structural
|
bool
|
structural wall. |
False
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
Wall
|
the wall. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
when no transaction is open, or a name doesn't match (the message lists the valid names). |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_walls(points, wall_type, level=None, height=10.0, closed=True, top_level=None, doc=None)
Create walls along a polyline, one wall per pair of consecutive points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list
|
plan points as DB.XYZ or (x, y) tuples. |
required |
wall_type
|
WallType | str
|
wall type or its name. |
required |
level
|
Level | str
|
base level, defaults as in create_wall. |
None
|
height
|
float | str
|
unconnected height. |
10.0
|
closed
|
bool
|
also join the last point to the first. |
True
|
top_level
|
Level | str
|
make the tops follow this level. |
None
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
list[Wall]
|
walls, in the order of the points. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_profile_wall(profile_points, wall_type, level=None, structural=False, doc=None)
Create a wall from a closed outline drawn in its vertical plane.
For walls that aren't rectangles in elevation, such as gable ends, stepped parapets or walls under a sloped ceiling. The wall is native, so it keeps its type's layers and materials, joins, and hosts openings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_points
|
list
|
(x, y, z) points of the outline, in order, not repeating the first; all in one vertical plane. The first two points should be the bottom edge. |
required |
wall_type
|
WallType | str
|
wall type or its name. |
required |
level
|
Level | str
|
level the wall is associated with, defaults as in create_wall. Elevations in the points are absolute. |
None
|
structural
|
bool
|
structural wall. |
False
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
Wall
|
the wall. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
when the points aren't in one vertical plane. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_gable_wall(start, end, wall_type, eave_height, pitch=None, ridge_height=None, level=None, doc=None)
Create a gable end wall: rectangular to the eave, triangular above it.
Use it for the end walls under a gable roof on Revit versions where walls can't attach to roofs (update.attach_wall_tops), instead of filling the gable with DirectShape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
XYZ | tuple
|
plan point at one eave end of the wall. |
required |
end
|
XYZ | tuple
|
plan point at the other eave end. |
required |
wall_type
|
WallType | str
|
wall type or its name. |
required |
eave_height
|
float | str
|
height of the wall's two eave corners above the level. |
required |
pitch
|
float | str
|
roof pitch ( |
None
|
ridge_height
|
float | str
|
height of the peak above the level, at the wall's midpoint. |
None
|
level
|
Level | str
|
base level, defaults as in create_wall. |
None
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
Wall
|
the wall. |
Note
The rake follows the roof's slope from the wall's own ends. A roof
whose eave outline overhangs the wall sits higher over the wall by
overhang * pitch; add that to eave_height to close the gap.
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_floor(points, floor_type, level=None, offset=0.0, structural=False, doc=None)
Create a floor on a closed outline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list
|
outline plan points, in order, not repeating the first. |
required |
floor_type
|
FloorType | str
|
floor type or its name. |
required |
level
|
Level | str
|
level, defaults as in create_wall. |
None
|
offset
|
float | str
|
height above the level. |
0.0
|
structural
|
bool
|
structural floor. |
False
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
Floor
|
the floor. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_ceiling(points, ceiling_type, level=None, offset=8.0, doc=None)
Create a ceiling on a closed outline (Revit 2022 and later).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list
|
outline plan points. |
required |
ceiling_type
|
CeilingType | str
|
ceiling type or its name. |
required |
level
|
Level | str
|
level, defaults as in create_wall. |
None
|
offset
|
float | str
|
height above the level. |
8.0
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
Ceiling
|
the ceiling. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
on Revit 2021, which has no ceiling creation API. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_footprint_roof(points, roof_type, level=None, slopes=None, offset=0.0, doc=None)
Create a footprint roof with slopes on chosen edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list
|
eave outline plan points, overhangs included. |
required |
roof_type
|
RoofType | str
|
roof type or its name. |
required |
level
|
Level | str
|
level, defaults as in create_wall. |
None
|
slopes
|
dict
|
edge index to pitch, where edge |
None
|
offset
|
float | str
|
eave height above the level. |
0.0
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[FootPrintRoof, list[ModelCurve]]
|
the roof and the |
|
model curve of each footprint edge. |
Note
Calls NewFootPrintRoof through reflection with a pre-filled argument array, because IronPython 3.4 passes null for its out parameter and Revit rejects null.
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_gable_roof(x1, y1, x2, y2, roof_type, pitch, ridge='x', level=None, offset=0.0, doc=None)
Create a rectangular gable roof and check its rise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float | str
|
eave outline corner X, overhangs included. |
required |
y1
|
float | str
|
eave outline corner Y. |
required |
x2
|
float | str
|
opposite corner X. |
required |
y2
|
float | str
|
opposite corner Y. |
required |
roof_type
|
RoofType | str
|
roof type or its name. |
required |
pitch
|
float | str
|
|
required |
ridge
|
str
|
|
'x'
|
level
|
Level | str
|
level, defaults as in create_wall. |
None
|
offset
|
float | str
|
eave height above the level. |
0.0
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
FootPrintRoof
|
the roof. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
when the built roof's rise doesn't match the pitch, which means the slopes landed on the wrong edges. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_hip_roof(x1, y1, x2, y2, roof_type, pitch, level=None, offset=0.0, doc=None)
Create a rectangular hip roof, the same pitch on all four edges; see create_gable_roof.
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_shed_roof(x1, y1, x2, y2, roof_type, pitch, low_side='south', level=None, offset=0.0, doc=None)
Create a rectangular shed roof sloping down toward one side, and check its rise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float | str
|
eave outline corner X, overhangs included. |
required |
y1
|
float | str
|
eave outline corner Y. |
required |
x2
|
float | str
|
opposite corner X. |
required |
y2
|
float | str
|
opposite corner Y. |
required |
roof_type
|
RoofType | str
|
roof type or its name. |
required |
pitch
|
float | str
|
|
required |
low_side
|
str
|
south, east, north or west. |
'south'
|
level
|
Level | str
|
level, defaults as in create_wall. |
None
|
offset
|
float | str
|
height of the low eave above the level. |
0.0
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
FootPrintRoof
|
the roof. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
place_hosted_instance(symbol, host, point, level=None, sill_height=None, doc=None)
Place a door, window or other hosted family on a host such as a wall.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
FamilySymbol | str
|
family type or its name; activated when needed. |
required |
host
|
Element
|
host element, usually a wall. |
required |
point
|
XYZ | tuple
|
plan point on the host's location line. |
required |
level
|
Level | str
|
level, defaults to the host's level. |
None
|
sill_height
|
float | str
|
sill height for windows. |
None
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
FamilyInstance
|
the instance. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
place_family_instance(symbol, point, level=None, structural_type=None, rotation=0.0, doc=None)
Place a level-based family instance such as furniture, fixtures or columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
FamilySymbol | str
|
family type or its name; activated when needed. |
required |
point
|
XYZ | tuple
|
plan insertion point. |
required |
level
|
Level | str
|
level, defaults as in create_wall. |
None
|
structural_type
|
StructuralType
|
defaults to NonStructural. |
None
|
rotation
|
float
|
rotation in degrees around the insertion point. |
0.0
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
FamilyInstance
|
the instance. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_column(symbol, point, level=None, top_level=None, structural=True, doc=None)
Place a column from level up to top_level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
FamilySymbol | str
|
column type or its name. |
required |
point
|
XYZ | tuple
|
plan insertion point. |
required |
level
|
Level | str
|
base level, defaults as in create_wall. |
None
|
top_level
|
Level | str
|
top level; must be above the base. Adjust heights afterwards with FAMILY_BASE_LEVEL_OFFSET_PARAM and FAMILY_TOP_LEVEL_OFFSET_PARAM. |
None
|
structural
|
bool
|
structural column (else architectural). |
True
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
FamilyInstance
|
the column. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
when the top level isn't above the base level, which would make a zero-height column. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_room(point, level=None, name=None, number=None, require_enclosed=True, doc=None)
Place a room at a plan point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
XYZ | UV | tuple
|
plan point inside the room. |
required |
level
|
Level | str
|
level, defaults as in create_wall. |
None
|
name
|
str
|
room name. |
None
|
number
|
str
|
room number. |
None
|
require_enclosed
|
bool
|
raise when the room isn't enclosed. Placing rooms right after the walls is a cheap check for gaps in a layout. |
True
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
Room
|
the room. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
when |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_room_separation_lines(points, level=None, view=None, closed=False, doc=None)
Create room separation lines, to divide an open plan without walls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list
|
plan points of the polyline. |
required |
level
|
Level | str
|
level, defaults as in create_wall. |
None
|
view
|
ViewPlan
|
plan view to create them in, defaults to a floor plan of the level. |
None
|
closed
|
bool
|
also join the last point to the first. |
False
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
list[ModelCurve]
|
the separation lines. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_model_lines(points, level=None, closed=False, doc=None)
Create model lines along a polyline at a level's elevation.
Returns:
| Type | Description |
|---|---|
list[ModelCurve]
|
the model lines. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
unique_view_name(view_name, doc=None)
Return view_name, or "view_name (2)" and so on if it is taken.
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_plan_view(level=None, view_name=None, plan_type='floor', template=None, doc=None)
Create a floor, ceiling or structural plan of a level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
Level | str
|
level, defaults as in create_wall. |
None
|
view_name
|
str
|
name, made unique; defaults to
|
None
|
plan_type
|
str
|
floor, ceiling or structural. |
'floor'
|
template
|
str | View
|
view template to apply. |
None
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
ViewPlan
|
the view. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_model_3d_view(view_name=None, direction='southeast', elements=None, model_only=True, template=None, doc=None)
Create a new isometric 3D view framed on elements or the whole model.
Unlike create_3d_view, which reuses a view with the same name, this always creates a view (with a unique name), hides annotation and fits a section box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_name
|
str
|
name, made unique; defaults to "3D". |
None
|
direction
|
str
|
where the viewer stands: southeast, southwest, northeast, northwest, south, north, east, west, top. |
'southeast'
|
elements
|
list
|
elements to frame with the section box; defaults to query.get_model_elements(). |
None
|
model_only
|
bool
|
hide levels, grids and annotation, whose extents otherwise dwarf the model in the view. |
True
|
template
|
str | View
|
view template to apply. |
None
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
View3D
|
the view. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_section_view(start, end, view_name=None, bottom=None, top=None, depth=10.0, template=None, doc=None)
Create a section along a plan line, looking to the left of start -> end.
A line drawn west to east looks north.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
XYZ | tuple
|
section line start. |
required |
end
|
XYZ | tuple
|
section line end. |
required |
view_name
|
str
|
name, made unique; defaults to "Section". |
None
|
bottom
|
float | str
|
bottom elevation, defaults to 1 ft below the lowest level. |
None
|
top
|
float | str
|
top elevation, defaults to 10 ft above the highest level. |
None
|
depth
|
float | str
|
far clip distance. |
10.0
|
template
|
str | View
|
view template to apply. |
None
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
ViewSection
|
the view. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_elevation_view(side='south', view_name=None, plan=None, offset=10.0, template=None, doc=None)
Create an exterior elevation of the whole model seen from one side.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
side
|
str
|
south, north, east or west. |
'south'
|
view_name
|
str
|
name, made unique; defaults to
|
None
|
plan
|
ViewPlan | str
|
plan to host the marker, defaults to a floor plan of the lowest level. |
None
|
offset
|
float | str
|
distance of the marker outside the model's extents. |
10.0
|
template
|
str | View
|
view template to apply. |
None
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
ViewSection
|
the elevation view. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 | |
create_dimension(view, references, axis='x', position=0.0, doc=None)
Create a linear dimension through references in a plan view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view
|
View
|
view to draw the dimension in. |
required |
references
|
list[Reference]
|
at least two references, such as face references from query.get_face_references. |
required |
axis
|
str
|
|
'x'
|
position
|
float | str
|
where the dimension line sits. |
0.0
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
Dimension
|
the dimension. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
with fewer than two references, an unknown axis, or a model with no elements to span. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
tag_elements(view, elements, offset=0.0, tag_type=None, leader=False, doc=None)
Tag elements by category in a view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view
|
View
|
view to tag in. |
required |
elements
|
list[Element]
|
elements to tag. |
required |
offset
|
float | str
|
move each tag this far along the element's facing direction (doors and windows); negative moves it the other way, into the room. |
0.0
|
tag_type
|
FamilySymbol | str
|
tag type or its name; defaults to the category's default tag. |
None
|
leader
|
bool
|
draw a leader. |
False
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
list[IndependentTag]
|
the tags. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_room_tags(view, rooms=None, tag_type=None, doc=None)
Tag rooms at their location points in a plan view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view
|
ViewPlan
|
plan view. |
required |
rooms
|
list[Room]
|
rooms to tag, defaults to the placed rooms visible in the view. |
None
|
tag_type
|
FamilySymbol | str
|
room tag type or its name,
such as |
None
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
list[RoomTag]
|
the tags. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_schedule(category, fields, view_name=None, sort_by=None, totals=None, itemized=True, grand_total=True, doc=None)
Create a schedule of a category with the named fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str | BuiltInCategory | Category
|
category, such as
|
required |
fields
|
list[str]
|
field names in column order, as shown in Revit's
schedule properties ( |
required |
view_name
|
str
|
schedule name, made unique. |
None
|
sort_by
|
list[str]
|
field names to sort by, in order. A
field missing from |
None
|
totals
|
list[str]
|
numeric fields to total. A field
missing from |
None
|
itemized
|
bool
|
list every element instead of grouping. |
True
|
grand_total
|
bool
|
show a grand total row with a count. |
True
|
doc
|
Document
|
document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
ViewSchedule
|
the schedule. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
when a field name isn't schedulable for the category; the message lists the available fields. |
Source code in pyrevitlib/pyrevit/revit/db/create.py
1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 | |
place_on_sheet(sheet, view, anchor='top_left', margin=0.1, doc=None, right_margin=0.0)
Place a view or schedule on a sheet, aligned to a corner of the title block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sheet
|
ViewSheet
|
sheet. |
required |
view
|
View | ViewSchedule
|
view or schedule to place. A view can be on one sheet only; schedules can repeat. |
required |
anchor
|
str
|
top_left, top_right, bottom_left, bottom_right or center of the title block (the sheet outline when it has none). |
'top_left'
|
margin
|
float | str
|
gap between the placed box and the title block edge, in sheet feet (0.1 ft is 1.2 in). |
0.1
|
doc
|
Document
|
document, defaults to the active one. |
None
|
right_margin
|
float | str
|
width of the title block's right-hand information strip, in sheet feet, which right anchors and center keep clear. The title block's bounding box includes the strip and its width is not exposed by the API, so measure it on the sheet. |
0.0
|
Returns:
| Type | Description |
|---|---|
Viewport | ScheduleSheetInstance
|
the placed viewport or |
|
schedule instance. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
when |
Source code in pyrevitlib/pyrevit/revit/db/create.py
1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 | |
create_reference_plane(name, start, end, view, cut_vector=None, reference=None, doc=None)
Create a named reference plane in a family document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
plane name, unique within the family. |
required |
start
|
XYZ | tuple
|
bubble end of the plane. |
required |
end
|
XYZ | tuple
|
free end of the plane. |
required |
view
|
View
|
plan or elevation view the plane is drawn in. |
required |
cut_vector
|
XYZ
|
direction normal to the drawn line in the view, defaults to the view direction. |
None
|
reference
|
str
|
"Is Reference" setting, a key of
|
None
|
doc
|
Document
|
family document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
ReferencePlane
|
the plane. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
outside a family document or transaction, or for an
unknown |
Important
Revit keeps "left", "center_left_right", "right",
"front", "center_front_back", "back", "bottom",
"center_elevation" and "top" on one plane per family. Giving one
to a new plane resets the plane that had it to "not_a_reference"
without an error. "strong", "weak" and "not_a_reference" can
be on many planes.
Note
The query.REFERENCE_PLANE_REFERENCES values were checked in Revit
2024 and 2026.
Source code in pyrevitlib/pyrevit/revit/db/create.py
create_labelled_dimension(view, planes, start, end, label=None, equal_segments=False, doc=None)
Dimension reference planes in a family, optionally driving a parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view
|
View
|
view the dimension is drawn in. |
required |
planes
|
list[ReferencePlane]
|
at least two planes, in dimension order. |
required |
start
|
XYZ | tuple
|
start of the dimension line. |
required |
end
|
XYZ | tuple
|
end of the dimension line. |
required |
label
|
FamilyParameter
|
parameter that drives the distance between the two planes. |
None
|
equal_segments
|
bool
|
keep the segments equal, which holds a plane centred between two others. |
False
|
doc
|
Document
|
family document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
Dimension
|
the dimension. |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
outside a family document or transaction, with fewer
than two planes, when |
Important
A label on a dimension of three or more planes labels every segment,
so the family ends up twice as wide as the parameter. Label a
two-plane dimension and add a second, unlabelled dimension through the
centre plane with equal_segments=True.
Source code in pyrevitlib/pyrevit/revit/db/create.py
align_faces_to_planes(element, view, planes, tolerance=1e-06, doc=None)
Lock the planar faces of a family element to coincident reference planes.
Every planar face that lies in one of planes gets an alignment
constraint, so the element follows the planes when their dimensions change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
Element
|
form such as an extrusion. |
required |
view
|
View
|
view the alignments are made in. A plan view reaches vertical faces, an elevation view reaches horizontal ones. |
required |
planes
|
list[ReferencePlane]
|
candidate planes. |
required |
tolerance
|
float
|
distance in feet within which a face counts as lying in a plane. |
1e-06
|
doc
|
Document
|
family document, defaults to the active one. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
names of the planes that were aligned to a face. |
Note
A face that no plane contains is skipped. A point where two sloped
faces meet has no face to align; give it a short flat edge longer than
Application.ShortCurveTolerance.
Source code in pyrevitlib/pyrevit/revit/db/create.py
load_family_document(family_doc, doc=None, name=None)
Load an open family document into a project or another family.
A family document that was never saved loads under its document title,
such as Family24; pass name to rename the loaded family.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
family_doc
|
Document
|
the family document to load. |
required |
doc
|
Document
|
target document, defaults to the active one. |
None
|
name
|
str
|
name for the loaded family. |
None
|
Returns:
| Type | Description |
|---|---|
Family
|
the loaded family, in |
Raises:
| Type | Description |
|---|---|
PyRevitException
|
when |
Important
Call it without an open transaction on doc: LoadFamily manages
its own. The rename runs in a transaction of its own, which is rolled
back if Revit rejects the name.
Reloading replaces the Family object, so a Family kept from an
earlier load is no longer valid.
Note
Revit matches an incoming family by its document title, not by the name it was renamed to. Loading the same unsaved document again does not update the renamed family; it adds a new family under the title. The name check refuses that case instead of leaving the duplicate.
Source code in pyrevitlib/pyrevit/revit/db/create.py
2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 | |