Exemplo n.º 1
0
        /// <summary>
        /// Gets the ducts by ids.
        /// </summary>
        /// <param name="ids">The ids.</param>
        /// <returns></returns>
        private static Duct[] GetDuctsByIds(ICollection <ElementId> ids)
        {
            Utils.Log(string.Format("Duct.GetDuctsByIds started...", ""));

            var pipes = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument)
                        .OfClass(typeof(Autodesk.Revit.DB.Mechanical.Duct))
                        .WhereElementIsNotElementType()
                        .Cast <Autodesk.Revit.DB.Mechanical.Duct>()
                        .Where(x => ids.Contains(x.Id))
                        .ToList();

            Duct[] output = new Duct[pipes.Count];

            int c = 0;

            foreach (var p in pipes)
            {
                output[c] = new Duct(p);

                c = c + 1;
            }

            Utils.Log(string.Format("Duct.ByPoints completed.", ""));

            return(output);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a pipe by curve.
        /// </summary>
        /// <param name="ductType">Type of the duct.</param>
        /// <param name="mechanicalSystemType">Type of the mechanical system.</param>
        /// <param name="level">The level.</param>
        /// <param name="curve">The curve.</param>
        /// <param name="featureline">The featureline.</param>
        /// <returns></returns>
        public static Duct ByCurveFeatureline(Revit.Elements.Element ductType, Revit.Elements.Element mechanicalSystemType, Revit.Elements.Level level, Autodesk.DesignScript.Geometry.Curve curve, Featureline featureline)
        {
            Utils.Log(string.Format("Duct.ByCurveFeatureline started...", ""));

            var totalTransform = RevitUtils.DocumentTotalTransform();

            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 start       = curve.StartPoint.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point;
            var s           = start.ToXyz();
            var end         = curve.EndPoint.Transform(totalTransform) as Autodesk.DesignScript.Geometry.Point;
            var e           = end.ToXyz();
            var l           = level.InternalElement as Autodesk.Revit.DB.Level;

            var pipe = new Duct(oType, oSystemType, s, e, l);

            var startSOE = featureline.GetStationOffsetElevationByPoint(curve.StartPoint);
            var endSOE   = featureline.GetStationOffsetElevationByPoint(curve.EndPoint);

            double startStation   = (double)startSOE["Station"];
            double startOffset    = (double)startSOE["Offset"];
            double startElevation = (double)startSOE["Elevation"];
            double endStation     = (double)endSOE["Station"];
            double endOffset      = (double)endSOE["Offset"];
            double endElevation   = (double)endSOE["Elevation"];;

            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.RegionIndex.Name, featureline.BaselineRegionIndex);                                                 // 1.1.0
            pipe.SetParameterByName(ADSK_Parameters.Instance.RegionRelative.Name, startStation - featureline.Start);                                             // 1.1.0
            pipe.SetParameterByName(ADSK_Parameters.Instance.RegionNormalized.Name, (startStation - featureline.Start) / (featureline.End - featureline.Start)); // 1.1.0
            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(curve.StartPoint.X, 3));
            pipe.SetParameterByName(ADSK_Parameters.Instance.Y.Name, Math.Round(curve.StartPoint.Y, 3));
            pipe.SetParameterByName(ADSK_Parameters.Instance.Z.Name, Math.Round(curve.StartPoint.Z, 3));
            pipe.SetParameterByName(ADSK_Parameters.Instance.Station.Name, Math.Round(startStation, 3));
            pipe.SetParameterByName(ADSK_Parameters.Instance.Offset.Name, Math.Round(startOffset, 3));
            pipe.SetParameterByName(ADSK_Parameters.Instance.Elevation.Name, Math.Round(startElevation, 3));
            pipe.SetParameterByName(ADSK_Parameters.Instance.Update.Name, 1);
            pipe.SetParameterByName(ADSK_Parameters.Instance.Delete.Name, 0);
            pipe.SetParameterByName(ADSK_Parameters.Instance.EndStation.Name, Math.Round(endStation, 3));
            pipe.SetParameterByName(ADSK_Parameters.Instance.EndOffset.Name, Math.Round(endOffset, 3));
            pipe.SetParameterByName(ADSK_Parameters.Instance.EndElevation.Name, Math.Round(endElevation, 3));
            pipe.SetParameterByName(ADSK_Parameters.Instance.EndRegionRelative.Name, endStation - featureline.Start);                                             // 1.1.0
            pipe.SetParameterByName(ADSK_Parameters.Instance.EndRegionNormalized.Name, (endStation - featureline.Start) / (featureline.End - featureline.Start)); // 1.1.0

            totalTransform.Dispose();

            Utils.Log(string.Format("Duct.ByCurveFeatureline completed.", ""));

            return(pipe);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a Conduit by revit Conduit.
        /// </summary>
        /// <param name="element">The MEP Curve from Revit</param>
        /// <returns></returns>
        public static Duct ByRevitElement(Revit.Elements.Element element)
        {
            if (element.InternalElement is Autodesk.Revit.DB.Mechanical.Duct)
            {
                var c       = element.InternalElement as Autodesk.Revit.DB.Mechanical.Duct;
                var conduit = new Duct();
                conduit.InternalSetMEPCurve(c);
                return(conduit);
            }

            return(null);
        }