Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Create the first Symbol of a Family

Sean_Page
Collaborator

Create the first Symbol of a Family

Sean_Page
Collaborator
Collaborator

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.

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Reply
546 Views
6 Replies
Replies (6)

longt61
Advocate
Advocate

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.  

 

Sean_Page
Collaborator
Collaborator

I was hopeful for a project solution, but this should work since BIF can't have their last type deleted.

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes

longt61
Advocate
Advocate

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());

 

Sean_Page
Collaborator
Collaborator

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!

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect

Sean_Page
Collaborator
Collaborator

Not sure if you can edit your answer or not, but the load family call is backwards. The method LoadFamily is called from the family doc, not the project doc.

 

famDoc.LoadFamily(projectDoc,new FamilyLoadOptions());

 

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect

longt61
Advocate
Advocate
Thanks for pointing that out. I have updated the code.
0 Likes