Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }