Adds a new association between an analytical element and a physical element.
Namespace: Autodesk.Revit.DB.StructureAssembly: RevitAPI (in RevitAPI.dll) Version: 26.4.0.0 (26.4.0.0)
Syntax
C#
public void AddAssociation(
ElementId analyticalElementId,
ElementId physicalElementId
)
Parameters
- analyticalElementId ElementId
-
Id of the analytical element.
- physicalElementId ElementId
-
Id of the physical element.
Exceptions
| Exception | Condition |
|---|
| ArgumentException |
Analytical id is not valid or has already defined another association.
-or-
Physical id is not valid or has already defined another association.
|
| ArgumentNullException |
A non-optional argument was null
|
Remarks
The arguments must be ids of an analytical and of a physical element that don't have other associations, otherwise an exception is thrown.
Physical element can have one of these categories:
- Columns
- Curtain Wall Panels
- Floors
- Generic Models
- Mass
- Parts
- Railings
- Ramps
- Roofs
- Stairs
- Structural Columns
- Structural Foundation
- Structural Framing
- Structural Trusses
- Structural Beam System
- Walls
Analytical element can have one of these categories:
- Analytical Member
- Analytical Panel
Example
C#
using (Transaction trans = new Transaction(doc, "AddAssociationBetweenPhysicalAndAnalyticalElements"))
{
trans.Start();
ElementId idAnalyticalElem = GetSelectedObject(activeDoc, "Please select analytical element");
ElementId idPhysicalElem = GetSelectedObject(activeDoc, "Please select physical element");
AnalyticalToPhysicalAssociationManager analyticalToPhysicalManager = AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(doc);
if (analyticalToPhysicalManager == null)
return Result.Failed;
analyticalToPhysicalManager.AddAssociation(idAnalyticalElem, idPhysicalElem);
trans.Commit();
VB
Using trans As Transaction = New Transaction(doc, "AddAssociationBetweenPhysicalAndAnalyticalElements")
trans.Start()
Dim idAnalyticalElem = GetSelectedObject(activeDoc, "Please select analytical element")
Dim idPhysicalElem = GetSelectedObject(activeDoc, "Please select physical element")
Dim analyticalToPhysicalManager = AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(doc)
If analyticalToPhysicalManager Is Nothing Then Return Result.Failed
analyticalToPhysicalManager.AddAssociation(idAnalyticalElem, idPhysicalElem)
trans.Commit()VB
Using trans As Transaction = New Transaction(doc, "AddAssociationBetweenPhysicalAndAnalyticalElements")
trans.Start()
Dim idAnalyticalElem = GetSelectedObject(activeDoc, "Please select analytical element")
Dim idPhysicalElem = GetSelectedObject(activeDoc, "Please select physical element")
Dim analyticalToPhysicalManager = AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(doc)
If analyticalToPhysicalManager Is Nothing Then Return Result.Failed
analyticalToPhysicalManager.AddAssociation(idAnalyticalElem, idPhysicalElem)
trans.Commit()
See Also
Reference