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
413 Views, 6 Replies

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

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.

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
Tags (2)
Labels (1)
6 REPLIES 6
Message 2 of 7
longt61
in reply to: Sean_Page

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.  

 

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

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

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
Message 4 of 7
longt61
in reply to: Sean_Page

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

 

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

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

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
Message 6 of 7
Sean_Page
in reply to: longt61

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

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
Message 7 of 7
longt61
in reply to: Sean_Page

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

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 Design & Make Report