public static Dictionary <string, object> CreateDuctInsulation(List <Revit.Elements.Element> elements, Revit.Elements.Element ductInsulationType, double insulationThickness) { string result = ""; Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; ElementId dITId = doc.GetElement(ductInsulationType.UniqueId.ToString()).Id; insulationThickness *= 0.00328084; try { foreach (Revit.Elements.Element e in elements) { ElementId elId = doc.GetElement(e.UniqueId.ToString()).Id; DuctInsulation.Create(doc, elId, dITId, insulationThickness); } result = "Executed"; } catch (Exception ex) { result = ex.Message; } return(new Dictionary <string, object> { { "elements", elements }, { "result", result } }); }
public static Duct MakeDuct(Document doc, XYZ p1, XYZ p2, ElementId typ, ElementId mst, object diameter, object insulationThick) { if (typ == null) { throw new ArgumentNullException("A Duct Type must be specified"); } // use default level (actually - it appears that this doesn't work??? ElementId level = new ElementId(-1); IList <Level> levelsBelow = getAllLevelsBelow(doc, Math.Min(p1.Z, p2.Z)); Level levElement = null; if (levelsBelow != null) { levElement = levelsBelow[0]; } else { levElement = getClosestLevel(doc, Math.Min(p1.Z, p2.Z)); } Duct d = Duct.Create(doc, mst, typ, levElement.Id, p1, p2); if (diameter != null) { if (diameter is String) { d.get_Parameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM).SetValueString(diameter.ToString()); } if (diameter is double) { d.get_Parameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM).Set(Convert.ToDouble(diameter)); } } if (insulationThick != null) { //if (insulationThick is String) //{ // d.get_Parameter(BuiltInParameter.RBS_PIPE_INSULATION_THICKNESS).SetValueString(insulationThick.ToString()); //} //if (insulationThick is double) //{ // double ins = Convert.ToDouble(insulationThick); // if (ins != 0) d.get_Parameter(BuiltInParameter.RBS_PIPE_INSULATION_THICKNESS).Set(Convert.ToDouble(insulationThick)); //} double thick = Convert.ToDouble(insulationThick); if (thick > 0) { DuctInsulation test = DuctInsulation.Create(doc, d.Id, new ElementId(-1), Convert.ToDouble(insulationThick)); } } return(d); }