smmoes,
As Aaron stated, it needs to be in the scope of a transaction.
Aaron.Lu wrote:Try this:
Transaction transaction = new Transaction(doc, "LoadFamilyTest"); transaction.Start(); try { FamilySymbol symbol; var file = @"D:\---\family symbol insert error\Rectangular Offset Radius Drop-Cheek.rfa"; var loaded = doc.LoadFamilySymbol(file, "Standard", out symbol); if (loaded) { TaskDialog.Show("Info", symbol.Name); } transaction.Commit(); } catch (Exception ex) { message = ex.ToString(); transaction.RollBack(); }Please note that the family you uploaded only has a type named "Standard" rather than "Rectangular Offset Radius Drop-Cheek"
Also: if you want to use a *symbol*, don't forget to make sure it is activated by calling: symbol.Activate();
Of course you can use Document.LoadFamily to load the entire family into the document, while LoadFamilySymbol only loads the one you required.
var file = @"D:\---\family symbol insert error\Rectangular Offset Radius Drop-Cheek.rfa"; Family family; var loaded = doc.LoadFamily(file, out family); if (loaded) { TaskDialog.Show("Info", family.Name); }
Aaron,
I have my Symbol creation within the scope of a transaction, unfortunately, still no luck. Also, I don't think I can use Family, as opposed to Family Symbol because I'm using this to create a Family Instance, Here is what I have, in it's entirety, right now. Like I said, this works for numerous other families, it's just sometimes when I modify/save a family and I return to using it in this fashion it just starts failing by telling me it can't load the Symbol. It's odd.
using (Transaction trans = new Transaction(doc, "Family Insert")) { trans.Start(); FamilySymbol famSym = null; FamilyInstance famInstance = null; //Location of Family on machine string fileLoc = @"C:\Revit Families\Rectangular Offset Radius Drop-Cheek.rfa"; //Family Name string famName = "Rectangular Offset Radius Drop-Cheek"; //Load Family Symbol doc.LoadFamilySymbol(fileLoc, famName, out famSym); // Check FamSym integrity. if ((!famSym.IsActive) && (famSym != null)) // <-- This is where it fails, we have 'null' for famSym from previous method. { famSym.Activate(); doc.Regenerate(); } famInstance = doc.Create.NewFamilyInstance(new XYZ(0,0,0), famSym, AutoDesk.Revit.DB.Structure.StructuralType.NonStructural); trans.Commit(); }