re-LoadFamily that is already in the project document

re-LoadFamily that is already in the project document

g_sicre
Contributor Contributor
4,982 Views
9 Replies
Message 1 of 10

re-LoadFamily that is already in the project document

g_sicre
Contributor
Contributor

Hi all,

 

I am having some trouble when reloading families in the model using both .LoadFamily() and .LoadFamilySymbol() methods. I have already read some posts about this topic (and its given solutions) such as:

 

- https://forums.autodesk.com/t5/revit-api-forum/problem-with-loadfamily-method/td-p/7407956

- https://forums.autodesk.com/t5/revit-api-forum/ifamilyloadoptions-not-respected-in-python/td-p/97287...

 

I have realise that, when trying to reload a family that was already in the project when it was opened, both methods fail. Nevertheless, if the family is loaded for the first time with .LoadFamilySymbol() you achieve your goal, whereas doing the same with .LoadFamily() always return false. I am trying passing all different arguments (including IFamilyLoadOptions) and no matter which of them I used, the result is always as I have said.

 

Regarding above posts:

- I am modifying the family before trying to load it.

- I am using Python.

 

So, I am asking for a solution to re-load a family that is already in the project document.

 

Thank you in advance

0 Likes
Accepted solutions (2)
4,983 Views
9 Replies
Replies (9)
Message 2 of 10

TripleM-Dev.net
Advisor
Advisor

Hi,

 

Actually the second link provides "some" answer, like @jeremytammik states that there could be something wrong with the wrapper for this specific function. Maybe ask the forum of the Pyton used?

 

I tested the code from the first link in the Revit API and works as expected, the changed family is overwritten in the project.

 

- Michel

0 Likes
Message 3 of 10

franciscopossetto
Advocate
Advocate

Could you share the error you have after running those methods?

Github:
https://github.com/franpossetto
0 Likes
Message 4 of 10

g_sicre
Contributor
Contributor

Hi,

 

I do not have an error. It just return "false". 

@jeremytammik suggest defining the IFamilyLoadOptions interface in C#, but I do not know how to "combine" this part of the code in C# with the rest in Python.

 

I will ask through Stackoverflow if there is any way to convert this options to Python, and come back here if I get something.

 

Thank you both.

0 Likes
Message 5 of 10

franciscopossetto
Advocate
Advocate

Hey,

 

You can try with the implementation that Grant Foster uploaded in the RevitAPIDocs/code.

https://www.revitapidocs.com/code/#Python_FamilyLoader-py

 

It is pretty similar to yours. Just some details are different. I think this implementation is for pyRevit. You could try pyRevit, in order to know if it is problem-related to Dynamo or with the code.

 

Kind regards.

Github:
https://github.com/franpossetto
0 Likes
Message 6 of 10

franciscopossetto
Advocate
Advocate
Accepted solution

I got the difference. The first method you defined in your class is called OnFamilyLoad. It works when the family is not loaded in the document. Replace it with OnFamilyFound.

 

It should work:

1a.png

Kind regards.

Github:
https://github.com/franpossetto
0 Likes
Message 7 of 10

g_sicre
Contributor
Contributor

Hi Francisco,

 

I have tried the code that you shared, with OnFamilyFound method, and works fine loading family symbols. However, I keep having the same result (false) when I try to reload a family that was already in the project.

Screenshot_2.png

 

In your code, do you reload a family that was already in the project? 

 

Thanks a lot for your time,

 

Kind Regards

0 Likes
Message 8 of 10

franciscopossetto
Advocate
Advocate
Accepted solution

Hey,

 

After running the script, the result that I got is that the FamilySymbol is updated, and all instances are updated too.

 

I did this test:

1. Run the script - > it returned true: FamilySymbol is updated, and all instances are updated too.

2. Run the script again -> it returned false: I think because the Family hasn´t had any changes.

3. Modify family and run the script -> it returned false

4. I refresh dynamo disconnecting the nodes-> it returns a warning.

5. I connect the nodes again, and run -> FamilySymbol is updated, and all instances are updated too.

 

Be sure you are using a Family that has been modified and trying refreshing dynamo after modifying your Family and then reload it. 

 

I hope it helps,

Kind regards.

Github:
https://github.com/franpossetto
0 Likes
Message 9 of 10

g_sicre
Contributor
Contributor
Hi Francisco,

you are totally right! I did what you suggested in your previous posts but that time I completly forgot to modify the family before reload it. Now I have done again what I shared before and all instances are updated.

Thank you so much for your help!

Kind regards.
0 Likes
Message 10 of 10

franciscopossetto
Advocate
Advocate

I'm glad it worked!

Github:
https://github.com/franpossetto
0 Likes