Пример #1
0
        public Curve NurbsToSpeckle(DB.NurbSpline revitCurve, string units = null)
        {
            var points = new List <double>();

            foreach (var p in revitCurve.CtrlPoints)
            {
                var point = PointToSpeckle(p, units);
                points.AddRange(new List <double> {
                    point.x, point.y, point.z
                });
            }

            Curve speckleCurve = new Curve();

            speckleCurve.weights = revitCurve.Weights.Cast <double>().ToList();
            speckleCurve.points  = points;
            speckleCurve.knots   = revitCurve.Knots.Cast <double>().ToList();;
            speckleCurve.degree  = revitCurve.Degree;
            //speckleCurve.periodic = revitCurve.Period;
            speckleCurve.rational = revitCurve.isRational;
            speckleCurve.closed   = RevitVersionHelper.IsCurveClosed(revitCurve);
            speckleCurve.units    = units ?? ModelUnits;
            speckleCurve.domain   = new Interval(revitCurve.GetEndParameter(0), revitCurve.GetEndParameter(1));
            speckleCurve.length   = ScaleToSpeckle(revitCurve.Length);

            var coords = revitCurve.Tessellate().SelectMany(xyz => PointToSpeckle(xyz, units).ToList()).ToList();

            speckleCurve.displayValue = new Polyline(coords, units);

            return(speckleCurve);
        }
Пример #2
0
        public Curve NurbsToSpeckle(DB.NurbSpline revitCurve, string units = null)
        {
            var points = new List <double>();

            foreach (var p in revitCurve.CtrlPoints)
            {
                var point = PointToSpeckle(p, units);
                points.AddRange(new List <double> {
                    point.x, point.y, point.z
                });
            }

            Curve speckleCurve = new Curve();

            speckleCurve.weights = revitCurve.Weights.Cast <double>().ToList();
            speckleCurve.points  = points;
            speckleCurve.knots   = revitCurve.Knots.Cast <double>().ToList();;
            speckleCurve.degree  = revitCurve.Degree;
            //speckleCurve.periodic = revitCurve.Period;
            speckleCurve.rational = revitCurve.isRational;
            speckleCurve.closed   = RevitVersionHelper.IsCurveClosed(revitCurve);
            speckleCurve.units    = units ?? ModelUnits;
            //speckleCurve.domain = new Interval(revitCurve.StartParameter(), revitCurve.EndParameter());
            speckleCurve.length = revitCurve.Length;

            return(speckleCurve);
        }
Пример #3
0
        //Nesting the various profiles into a polycurve segments
        private List <ICurve> GetProfiles(DB.RoofBase roof)
        {
            // TODO handle case if not one of our supported roofs
            var profiles = new List <ICurve>();

            switch (roof)
            {
            case FootPrintRoof footprint:
            {
                ModelCurveArrArray crvLoops = footprint.GetProfiles();

                for (var i = 0; i < crvLoops.Size; i++)
                {
                    var crvLoop = crvLoops.get_Item(i);
                    var poly    = new Polycurve(ModelUnits);
                    foreach (DB.ModelCurve curve in crvLoop)
                    {
                        if (curve == null)
                        {
                            continue;
                        }

                        var segment = CurveToSpeckle(curve.GeometryCurve) as Base; //it's a safe casting
                        segment["slopeAngle"] = GetParamValue <double>(curve, BuiltInParameter.ROOF_SLOPE);
                        segment["isSloped"]   = GetParamValue <bool>(curve, BuiltInParameter.ROOF_CURVE_IS_SLOPE_DEFINING);
                        segment["offset"]     = GetParamValue <double>(curve, BuiltInParameter.ROOF_CURVE_HEIGHT_OFFSET);
                        poly.segments.Add(segment as ICurve);

                        //roud profiles are returned duplicated!
                        if (curve is ModelArc arc && RevitVersionHelper.IsCurveClosed(arc.GeometryCurve))
                        {
                            break;
                        }
                    }
                    profiles.Add(poly);
                }

                break;
            }

            case ExtrusionRoof extrusion:
            {
                var crvloop = extrusion.GetProfile();
                var poly    = new Polycurve(ModelUnits);
                foreach (DB.ModelCurve curve in crvloop)
                {
                    if (curve == null)
                    {
                        continue;
                    }

                    poly.segments.Add(CurveToSpeckle(curve.GeometryCurve));
                }
                profiles.Add(poly);
                break;
            }
            }
            return(profiles);
        }