CreateRectangle Method


Creates rectangle on face or sketchplane for two given diagonal points.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since:  2012

Syntax

C#
public static void CreateRectangle(
	Document document,
	ReferencePoint startPoint,
	ReferencePoint endPoint,
	CurveProjectionType projectionType,
	bool boundaryReferenceLines,
	bool boundaryCurvesFollowSurface,
	out IList<ElementId> createdCurvesIds,
	out IList<ElementId> createdCornersIds
)
Visual Basic
Public Shared Sub CreateRectangle ( _
	document As Document, _
	startPoint As ReferencePoint, _
	endPoint As ReferencePoint, _
	projectionType As CurveProjectionType, _
	boundaryReferenceLines As Boolean, _
	boundaryCurvesFollowSurface As Boolean, _
	<OutAttribute> ByRef createdCurvesIds As IList(Of ElementId), _
	<OutAttribute> ByRef createdCornersIds As IList(Of ElementId) _
)
Visual C++
public:
static void CreateRectangle(
	Document^ document, 
	ReferencePoint^ startPoint, 
	ReferencePoint^ endPoint, 
	CurveProjectionType projectionType, 
	bool boundaryReferenceLines, 
	bool boundaryCurvesFollowSurface, 
	[OutAttribute] IList<ElementId^>^% createdCurvesIds, 
	[OutAttribute] IList<ElementId^>^% createdCornersIds
)

Parameters

document
Type: Autodesk.Revit.DBDocument
The Document.
startPoint
Type: Autodesk.Revit.DBReferencePoint
First diagonal point of rectangle.
endPoint
Type: Autodesk.Revit.DBReferencePoint
Second diagonal point of rectangle.
projectionType
Type: Autodesk.Revit.DBCurveProjectionType
Projection type of rectangle's boundary curves. If the rectangle input points are Face hosted, and CurveProjectionType::ParallelToLevel is requested, and the Face normal at the location of the start point is at a less than 45 degree angle with the level planes, then the projectionType will be set to FromTopDown, even if ParallelToLevel was requested.
boundaryReferenceLines
Type: SystemBoolean
True if rectangle's boundary curves should be reference lines, false otherwise.
boundaryCurvesFollowSurface
Type: SystemBoolean
True if rectangle's boundary curves should follow surface, false otherwise.
createdCurvesIds
Type: System.Collections.GenericIListElementId%
Created rectangle's boundary curves ids.
createdCornersIds
Type: System.Collections.GenericIListElementId%
Ids of two newly created corner points.

Remarks

This array contains the ElementIds of the two additional corner points that are created to complete the rectangle.

Exceptions

ExceptionCondition
Autodesk.Revit.ExceptionsArgumentNullException A non-optional argument was null
Autodesk.Revit.ExceptionsArgumentOutOfRangeException Unexpected projection type. -or- A value passed for an enumeration argument is not a member of that enumeration
Autodesk.Revit.ExceptionsInvalidOperationException Unable to create rectangle.

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →