Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create the first Symbol of a Family

6 REPLIES 6
Reply
Message 1 of 7
Sean_Page
266 Views, 6 Replies

Create the first Symbol of a Family

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.

Tags (2)
Labels (1)
6 REPLIES 6
Message 2 of 7
longt61
in reply to: Sean_Page

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.  

 

Message 3 of 7
Sean_Page
in reply to: Sean_Page

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

Message 4 of 7
longt61
in reply to: Sean_Page

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

 

Message 5 of 7
Sean_Page
in reply to: longt61

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!

Message 6 of 7
Sean_Page
in reply to: longt61

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

 

Message 7 of 7
longt61
in reply to: Sean_Page

Thanks for pointing that out. I have updated the code.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community