Ejemplo n.º 1
0
        /// <summary>
        /// Create Conduits following a polycurve
        /// </summary>
        /// <param name="conduitType">The conduit type.</param>
        /// <param name="polyCurve">the Polycurve to follow.</param>
        /// <returns></returns>
        private static Conduit[] ByPolyCurve(Revit.Elements.Element conduitType, PolyCurve polyCurve)
        {
            Utils.Log(string.Format("Conduit.ByPolyCurve started...", ""));

            var oType = conduitType.InternalElement as Autodesk.Revit.DB.Electrical.ConduitType;

            IList <ElementId> ids = new List <ElementId>();

            TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);

            foreach (Autodesk.DesignScript.Geometry.Curve c in polyCurve.Curves())
            {
                Conduit ct = Conduit.ByCurve(conduitType, c);
                ids.Add(ct.InternalMEPCurve.Id);
            }

            for (int i = 0; i < GetConduitByIds(ids).Length - 1; ++i)
            {
                Conduit ct1 = GetConduitByIds(ids)[i];
                Conduit ct2 = GetConduitByIds(ids)[i + 1];
                Fitting.Elbow(ct1, ct2);
            }

            TransactionManager.Instance.TransactionTaskDone();

            Utils.Log(string.Format("Conduit.ByPolyCurve completed.", ""));

            return(GetConduitByIds(ids));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a Conduit by a curve.
        /// </summary>
        /// <param name="conduitType">Type of the conduit.</param>
        /// <param name="curve">The curve.</param>
        /// <param name="featureline">The featureline.</param>
        /// <returns></returns>
        public static Conduit ByCurveFeatureline(Revit.Elements.Element conduitType, Autodesk.DesignScript.Geometry.Curve curve, Featureline featureline)
        {
            Utils.Log(string.Format("Conduit.ByCurveFeatureline started...", ""));

            var totalTransform = RevitUtils.DocumentTotalTransform();

            if (!SessionVariables.ParametersCreated)
            {
                UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument);
            }

            var pipe = Conduit.ByCurve(conduitType, curve);  //  new Conduit(oType, s, e);

            var start = curve.StartPoint;
            var end   = curve.EndPoint;

            var startSOE = featureline.GetStationOffsetElevationByPoint(start);
            var endSOE   = featureline.GetStationOffsetElevationByPoint(end);

            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

            if (start != null)
            {
                start.Dispose();
            }
            if (end != null)
            {
                end.Dispose();
            }

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

            return(pipe);
        }