Am I just missing something right in front of me, or is the ONLY way to create a symbol under a family is to duplicate an existing one? I am trying to allow the user to make new types, but some families don't have any types especially if the model has been purged, and therefore it's breaking then"Symbol.Duplicate()" function.
Am I just missing something right in front of me, or is the ONLY way to create a symbol under a family is to duplicate an existing one? I am trying to allow the user to make new types, but some families don't have any types especially if the model has been purged, and therefore it's breaking then"Symbol.Duplicate()" function.
You can edit the existing family and create a new type in the family document, then load it back to current project. It might be a bit slower than type duplication in current project document but it does the job. Just keep in mind that is method can be applied to custom families (families which can be saved to external .rfa file) only but not Revit built in system family.
You can edit the existing family and create a new type in the family document, then load it back to current project. It might be a bit slower than type duplication in current project document but it does the job. Just keep in mind that is method can be applied to custom families (families which can be saved to external .rfa file) only but not Revit built in system family.
well, this is the code you ask for, but you have to custom/ modify it further though
Family family = Get_your_family();
Document famDoc = projectDoc.EditFamily(family);
using(Transaction trans = new Transaction(famDoc, "Create new type"))
{
trans.Start();
FamilyType newType = famDoc.FamilyManager.NewType("new type name");
// check the overload and custom the code to suit your need
FamilyParameter param_1 = famDoc.FamilyManager.Parameters.Cast<FamilyParameter>().FirstOrDefault(x => x.Definition.Name == "your_param_name_1");
famDoc.FamilyManager.Set(param_1, "new value");
FamilyParameter param_2 = famDoc.FamilyManager.Parameters.Cast<FamilyParameter>().FirstOrDefault(x => x.Definition.Name == "your_param_name_2");
famDoc.FamilyManager.Set(param_2, 20.5);
trans.Commit();
}
famDoc.LoadFamily(projectDoc, new LoadFamilyOptions());
well, this is the code you ask for, but you have to custom/ modify it further though
Family family = Get_your_family();
Document famDoc = projectDoc.EditFamily(family);
using(Transaction trans = new Transaction(famDoc, "Create new type"))
{
trans.Start();
FamilyType newType = famDoc.FamilyManager.NewType("new type name");
// check the overload and custom the code to suit your need
FamilyParameter param_1 = famDoc.FamilyManager.Parameters.Cast<FamilyParameter>().FirstOrDefault(x => x.Definition.Name == "your_param_name_1");
famDoc.FamilyManager.Set(param_1, "new value");
FamilyParameter param_2 = famDoc.FamilyManager.Parameters.Cast<FamilyParameter>().FirstOrDefault(x => x.Definition.Name == "your_param_name_2");
famDoc.FamilyManager.Set(param_2, 20.5);
trans.Commit();
}
famDoc.LoadFamily(projectDoc, new LoadFamilyOptions());
Thanks @longt61, I am very familiar with this process and working with loadable families in the FamilyManager context. Like I said I thought maybe I was just overlooking something for creating new vs duplicating in the Project environment. I think your suggestion will be how I will proceed!
Thanks @longt61, I am very familiar with this process and working with loadable families in the FamilyManager context. Like I said I thought maybe I was just overlooking something for creating new vs duplicating in the Project environment. I think your suggestion will be how I will proceed!
Can't find what you're looking for? Ask the community or share your knowledge.