Modifies StructuralConnectionHandlerType of input StructuralConnectionHandler.
Adds input elements or subelements.
Removes input subelements.The subelements will be erased.
Updates any geometrical, parametrical or location changes of existing subelements, regardless of whether elements or subelements are added or removed.
Namespace: Autodesk.Revit.DB.StructureAssembly: RevitAPI (in RevitAPI.dll) Version: 26.4.0.0 (26.4.0.0)
Syntax
C#
public static void UpdateCustomConnectionType(
StructuralConnectionHandler structuralConnectionHandler,
IList<Reference> addReferences,
IList<Reference> removeReferences
)
Parameters
- structuralConnectionHandler StructuralConnectionHandler
-
The existing StructuralConnectionHandler having custom StructuralConnectionHandlerType which is about to be modified.
- addReferences IList<Reference>
-
References to elements or subelements which are to be used to modify custom StructuralConnectionHandlerType by adding them.
- removeReferences IList<Reference>
-
References to subelements of input StructuralConnectionHandler which are to be used to modify custom StructuralConnectionHandlerType by removing them.
Exceptions
| Exception | Condition |
|---|
| ArgumentException |
Input StructuralConnectionHandler must have custom type.
-or-
All the input Elements should be of the following structural categories: framings, columns, profiles, plates, bolts, anchors, shear studs, welds or structural connections.
-or-
Total number of different input elements of input StructuralConnectionHandlers must be lower or equal to 3.
-or-
All the input references must belong to input StructuralConnectionHandler.
After modification of StructuralConnectionHandlerType there must remain at least one subelement of structural connections category in StructuralConnectionHandler.
|
| ArgumentNullException |
A non-optional argument was null
|
Remarks
Elements or subelements added to a custom connection are deleted and transformed in subelements of the connection. They could be:
- FamilyInstance (structural beams and columns).
- StructuralConnectionHandler elements associated to the connection.
- Specific steel connection elements (bolts, anchors, plates, etc). These connection elements will be of type element but with categories related to structural connections, for example:
- OST_StructConnectionWelds
- OST_StructConnectionHoles
- OST_StructConnectionModifiers
- OST_StructConnectionShearStuds
- OST_StructConnectionBolts
- OST_StructConnectionAnchors
- OST_StructConnectionPlates
You cannot add: elements connected by any connection handler, generic connections, holes and modifiers that are not on the connected elements.
Example
C#
Autodesk.Revit.DB.Transaction transaction = new Autodesk.Revit.DB.Transaction(doc, "Modify custom connection subelements");
TransactionStatus ts = TransactionStatus.Uninitialized;
try
{
transaction.Start();
using (FabricationTransaction trans = new FabricationTransaction(doc, false, "Modify custom connection", true))
{
IEnumerable<Subelement> subelements = conn.GetSubelements();
UserDefinedConnectionInstance userConn = Utilities.Functions.GetFilerObject(doc, target) as UserDefinedConnectionInstance;
foreach (Subelement subelement in subelements)
{
FilerObject filerObjForSubelement = Utilities.Functions.GetFilerObject(doc, subelement.GetReference());
if (null == filerObjForSubelement)
continue;
if (filerObjForSubelement is not ConstructionElement)
continue;
ConstructionElement ace = filerObjForSubelement as ConstructionElement;
if (null == ace || !ace.HasDrivingPassiveConstructionObject)
continue;
PassiveConstructionObject pco = ace.DrivingPassiveConstructionObject;
if (null == pco || pco is not UserDefinedConnectionInstance)
continue;
bool bOlddeleteRuleOnDeleteDriven = userConn.DeleteRuleOnDeleteDriven;
userConn.DeleteRuleOnDeleteDriven = false;
if (filerObjForSubelement is Plate)
{
Plate plate = filerObjForSubelement as Plate;
Polyline3d newContour = new Polyline3d();
Polyline3d oldContour;
plate.GetBaseContourPolygon(1, out oldContour);
oldContour.Expand(100);
newContour = oldContour;
if (newContour.VertexCount <= 0)
{
return Result.Failed;
}
IEnumerable<ObjectId> deletedFeatures;
IEnumerable<ObjectId> addedFeatures;
plate.SetOuterContour(newContour, out deletedFeatures, out addedFeatures);
plate.Thickness = 100;
plate.TransformBy(Matrix3d.GetTranslation(new Vector3d(0, 0, 100)));
}
else if (filerObjForSubelement is BoltPattern)
{
BoltPattern boltPattern = filerObjForSubelement as BoltPattern;
if (boltPattern.IsKindOf(FilerObject.eObjectType.kCountableScrewBoltPattern))
{
CountableScrewBoltPattern countableScrewBoltPattern = boltPattern as CountableScrewBoltPattern;
if (null != countableScrewBoltPattern)
{
countableScrewBoltPattern.GetConnectedElements(out IEnumerable<ObjectId> connectedElements, 0);
FilerObject[] connectedFilerObjects = new FilerObject[] { };
foreach (ObjectId connectedElement in connectedElements)
{
FilerObject connectedElementObj = FilerObject.GetFilerObjectByHandle(connectedElement.Handle);
if (null != connectedElementObj)
{
connectedFilerObjects.Append(connectedElementObj);
}
}
if (connectedElements.Count() > 0)
{
CircleScrewBoltPattern circScrewBoltPattern = new CircleScrewBoltPattern(countableScrewBoltPattern.CenterPoint, countableScrewBoltPattern.XDirection, countableScrewBoltPattern.YDirection);
if (null != circScrewBoltPattern)
{
circScrewBoltPattern.NumberOfScrews = 3;
circScrewBoltPattern.Radius = countableScrewBoltPattern.Length / 2;
circScrewBoltPattern.Standard = countableScrewBoltPattern.Standard;
circScrewBoltPattern.Grade = countableScrewBoltPattern.Grade;
circScrewBoltPattern.BoltAssembly = countableScrewBoltPattern.BoltAssembly;
circScrewBoltPattern.ScrewDiameter = countableScrewBoltPattern.ScrewDiameter;
circScrewBoltPattern.BindingLength = countableScrewBoltPattern.BindingLength;
circScrewBoltPattern.BindingLengthAddition = countableScrewBoltPattern.BindingLengthAddition;
circScrewBoltPattern.IsInverted = countableScrewBoltPattern.IsInverted;
circScrewBoltPattern.AssemblyLocation = countableScrewBoltPattern.AssemblyLocation;
circScrewBoltPattern.Coating = countableScrewBoltPattern.Coating;
circScrewBoltPattern.Material = countableScrewBoltPattern.Material;
circScrewBoltPattern.IgnoreMaxGap = countableScrewBoltPattern.IgnoreMaxGap;
circScrewBoltPattern.HoleTolerance = countableScrewBoltPattern.HoleTolerance;
circScrewBoltPattern.Connect(connectedFilerObjects, countableScrewBoltPattern.AssemblyLocation);
userConn.ExcludeObjectsFromConnection([countableScrewBoltPattern.GetObjectId()]);
string strOldHandle = countableScrewBoltPattern.Handle;
string strNewHandle = circScrewBoltPattern.Handle;
Guid guidToTransfer = countableScrewBoltPattern.GetUniqueId();
Guid uidDummy = Guid.NewGuid();
countableScrewBoltPattern.SetUniqueId(uidDummy);
circScrewBoltPattern.SetUniqueId(guidToTransfer);
circScrewBoltPattern.WriteToDb();
userConn.IncludeObjectsInConnection([circScrewBoltPattern.GetObjectId()]);
countableScrewBoltPattern.DelFromDb();
}
}
}
}
}
else
continue;
userConn.DeleteRuleOnDeleteDriven = bOlddeleteRuleOnDeleteDriven;
}
trans.Commit();
}
StructuralConnectionHandlerType.UpdateCustomConnectionType(conn, [], []);
ts = transaction.Commit();
if (ts != TransactionStatus.Committed)
{
message = "Failed to commit the current transaction !";
transaction.RollBack();
return Result.Failed;
}
}
See Also
Reference