Hi,
I would like to overwrite a familySymbol available in the document when document opened event. The familySymbol is not available in the family text file (i.e) familySymbol is available only in document.
I tried LoadFamilySymbol() method with IFamilyLoadOptions arguments, it returns false and familySymbol as null. I dont want to create the symbol in family text file and i need only to update the familysymbol available in the document.
Could anyone help me to solve this issue.
Regards,
sangsen
Solved! Go to Solution.
Solved by Lucavox. Go to Solution.
If you're trying to overwrite a FamilySymbol you could just find the one you're trying to chanage, start a Transaction, and then edit the parameters. No reason to reload the family at all, unless it's a different version. If you need to make a new Type of that family, you can just Duplicate the first FamilySymbol and then change the parameters.
Hi,
This is a short code to Load a family in the document knowing the path and the type name you need:
string path = @"c:\familyfile.rfa"; string name = "Type name"; //You need to set the path and type name correctly Transaction t = new Transaction(Document, "load_my_symbol"); t.Start(); Document.LoadFamilySymbol(path, name); t.Commit();
I don't understand if you need to replace instances within the project. But if you need to use FamilyLoadoptions the code below could be helpful:
- First build the class
public class familyloadoptions : IFamilyLoadOptions { #region IFamilyLoadOptions Members public bool OnFamilyFound(bool familyInUse, out bool overwriteParameterValues) { if( !familyInUse ) { overwriteParameterValues = true; return true; } else { overwriteParameterValues = true; return true; } } public bool OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues) { if (!familyInUse) { source = FamilySource.Family; overwriteParameterValues = true; return true; } else { source = FamilySource.Family; overwriteParameterValues = true; return true; } } #endregion }
Here the code of the command:
string path = @"c:\familyfile.rfa"; string name = "Type name"; Transaction t = new Transaction(Document, "load_my_symbol"); t.Start(); FamilySymbol symb; Document.LoadFamilySymbol(path, name, new familyloadoptions(), out symb); t.Commit();
Kind regards,
Luca Vocella