/// <summary> /// Reset detailed structural connection type to generic. /// </summary> /// <param name="activeDoc">The active document.</param> /// <param name="message">Set message on failure.</param> /// <returns>Returns the status of the operation.</returns> public static Result ResetDetailedStructuralConnection(UIDocument activeDoc, ref string message) { Result ret = Result.Succeeded; // Prompt to select a structural connection. StructuralConnectionHandler conn = StructuralConnectionSelectionUtils.SelectConnection(activeDoc); if (conn != null) { using (Transaction tran = new Transaction(activeDoc.Document, "Change detailed connection type")) { tran.Start(); ElementId genericTypeId = StructuralConnectionHandlerType.GetDefaultConnectionHandlerType(activeDoc.Document); if (genericTypeId == ElementId.InvalidElementId) { genericTypeId = StructuralConnectionHandlerType.CreateDefaultStructuralConnectionHandlerType(activeDoc.Document); } conn.ChangeTypeId(genericTypeId); TransactionStatus ts = tran.Commit(); if (ts != TransactionStatus.Committed) { message = "Failed to commit the current transaction !"; ret = Result.Failed; } } } else { message = "There is no connection selected !"; ret = Result.Failed; } return(ret);; }
/// <summary> /// Change detailed structural connection. /// </summary> /// <param name="activeDoc">The active document.</param> /// <param name="message">Set message on failure.</param> /// <returns>Returns the status of the operation.</returns> public static Result ChangeDetailedStructuralConnection(UIDocument activeDoc, ref string message) { Result ret = Result.Succeeded; // Prompt to select a structural connection. StructuralConnectionHandler conn = StructuralConnectionSelectionUtils.SelectConnection(activeDoc); if (conn != null) { using (Transaction tran = new Transaction(activeDoc.Document, "Change detailed connection type")) { tran.Start(); // The type is from the SteelConnectionsData.xml file. StructuralConnectionHandlerType connectionType = StructuralConnectionHandlerType.Create(activeDoc.Document, "shearplatenew", new Guid("B490A703-5B6D-4B7A-8471-752133527925"), "shearplatenew"); if (connectionType != null) { // The replacement type should be valid on the connected elements. conn.ChangeTypeId(connectionType.Id); } TransactionStatus ts = tran.Commit(); if (ts != TransactionStatus.Committed) { message = "Failed to commit the current transaction !"; ret = Result.Failed; } } } else { message = "There is no connection selected!"; ret = Result.Failed; } return(ret); }