CreateHanger Method (Document, FabricationServiceButton, Int32, ElementId, Connector, Double, Boolean)


Creates a hanger on the fabrication part.

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

Syntax

C#
public static FabricationPart CreateHanger(
	Document document,
	FabricationServiceButton button,
	int condition,
	ElementId hostId,
	Connector hostConnector,
	double distance,
	bool attachToStructure
)
Visual Basic
Public Shared Function CreateHanger ( _
	document As Document, _
	button As FabricationServiceButton, _
	condition As Integer, _
	hostId As ElementId, _
	hostConnector As Connector, _
	distance As Double, _
	attachToStructure As Boolean _
) As FabricationPart
Visual C++
public:
static FabricationPart^ CreateHanger(
	Document^ document, 
	FabricationServiceButton^ button, 
	int condition, 
	ElementId^ hostId, 
	Connector^ hostConnector, 
	double distance, 
	bool attachToStructure
)

Parameters

document
Type: Autodesk.Revit.DBDocument
The document.
button
Type: Autodesk.Revit.DBFabricationServiceButton
The fabrication service button to use.
condition
Type: SystemInt32
The condition index. If the button has multiple conditions.
hostId
Type: Autodesk.Revit.DBElementId
The host part id. The host should be one horizontal straight part.
hostConnector
Type: Autodesk.Revit.DBConnector
The connector of the host.
distance
Type: SystemDouble
The distance from the input connector of the host part. Units are in feet (ft).
attachToStructure
Type: SystemBoolean
Attach to the nearest structural element. The structural element might be one of Floor/Roof/Stair/Structural Framing.

Return Value

The newly-created fabrication hanger.

Exceptions

ExceptionCondition
Autodesk.Revit.ExceptionsArgumentException Hangers may only be placed on straight horizontal fabrication segments and some kind of fittings. -or- Invalid fabrication service button.
Autodesk.Revit.ExceptionsArgumentNullException A non-optional argument was null
Autodesk.Revit.ExceptionsArgumentOutOfRangeException The index condition is not larger or equal to 0 and less than ConditionCount.
Autodesk.Revit.ExceptionsInvalidOperationException the distance is out of range. -or- cannot find suitable fabrication part for the host. -or- cannot place hanger on the host.

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 →