public static List <IBHoMObject> FromRevit(this Autodesk.Revit.DB.Mechanical.Duct duct, Discipline discipline, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { switch (discipline) { case Discipline.Architecture: case Discipline.Physical: case Discipline.Environmental: return(new List <IBHoMObject>(duct.DuctFromRevit(settings, refObjects))); default: return(null); } }
public static List <BH.oM.MEP.System.Duct> DuctFromRevit(this Autodesk.Revit.DB.Mechanical.Duct revitDuct, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); // Reuse a BHoM duct from refObjects if it has been converted before List <BH.oM.MEP.System.Duct> bhomDucts = refObjects.GetValues <BH.oM.MEP.System.Duct>(revitDuct.Id); if (bhomDucts != null) { return(bhomDucts); } else { bhomDucts = new List <BH.oM.MEP.System.Duct>(); } List <BH.oM.Geometry.Line> queried = Query.LocationCurveMEP(revitDuct, settings); // Flow rate double flowRate = revitDuct.LookupParameterDouble(BuiltInParameter.RBS_DUCT_FLOW_PARAM); BH.oM.MEP.System.SectionProperties.DuctSectionProperty sectionProperty = BH.Revit.Engine.Core.Query.DuctSectionProperty(revitDuct, settings); // Orientation angle double orientationAngle = revitDuct.OrientationAngle(settings); //ToDo - resolve in next issue, specific issue being raised for (int i = 0; i < queried.Count; i++) { BH.oM.Geometry.Line segment = queried[i]; BH.oM.MEP.System.Duct thisSegment = new Duct { StartPoint = segment.StartPoint(), EndPoint = segment.EndPoint(), FlowRate = flowRate, SectionProperty = sectionProperty, OrientationAngle = orientationAngle }; //Set identifiers, parameters & custom data thisSegment.SetIdentifiers(revitDuct); thisSegment.CopyParameters(revitDuct, settings.ParameterSettings); thisSegment.SetProperties(revitDuct, settings.ParameterSettings); bhomDucts.Add(thisSegment); } refObjects.AddOrReplace(revitDuct.Id, bhomDucts); return(bhomDucts); }
public bool CanConvertToSpeckle(object @object) { return(@object switch { DB.DetailCurve _ => true, DB.DirectShape _ => true, DB.FamilyInstance _ => true, DB.Floor _ => true, DB.Level _ => true, DB.View _ => true, DB.ModelCurve _ => true, DB.Opening _ => true, DB.RoofBase _ => true, DB.Area _ => true, DB.Architecture.Room _ => true, DB.Architecture.TopographySurface _ => true, DB.Wall _ => true, DB.Mechanical.Duct _ => true, DB.Mechanical.Space _ => true, DB.Plumbing.Pipe _ => true, DB.Electrical.Wire _ => true, DB.CurtainGridLine _ => true, //these should be handled by curtain walls DB.Architecture.BuildingPad _ => true, DB.Architecture.Stairs _ => true, DB.Architecture.StairsRun _ => true, DB.Architecture.StairsLanding _ => true, DB.Architecture.Railing _ => true, DB.Architecture.TopRail _ => true, DB.Ceiling _ => true, DB.PointCloudInstance _ => true, DB.Group _ => true, DB.ProjectInfo _ => true, DB.ElementType _ => true, DB.Grid _ => true, DB.ReferencePoint _ => true, DB.Structure.AnalyticalModelStick _ => true, DB.Structure.AnalyticalModelSurface _ => true, DB.Structure.BoundaryConditions _ => true, _ => (@object as Element).IsElementSupported() });
public static IEnumerable <IBHoMObject> FromRevit(this Autodesk.Revit.DB.Mechanical.Duct duct, Discipline discipline, Transform transform = null, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { IEnumerable <IElement1D> result = null; switch (discipline) { case Discipline.Architecture: case Discipline.Physical: case Discipline.Environmental: result = new List <IElement1D>(duct.DuctFromRevit(settings, refObjects)); break; } if (result != null && transform?.IsIdentity == false) { TransformMatrix bHoMTransform = transform.FromRevit(); result = result.Select(x => x.ITransform(bHoMTransform)); } return(result?.Cast <IBHoMObject>().ToList()); }
public static IProfile Profile(this Autodesk.Revit.DB.Mechanical.Duct duct, RevitSettings settings = null) { settings = settings.DefaultIfNull(); // Is the duct circular, rectangular or oval? // Get the duct shape, which is either circular, rectangular, oval or null Autodesk.Revit.DB.ConnectorProfileType ductShape = BH.Revit.Engine.Core.Query.Shape(duct, settings); //duct.DuctType.Shape; switch (ductShape) { case Autodesk.Revit.DB.ConnectorProfileType.Round: // Create a circular profile // Diameter double diameter = duct.Diameter.ToSI(UnitType.UT_HVAC_DuctSize); // Thickness / gauge of the duct sheet double thickness = 0.001519; // Dafault to 16 gauge, to be changed later return(BH.Engine.Spatial.Create.TubeProfile(diameter, thickness)); case Autodesk.Revit.DB.ConnectorProfileType.Rectangular: // Create a rectangular box profile double boxHeight = duct.Height.ToSI(UnitType.UT_HVAC_DuctSize); double boxWidth = duct.Width.ToSI(UnitType.UT_HVAC_DuctSize); double boxThickness = 0.001519; // Dafault to 16 gauge, to be changed later double outerRadius = 0; double innerRadius = 0; return(BH.Engine.Spatial.Create.BoxProfile(boxHeight, boxWidth, boxThickness, outerRadius, innerRadius)); case Autodesk.Revit.DB.ConnectorProfileType.Oval: // Create an oval profile // There is currently no section profile for an oval duct in BHoM_Engine. This part will be implemented once the relevant section profile becomes available. BH.Engine.Reflection.Compute.RecordError("Unable to create a profile for an oval duct at this time because there is currently no section profile for an oval duct. Element ID: " + duct.Id); return(null); default: return(null); } }
public static BH.oM.MEP.System.SectionProperties.DuctSectionProperty DuctSectionProperty(this Autodesk.Revit.DB.Mechanical.Duct revitDuct, RevitSettings settings = null) { settings = settings.DefaultIfNull(); // Duct section profile SectionProfile sectionProfile = revitDuct.DuctSectionProfile(settings); // Duct section property return(BH.Engine.MEP.Create.DuctSectionProperty(sectionProfile)); }
public static BH.oM.MEP.System.SectionProperties.SectionProfile DuctSectionProfile(this Autodesk.Revit.DB.Mechanical.Duct revitDuct, RevitSettings settings = null) { settings = settings.DefaultIfNull(); IProfile profile = revitDuct.Profile(settings); // Lining thickness double liningThickness = revitDuct.LookupParameterDouble(BuiltInParameter.RBS_REFERENCE_LINING_THICKNESS); if (liningThickness == double.NaN) { liningThickness = 0; } // Insulation thickness double insulationThickness = revitDuct.LookupParameterDouble(BuiltInParameter.RBS_REFERENCE_INSULATION_THICKNESS); if (insulationThickness == double.NaN) { insulationThickness = 0; } // Create a section profile if (profile != null) { return(BH.Engine.MEP.Create.SectionProfile(profile as dynamic, liningThickness, insulationThickness)); } else { return(null); } }
/// <summary> /// Initialize a Duct element /// </summary> /// <param name="instance">The instance.</param> private void InitPipe(Autodesk.Revit.DB.Mechanical.Duct instance) { Autodesk.Revit.DB.MEPCurve fi = instance as Autodesk.Revit.DB.MEPCurve; InternalSetMEPCurve(fi); }
/// <summary> /// Initializes a new instance of the <see cref="Duct"/> class. /// </summary> /// <param name="instance">The instance.</param> protected Duct(Autodesk.Revit.DB.Mechanical.Duct instance) { SafeInit(() => InitPipe(instance)); }
public static Dictionary <string, object> ByPolyCurve(Revit.Elements.Element ductType, Revit.Elements.Element mechanicalSystemType, PolyCurve polyCurve, Revit.Elements.Level level, double maxLength, Featureline featureline) { Utils.Log(string.Format("Duct.ByPolyCurve started...", "")); var totalTransform = RevitUtils.DocumentTotalTransform(); var totalTransformInverse = totalTransform.Inverse(); if (!SessionVariables.ParametersCreated) { UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument); } var oType = ductType.InternalElement as Autodesk.Revit.DB.Mechanical.DuctType; var oSystemType = mechanicalSystemType.InternalElement as Autodesk.Revit.DB.Mechanical.MechanicalSystemType; var l = level.InternalElement as Autodesk.Revit.DB.Level; double length = polyCurve.Length; int subdivisions = Convert.ToInt32(Math.Ceiling(length / maxLength)); IList <Autodesk.DesignScript.Geometry.Point> points = new List <Autodesk.DesignScript.Geometry.Point>(); points.Add(polyCurve.StartPoint); foreach (Autodesk.DesignScript.Geometry.Point p in polyCurve.PointsAtEqualChordLength(subdivisions)) { points.Add(p); } points.Add(polyCurve.EndPoint); points = Autodesk.DesignScript.Geometry.Point.PruneDuplicates(points); IList <ElementId> ids = new List <ElementId>(); TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); for (int i = 0; i < points.Count - 1; ++i) { Autodesk.DesignScript.Geometry.Point start = points[i].Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var s = start.ToXyz(); Autodesk.DesignScript.Geometry.Point end = points[i + 1].Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point; var e = end.ToXyz(); Autodesk.Revit.DB.Mechanical.Duct p = Autodesk.Revit.DB.Mechanical.Duct.CreatePlaceholder(DocumentManager.Instance.CurrentDBDocument, oSystemType.Id, oType.Id, l.Id, s, e); ids.Add(p.Id); } var ductIds = Autodesk.Revit.DB.Mechanical.MechanicalUtils.ConvertDuctPlaceholders(DocumentManager.Instance.CurrentDBDocument, ids); TransactionManager.Instance.TransactionTaskDone(); DocumentManager.Instance.CurrentDBDocument.Regenerate(); Duct[] ducts = GetDuctsByIds(ductIds); foreach (Duct pipe in ducts) { var curve = pipe.Location.Transform(totalTransformInverse) as Autodesk.DesignScript.Geometry.Curve; var sp = curve.StartPoint; var ep = curve.EndPoint; pipe.SetParameterByName(ADSK_Parameters.Instance.Corridor.Name, featureline.Baseline.CorridorName); pipe.SetParameterByName(ADSK_Parameters.Instance.BaselineIndex.Name, featureline.Baseline.Index); pipe.SetParameterByName(ADSK_Parameters.Instance.Code.Name, featureline.Code); pipe.SetParameterByName(ADSK_Parameters.Instance.Side.Name, featureline.Side.ToString()); pipe.SetParameterByName(ADSK_Parameters.Instance.X.Name, Math.Round(sp.X, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Y.Name, Math.Round(sp.Y, 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Z.Name, Math.Round(sp.Z, 3)); var soe = featureline.GetStationOffsetElevationByPoint(sp); pipe.SetParameterByName(ADSK_Parameters.Instance.Station.Name, Math.Round((double)soe["Station"], 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Offset.Name, Math.Round((double)soe["Offset"], 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Elevation.Name, Math.Round((double)soe["Elevation"], 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.Update.Name, 1); pipe.SetParameterByName(ADSK_Parameters.Instance.Delete.Name, 0); soe = featureline.GetStationOffsetElevationByPoint(ep); pipe.SetParameterByName(ADSK_Parameters.Instance.EndStation.Name, Math.Round((double)soe["Station"], 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.EndOffset.Name, Math.Round((double)soe["Offset"], 3)); pipe.SetParameterByName(ADSK_Parameters.Instance.EndElevation.Name, Math.Round((double)soe["Elevation"], 3)); } IList <Fitting> fittings = new List <Fitting>(); for (int i = 0; i < ducts.Length - 1; ++i) { Fitting fitting = null; try { fitting = Fitting.Elbow(ducts[i], ducts[i + 1]); } catch { } fittings.Add(fitting); } totalTransform.Dispose(); totalTransformInverse.Dispose(); Utils.Log(string.Format("Duct.ByPolyCurve completed.", "")); return(new Dictionary <string, object>() { { "Ducts", ducts }, { "Fittings", fittings } }); }