Family Loading Failed in Revit API 2012

Family Loading Failed in Revit API 2012

Anonymous
Not applicable
4,094 Views
9 Replies
Message 1 of 10

Family Loading Failed in Revit API 2012

Anonymous
Not applicable

Hi Everyone,

 

I have created an extrusion in a family document and want to load it back to the Revit active project document. Everything works fine using Revit API 2011, however, when i try to implement the same thing using Revit 2012, it throws me an exception "A serious problem occurred. Please save and continue." When i debugged in, i receive an exception called   "Family Loading Failed". 


But everything work fine when i debugged using Revit 2011.


Below is some code snippets 
public bool CreateFamily(Document familyDoc, ExternalCommandData commandData, Document projectDoc)

{   

Transaction trans = new Transaction(familyDoc,  "Create Family");
try

{

if (trans.Start() == TransactionStatus.Started)

{

.............(Add reference plane)

.............(Add alignment)

.............(Add dimension)

familyDoc.LoadFamily(projectDoc, new FamilyOption());

trans.Commit();

return true;

}

catch (Exception ex)

{

trans.RollBack();

return false;

}

}

 

Any idea why this code works only for Revit 2011, but not 2012?

 

Many thanks if someone can help. 

 

http://www.box.net/shared/fn9nekkodxzse15l2qzj

0 Likes
4,095 Views
9 Replies
Replies (9)
Message 2 of 10

saikat
Autodesk
Autodesk

Hi :

 

Will it be possible to create a minimal buildable VS sample that I can quickly test at my end and investigate further. Please do not send across anything confidential

 

thanks

Saikat



Saikat Bhattacharya
Senior Manager - Technology Consulting
0 Likes
Message 3 of 10

Anonymous
Not applicable

Hi saikat,


Thanks for the reply. I managed to generate the same exception using code as attached. Please kindly view on it.
As problem mentioned, everything works fine in Revit 2011(Result.JPG attached in the same folder), however, not in Revit 2012.

 

I have also attach the structural column.rft used to create the family.

 

Please let me know if you can figure it out what goes wrong. Thanks.

 

 

0 Likes
Message 4 of 10

saikat
Autodesk
Autodesk

Hi:

 

Thanks for sending across the code. I have been able to reproduce the same behavior with Revit 2012 while the same code works for Revit 2011. I will be interacting with our Development team on this.

 

Meanwhile I have found a work around which is to use another overload of LoadFamily which is to load the family from a disk family file. My tests confirm that it works well with this workaround.

 

so essentially your code has to be modified to be something similar to what I have below -

 

<code_begin>

 

addReferencePlanes();

ExtrusionpSolid = createSolid();

_rvtDoc.Regenerate();

addAlignments(pSolid);

addParameters();

addDimensions();

familyTrans.Commit();

_rvtDoc.SaveAs(

@"C:\Temp\myfamily1.rfa");

 

Familyfamily;

 

Transaction loadTrans = newTransaction(commandData.Application.ActiveUIDocument.Document, "Loading");

loadTrans.Start();

commandData.Application.ActiveUIDocument.Document.LoadFamily(

@"C:\Temp\myfamily1.rfa", outfamily);

loadTrans.Commit();

 

<code_end>

 

Sorry for the bad news.

regards

Saikat

 

 



Saikat Bhattacharya
Senior Manager - Technology Consulting
0 Likes
Message 5 of 10

Anonymous
Not applicable

Hi saikat,

 

Thanks for the solution. Actually i planned to load the family back into the project document straight away without saving it. But looks like this doesn't work in Revit 2012. 😞

 

Please let me know the result after you have discussed with the Autodesk Development team. 

 

Thanks.

 

 

 

0 Likes
Message 6 of 10

Anonymous
Not applicable

Hi Saikat,

 

I am having exactly the same problem with LoadFamily in 2013. Has there been any feedback from the Development Team on this? Whilst the workaround kind of works it is very slow and very messy!

 

Thanks

 

Nick

0 Likes
Message 7 of 10

saikat
Autodesk
Autodesk

I just did a quick check again and it seems the behavior still exists for 2013. And so unfortunately, there isnt any other workaround (other than the one discussed on this) we can suggest for this at the moment for Revit 2013.

 

Sorry for the bad news.

 

If you are an ADN member, please feel free to log this as a case via DHO.



Saikat Bhattacharya
Senior Manager - Technology Consulting
0 Likes
Message 8 of 10

Anonymous
Not applicable
OK Saikat thanks for checking.
0 Likes
Message 9 of 10

Anonymous
Not applicable

So is this thread saying that you can't use the IFamilyLoadOptions interface?  Thanks.

0 Likes
Message 10 of 10

jnoordzij
Advocate
Advocate

EDIT: Nevermind. Please ignore this post. I got it to work.

 

--------------------------------------------------

 

 

Does this issue still exist in Revit 2019? I am having the exact same issue.

 

I am working with IronPython code through Dynamo for Revit, so the code looks a bit different.

 

Method a) works, but family gets loaded as 'family1'

 

#create family doc
famTemplatePath = app.FamilyTemplatePath
templateFullName = Path.Combine(famTemplatePath, templatename + ".rft")
famdoc = app.NewFamilyDocument(templateFullName) #load the family into the project famdoc.LoadFamily(doc)

 

 

Method b) does not work (family loading failed)

 

#create family doc
(...)

#give the family doc a name famdoc.SaveAs("somepath" + newfamilyname + ".rfa") #load the family into the project famdoc.LoadFamily(doc)

 

Method c) works:

#create family doc
(...)

#give the family doc a name
famdoc.SaveAs("somepath" + newfamilyname + ".rfa") #load the family into the project doc.LoadFamily("somepath" + newfamilyname + ".rfa")

 

 

0 Likes