/// <summary> /// Create generic 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 CreateGenericStructuralConnection(UIDocument activeDoc, ref string message) { Result ret = Result.Succeeded; List <ElementId> ids = StructuralConnectionSelectionUtils.SelectConnectionElements(activeDoc); if (ids.Count() > 0) { // Start a new transaction. using (Transaction tran = new Transaction(activeDoc.Document, "Create generic structural connection")) { tran.Start(); StructuralConnectionHandler conn = StructuralConnectionHandler.Create(activeDoc.Document, ids); TransactionStatus ts = tran.Commit(); if (ts != TransactionStatus.Committed) { message = "Failed to commit the current transaction !"; ret = Result.Failed; } } } else { message = "There is no element selected !"; ret = Result.Failed; } return(ret); }
/// <summary> /// Create 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 CreateDetailedStructuralConnection(UIDocument activeDoc, ref string message) { Result ret = Result.Succeeded; // Selected the elements to be connected. List <ElementId> ids = StructuralConnectionSelectionUtils.SelectConnectionElements(activeDoc); if (ids.Count() > 0) { // Start a new transaction. using (Transaction transaction = new Transaction(activeDoc.Document, "Create detailed structural connection")) { transaction.Start(); // The type is from the SteelConnectionsData.xml file. StructuralConnectionHandlerType connectionType = StructuralConnectionHandlerType.Create(activeDoc.Document, "usclipangle", new Guid("A42C5CE5-91C5-47E4-B445-D053E5BD66DB"), "usclipangle"); if (connectionType != null) { StructuralConnectionHandler.Create(activeDoc.Document, ids, connectionType.Id); } TransactionStatus ts = transaction.Commit(); if (ts != TransactionStatus.Committed) { message = "Failed to commit the current transaction !"; ret = Result.Failed; } } } else { message = "There is no element selected!"; ret = Result.Failed; } return(ret); }
/// <summary> /// Update generic 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 UpdateGenericStructuralConnection(UIDocument activeDoc, ref string message) { Result ret = Result.Succeeded; // Prompt to select a structural connection. StructuralConnectionHandler conn = StructuralConnectionSelectionUtils.SelectConnection(activeDoc); if (conn != null) { // Select elements to add to connection. List <ElementId> ids = StructuralConnectionSelectionUtils.SelectConnectionElements(activeDoc); if (ids.Count() > 0) { // Start a new transaction. using (Transaction transaction = new Transaction(activeDoc.Document, "Update generic structural connection")) { transaction.Start(); conn.AddElementIds(ids); TransactionStatus ts = transaction.Commit(); if (ts != TransactionStatus.Committed) { message = "Failed to commit the current transaction !"; ret = Result.Failed; } } } else { message = "There are no connection input elements selected !"; } } return(ret); }