public FamilyInstance CreateSteelBeamInstance(Document doc, BeamSt beam, FamilySymbol fs)
 {
     StructuralType stBeam = StructuralType.Beam;
     XYZ p1 = new XYZ(Util.MmToFoot(beam.Location.X), Util.MmToFoot(beam.Location.Y), Util.MmToFoot(beam.Location.Z));
     XYZ p2 = p1 + beam.Length * new XYZ(Util.MmToFoot(beam.Axis.X), Util.MmToFoot(beam.Axis.Y), Util.MmToFoot(beam.Axis.Z));
     Line l1 = Line.CreateBound(p1, p2);
     FamilyInstance fi = doc.Create.NewFamilyInstance(l1, fs, null, stBeam);
     fi.LookupParameter("Reference Level").Set(GetLevel(doc, beam.Location.Z).Id);
     return fi;
 }
        public FamilySymbol GetIShapeBeamFamilySymbol(Document doc, BeamSt Beam, string familyName, BuiltInCategory category)
        {
            FamilySymbol fs = new FilteredElementCollector(doc).OfCategory(category)
                                                        .WhereElementIsElementType()
                                                        .Cast<FamilySymbol>()
                                                        .Where(f => f.FamilyName == familyName)
                                                        .FirstOrDefault(f =>
                                                        {
                                                            if (f.LookupParameter("Width").AsDouble() == Util.MmToFoot(Beam.Width) &&
                                                                f.LookupParameter("Height").AsDouble() == Util.MmToFoot(Beam.Depth) &&
                                                                f.LookupParameter("Flange Thickness").AsDouble() == Util.MmToFoot(Beam.FlangeTh) &&
                                                                f.LookupParameter("Web Thickness").AsDouble() == Util.MmToFoot(Beam.WebTh)
                                                                )
                                                            {
                                                                return true;
                                                            }
                                                            return false;
                                                        });

            if (fs != null) return fs;

            Family family = default;
            try
            {
                fs = new FilteredElementCollector(doc).OfCategory(category)
                                                        .WhereElementIsElementType()
                                                        .Cast<FamilySymbol>()
                                                        .First(f => f.FamilyName == familyName);
            }
            catch (Exception)
            {
                string directory = $"C:/ProgramData/Autodesk/RVT {revitVersion}/Libraries/US Imperial/Structural Framing/Steel/AISC 14.1/";
                family = OpenFamily(doc, directory, familyName);
                fs = doc.GetElement(family.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol;
            }

            ElementType fs1 = fs.Duplicate(String.Format("I-Beam Custom {0:0}x{1:0}", Beam.Width / 10, Beam.Depth / 10));
            fs1.LookupParameter("Width").Set(Util.MmToFoot(Beam.Width));
            fs1.LookupParameter("Height").Set(Util.MmToFoot(Beam.Depth));
            fs1.LookupParameter("Flange Thickness").Set(Util.MmToFoot(Beam.FlangeTh));
            fs1.LookupParameter("Web Thickness").Set(Util.MmToFoot(Beam.WebTh));
            fs1.LookupParameter("Web Fillet").Set(Util.MmToFoot(0.85 * (Beam.WebTh)));

            return fs1 as FamilySymbol;
        }