Fixture units dont update when Addin is running

Fixture units dont update when Addin is running

nelsonhp3
Contributor Contributor
773 Views
7 Replies
Message 1 of 8

Fixture units dont update when Addin is running

nelsonhp3
Contributor
Contributor

Hello,

I'm creating an addin that needs the values ​​of Fixture Units for piping systems. However, when the system has an open end, the value of the Fixture Units is equal to zero in some parts.

nelsonhp3_0-1587493589476.png

nelsonhp3_1-1587493611835.png

I tried to create a subtransaction that adds cap to open ends and then deletes them (see image below). However, I realized that while adding the caps, the fixture units are not updated. How can I solve this problem?
Is there any way to update the fixture unit calculation by API?

nelsonhp3_2-1587493975546.png

 

 

 

 

0 Likes
Accepted solutions (1)
774 Views
7 Replies
Replies (7)
Message 2 of 8

RPTHOMAS108
Mentor
Mentor

Have you tried calling Document.Regenerate after adding the caps and then inspecting the parameter value? Regenerate is automatically called after a transaction completes.

 

0 Likes
Message 3 of 8

TripleM-Dev.net
Advisor
Advisor
Accepted solution

Hi,

 

Use TransactionGroup, and inside it call the various transaction.

Commit the Transaction and don't assimilate the transactionGroup at the end.

See if this is enough to get the correct values.

 

If values need to be written back to the Revit Database, do it in a seperate transaction AFTER the group is ended.

See a earlier post: refresh-after-every-pickobject  

 

- Michel

Message 4 of 8

jeremytammik
Autodesk
Autodesk
Message 5 of 8

nelsonhp3
Contributor
Contributor

Thank you, it worked. This is how I made:

TransactionGroup endCapsRecall = new TransactionGroup(doc);
            Transaction endCaps = new Transaction(doc);
            endCapsRecall.Start("Transação temporaria");
            endCaps.Start("Colocar os end caps");

            foreach (PipingSystem ps in CollectorSystems)
            {
                if ((ps.SystemType == PipeSystemType.DomesticColdWater || ps.SystemType == PipeSystemType.DomesticHotWater)
                    && ps.BaseEquipmentConnector != null && ps.BaseEquipmentConnector.Direction == FlowDirectionType.Out)
                {
                    foreach (Element pp in ps.PipingNetwork)
                    {
                        if (pp is Pipe && PlumbingUtils.HasOpenConnector(doc, pp.Id))
                            PlumbingUtils.PlaceCapOnOpenEnds(doc, pp.Id, (pp as Pipe).PipeType.Id);
                    }
                }
            }
            endCaps.Commit();
            coldAndHotWaterSystems = createSectors();
            endCapsRecall.RollBack();

Just a note, I can't make it work with

using (Transaction endCaps = new Transaction()) {}

 

0 Likes
Message 6 of 8

TripleM-Dev.net
Advisor
Advisor

if I read the code correct the endcaps can all be edited in one transaction so the inner transaction would only be needed once.

I was in the understanding that each endcap needed to be edited and then read and the next and the next..

 

Try the code below.

using (TransactionGroup endCapsRecall = new TransactionGroup(doc))
             {
                endCapsRecall.Start("Transação temporaria");
                using (Transaction endCaps = new Transaction(doc))
                {
                    endCaps.Start("Colocar os end caps"); // If inside transaction is sufficient/works here then place it here and not inside the if statement.
               
                    foreach (PipingSystem ps in CollectorSystems)
                    {
                        if ((ps.SystemType == PipeSystemType.DomesticColdWater || ps.SystemType == PipeSystemType.DomesticHotWater)
                            && ps.BaseEquipmentConnector != null && ps.BaseEquipmentConnector.Direction == FlowDirectionType.Out)
                        {
                            foreach (Element pp in ps.PipingNetwork)
                            {
                                if (pp is Pipe && PlumbingUtils.HasOpenConnector(doc, pp.Id))
                                {
                                    //using (Transaction endCaps = new Transaction(doc)) // Transaction only needed here, but if above transaction works leave this out
                                    //{
                                    //    endCaps.Start("Colocar os end caps");
                                        PlumbingUtils.PlaceCapOnOpenEnds(doc, pp.Id, (pp as Pipe).PipeType.Id);
                                    //    endCaps.Commit();
                                    //}
                                    
                                }

                            }
                        }
                    }

                    endCaps.Commit();
                }
                coldAndHotWaterSystems = createSectors();
                endCapsRecall.RollBack();
            }

 

0 Likes
Message 7 of 8

nelsonhp3
Contributor
Contributor

I don't think this is a good idea because in that case for each pipe there will be a new transaction.

0 Likes
Message 8 of 8

TripleM-Dev.net
Advisor
Advisor

That's why the Transaction is commented out in the loop, and only exits outside the loop.