Message 1 of 4
Insert Family Instance

Not applicable
06-18-2018
07:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I know that this topic has been discussed before, but I still can't get what I want. I have a family which I get using:
FilteredElementCollector famColl = new FilteredElementCollector(doc) .OfClass(typeof(Family));
Family fam = null;
foreach (Element e in famColl)
{
if (e.Name == "FAMILY NAME")
{
fam = e as Family;
}
}
From this step, I just need to get the Family Symbol. I used this (got this from this forum), but with no success:
FamilySymbol famSym = null; foreach (ElementId fsIds in fam.GetFamilySymbolIds()) { ElementType elemType = doc.GetElement(fsIds) as ElementType; if (elemType.Name == "NAME") { famSym = doc.GetElement(fsIds) as FamilySymbol; } }
Finally, I want to use the Create.NewFamilyInstance method as follows:
FamilyInstance famInst = null;
using (Transaction t = new Transaction(doc, "Insert Family Instance")) { t.Start(); famInst = doc.Create.NewFamilyInstance(posEtiqueta, famSym, view); t.Commit(); }
Any tip of advice will be well received!
Thanks in advance!