Update family instance parameters when lookup table changes

Update family instance parameters when lookup table changes

4Dselect
Explorer Explorer
1,389 Views
3 Replies
Message 1 of 4

Update family instance parameters when lookup table changes

4Dselect
Explorer
Explorer

Hi All,

I am currently working on a procedure to update a lookup table connected to a family and subsequently update all instances of that family. I got as far as to update the family definition with the modified lookup table and all newly placed instances of that family are drawn with regards to the new values in the lookup table.

But what with the allready placed instances? I was looking for a way to force all instances to recalculate their parameter values but I can't seem to find the right procedure. In the fora I find procedures to update parameters to change their values but nothing to recalculate the values according to a lookup table.

Can somebody point me in the right direction?

I am currently using Revit 2020 on a Windows 10 (x64) workstation.

Regards.

Wim A.

0 Likes
Accepted solutions (1)
1,390 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Is there any procedure to achieve what you need manually in the end user interface?

 

If not, the API will probably not provide any either.

 

Maybe the only solution is  to cycle through all your instances one by one and update their properties as needed yourself?

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 4

4Dselect
Explorer
Explorer

Hello Jeremy,

You are right about your remarc, I hadn't thought of it that way so I started testing.

When I update my family manually with a new lookup table and save it to my model then I get the question to just overwrite the family or be more destructive and overwrite all parameters too. I chose the first option to just overwrite the family and I can see all my instances beeing updated with the new values from the lookup tabel. So manually my idea works.

But in case the API doesn't have the possibility to update the instances, how do I go about it?

I can select all the instances from a perticular family, iterate through them, get eacht parameter, and then what? How do I recalculate a parameter?

Kind regards.

Wim A.

0 Likes
Message 4 of 4

4Dselect
Explorer
Explorer
Accepted solution

Hi Everybody,

I have found a solution to my problem. In stead of importing the sizetable in my parent document I have to edit the family as a document, import the sizetable in the family document and then update the family in the parent document. This triggers an update for all instances connected to this family.

In code I get something like this:

                ARDB.Family CurrentFamily = el as ARDB.Family;
                if (CurrentFamily.Name == "M_Rectangular Elbow - Radius")
                {
                    ARDB.Document ThisElbowDoc= doc.EditFamily(CurrentFamily);
                    ARDB.FamilySizeTableManager ThisSizeTableManager = ARDB.FamilySizeTableManager.GetFamilySizeTableManager(ThisElbowDoc, ThisElbowDoc.OwnerFamily.Id);
                    if (ThisSizeTableManager.IsValidObject)
                    {
                        // must happen in a transaction.
                        ARDB.Transaction t = new ARDB.Transaction(ThisElbowDoc, "New Sizelist");
                        t.Start("New Sizelist");
                        //import the sizetable, overwrite the existing one.
                        ARDB.FamilySizeTableErrorInfo ImportErrorInfo = new ARDB.FamilySizeTableErrorInfo();
                        string ThisSizeTableName = "C:\\Data\\projecten\\4DSELECTWOMMELGEM-WOMMELGEM\\WIM-0917\\Job\\Opleiding\\M_Rectangular Elbow - Radius.csv";
                        ThisSizeTableManager.ImportSizeTable(ThisElbowDoc, ThisSizeTableName, ImportErrorInfo);
                        // End transaction
                        t.Commit();
                        // Save the modified sizetable in the parent document
                        FamilyOption ThisLoadOptions = new FamilyOption(); // Custom made function
                        ThisElbowDoc.LoadFamily(doc, ThisLoadOptions); // here the update begins
                    }
}

Without all the error checking and stuff. But it does the trick. When I modify my sizetable content and reload it, all related instanced are recalculated according to the new values in the sizetable.

Hope this helps someone.

Regards.

Wim A.

4Dselect.be