почему «Изменить параметры» возвращает ноль для вновь созданного Структурного соединения между балкой и колонной - PullRequest
0 голосов
/ 02 февраля 2020

Использование Revit API 2019 и Advance Steel API 2019

У меня есть простая задача соединить beam и column с Structural Connection (Clip angle) и обновить Modify Parameters.

I Я могу создать соединение между beam и column с Structural Connection (Clip angle), но когда я go изменить параметры вновь созданного Structural Connection, он дает null

ниже кода для создания соединение и измените его

        StructuralConnectionHandler structuralConnectionHandler = null;
        using (Transaction transaction = new Transaction(uidoc.Document, "Create detailed structural connection"))
        {
                    transaction.Start();
                    List<ElementId> elemIds = new List<ElementId>();
                    // retrive element from document

                    foreach (int id in selectedIDs)                   
                        elemIds.Add(doc.GetElement(new ElementId(id)).Id);

                    // The type is from the SteelConnectionsData.xml file.
                    StructuralConnectionHandlerType connectionType = StructuralConnectionHandlerType.Create(uidoc.Document, "usclipangle", new Guid("A42C5CE5-91C5-47E4-B445-D053E5BD66DB"), "usclipangle");

                    if (elemIds.Count() > 0 && connectionType != null)
                    {
                        //using (SubTransaction subTransaction = new SubTransaction(uidoc.Document))
                        //{
                        //    subTransaction.Start();
                            structuralConnectionHandler = StructuralConnectionHandler.Create(uidoc.Document, elemIds, connectionType.Id);
                        //    subTransaction.Commit();
                        //}
                        uidoc.Document.Regenerate();
                    }
                    else
                    {
                        message = "There is no element selected!";
                        ret = Result.Failed;
                    }
             TransactionStatus ts = transaction.Commit();
    }   

       // uidoc.Document.Save();  // tried to save document automatically but gives wired exception eg. Autodesk.Internal Exception

        bool modifyParameters = true// would be setting its value while debug.
        if (modifyParameters)
        {
            // Start detailed steel modeling transaction
            using (FabricationTransaction trans = new FabricationTransaction(doc, true, "Update connection parameters"))
            {
                AdvSteel.FilerObject filerObject = Functions.GetFilerObject(uidoc.Document, new Reference(structuralConnectionHandler));

        //filerObject object is null always
            // this piece of code works independently
                if (null == filerObject || !(filerObject is UserAutoConstructionObject))
                    return  Result.Failed; 

                UserAutoConstructionObject asConnection = (UserAutoConstructionObject)filerObject;

                //read connection parameters
                IFiler connectionFiler = asConnection.Save();

                if (connectionFiler != null)
                {
                    //I choose to modify thickess of the base plate
                    connectionFiler.WriteItem(Convert.ToDouble(50.0), "BaseThickness"); //units must be milimmeters; 
                    asConnection.Load(connectionFiler); //update connection parameters
                    asConnection.Update();
                    //
                    //if the connection parameters are modified, than we have to set this flag to true,
                    //meaning that this connection has different parameters than it's connection type.


                    // not avaliabe in revit 2019
                    //rvtConnection.OverrideTypeParams = true;


                    // not avaliabe in revit 2019
                    /// trans.Commit();
                }
            }

        }

До сих пор пытался:

Пытался зафиксировать в суб-транзакции.

Пытался чтобы сохранить документ после принятия.

прошел по ссылке ниже

Revit Dynamo: revit-api-access-to-Structure-connection-параметры

Autodesk Revit API: доступ к подробным параметрам в соединении из конструкционной стали

Буду признателен за любую помощь или подсказку

...