Problem with LoadFamily method

Problem with LoadFamily method

sean_dodsworth
Contributor Contributor
4,482 Views
5 Replies
Message 1 of 6

Problem with LoadFamily method

sean_dodsworth
Contributor
Contributor

Hi All,

I'm having trouble using the Document.LoadFamily method to load a family when an older version of the family exists in the model.

 

My code looks like this:

 

 

public class FamilyLoadOptions : IFamilyLoadOptions
    {
        public bool OnFamilyFound(bool familyInUse, out bool overwriteParameterValues)
        {
            overwriteParameterValues = true;
            return true;
        }

        public bool OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues)
        {
            source = FamilySource.Family;
            overwriteParameterValues = true;
            return true;
        }

    }


Family loadedFamily = null;
var success = doc.LoadFamily(localPath, new FamilyLoadOptions(), out loadedFamily);

 

When the family already exists in the model success is always false and loadedFamily is always null.

 

Also when I try to debug the FamilyLoadOptions neither of its methods are every accessed.

 

Thanks in advance,

Sean

Accepted solutions (1)
4,483 Views
5 Replies
Replies (5)
Message 2 of 6

aignatovich
Advisor
Advisor
Accepted solution
Hi, Sean!

Did you try to change anything in your family before loading it into the project? If nothing changed, Revit will not load it to the document
0 Likes
Message 3 of 6

sean_dodsworth
Contributor
Contributor

Yeah you're right, the family I was loading in must have been unchanged even though I had copied it to a different location.

 

Out of interest how does Revit know if one family is the same as another? Does it actually compare them element by element?

0 Likes
Message 4 of 6

aignatovich
Advisor
Advisor
Don't know exactly, may be it just compares the hash of the families contents
0 Likes
Message 5 of 6

jeremytammik
Autodesk
Autodesk

Dear Sean,

 

Thank you for your query, and to Alexander for his succinct, precise, complete answer.

 

Here are some previous discussions of thsis topic:

 

 

I hope this helps.

 

Best regards,

 

Jeremy



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

0 Likes
Message 6 of 6

sean_dodsworth
Contributor
Contributor

Hi Jeremy,

I did try searching but didn't find the links you just posted.

This one is exactly what I was looking for: http://thebuildingcoder.typepad.com/blog/2011/10/reloading-a-family-again.html

It would be great if the SDK documentation for the LoadFamily method included that bit of information.

 

- Sean