public FloorType GetFloorType(Document doc, FloorSlab floor) { FloorType f = new FilteredElementCollector(doc).OfClass(typeof(FloorType)) .Where(ft => ft is FloorType) .FirstOrDefault(e => { CompoundStructure comp = (e as FloorType).GetCompoundStructure(); if (comp.GetLayerWidth(0) == Util.MmToFoot(floor.Depth)) { return true; } return false; }) as FloorType; if (f != null) return f; f = new FilteredElementCollector(doc).OfClass(typeof(FloorType)).FirstOrDefault(e => e.Name == "Generic - 12\"") as FloorType; f = f.Duplicate(String.Format("Floor {0} CM", floor.Depth / 10)) as FloorType; CompoundStructure compound = f.GetCompoundStructure(); compound.SetLayerWidth(0, Util.MmToFoot(floor.Depth)); f.SetCompoundStructure(compound); return f; }
public Floor CreateFloor(Document doc, FloorSlab floor) { CurveArray curArr = new CurveArray(); List<XYZ> pts = floor.Profile.Select(pt => { Point3D pt1 = new Point3D(pt.X, pt.Y, pt.Z) * floor.Mat; return new XYZ(Util.MmToFoot(pt1.X), Util.MmToFoot(pt1.Y), Util.MmToFoot(pt1.Z)); }).ToList(); for (int i = 0; i < pts.Count - 1; i++) { curArr.Append(Line.CreateBound(pts[i], pts[i + 1])); } Floor f = doc.Create.NewFloor(curArr, GetFloorType(doc, floor), GetLevel(doc, floor.Level), false); f.LookupParameter("Height Offset From Level").Set(0); return f; }