Esempio n. 1
0
        public XYZ PointToNative(Point pt)
        {
            var revitPoint = new XYZ(ScaleToNative(pt.x, pt.units), ScaleToNative(pt.y, pt.units), ScaleToNative(pt.z, pt.units));
            var intPt      = ToInternalCoordinates(revitPoint, true);

            return(intPt);
        }
        /// <summary>
        /// DS Point to SpecklePoint
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public Point PointToSpeckle(DS.Point pt, string units = null)
        {
            var point = new Point(pt.X, pt.Y, pt.Z, units ?? ModelUnits);

            CopyProperties(point, pt);
            return(point);
        }
        /// <summary>
        /// Speckle Point to DS Point
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        ///
        public DS.Point PointToNative(Point pt)
        {
            var point = DS.Point.ByCoordinates(
                ScaleToNative(pt.x, pt.units), ScaleToNative(pt.y, pt.units), ScaleToNative(pt.z, pt.units));

            return(point.SetDynamoProperties <DS.Point>(GetDynamicMembersFromBase(pt)));
        }
        public XYZ PointToNative(Point pt)
        {
            var revitPoint = new XYZ(ScaleToNative(pt.value[0], pt.units), ScaleToNative(pt.value[1], pt.units), ScaleToNative(pt.value[2], pt.units));
            var intPt      = ToInternalCoordinates(revitPoint);

            return(intPt);
        }
Esempio n. 5
0
        /// <summary>
        /// DS Point to SpecklePoint
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public Point PointToSpeckle(DS.Point pt)
        {
            var point = new Point(pt.X, pt.Y, pt.Z, ModelUnits);

            CopyProperties(point, pt);
            return(point);
        }
        // Rh Capture?
        public Rhino.Geometry.Point PointToNative(Point pt)
        {
            var myPoint = new Rhino.Geometry.Point(new Point3d(
                                                       ScaleToNative(pt.x, pt.units),
                                                       ScaleToNative(pt.y, pt.units),
                                                       ScaleToNative(pt.z, pt.units)));

            return(myPoint);
        }
        // Rh Capture?
        public Rhino.Geometry.Point PointToNative(Point pt)
        {
            var myPoint = new Rhino.Geometry.Point(new Point3d(
                                                       ScaleToNative(pt.value[0], pt.units),
                                                       ScaleToNative(pt.value[1], pt.units),
                                                       ScaleToNative(pt.value[2], pt.units)));

            return(myPoint);
        }
Esempio n. 8
0
        public Point PointToSpeckle(XYZ pt, string units = null)
        {
            var u              = units ?? ModelUnits;
            var extPt          = ToExternalCoordinates(pt);
            var pointToSpeckle = new Point(
                u == Units.None ? extPt.X : ScaleToSpeckle(extPt.X),
                u == Units.None ? extPt.Y : ScaleToSpeckle(extPt.Y),
                u == Units.None ? extPt.Z : ScaleToSpeckle(extPt.Z),
                u);

            return(pointToSpeckle);
        }
Esempio n. 9
0
        public XYZ[] ControlPointsToNative(List <List <ControlPoint> > controlPoints)
        {
            var uCount = controlPoints.Count;
            var vCount = controlPoints[0].Count;
            var count  = uCount * vCount;
            var points = new DB.XYZ[count];
            int p      = 0;

            controlPoints.ForEach(row =>
                                  row.ForEach(pt =>
            {
                var point   = new Point(pt.x, pt.y, pt.z, pt.units);
                points[p++] = PointToNative(point);
            }));

            return(points);
        }
Esempio n. 10
0
        public XYZ[] ArrayToPoints(IEnumerable <double> arr, string units = null)
        {
            if (arr.Count() % 3 != 0)
            {
                throw new Speckle.Core.Logging.SpeckleException("Array malformed: length%3 != 0.");
            }

            XYZ[] points  = new XYZ[arr.Count() / 3];
            var   asArray = arr.ToArray();

            for (int i = 2, k = 0; i < arr.Count(); i += 3)
            {
                var point = new Point(asArray[i - 2], asArray[i - 1], asArray[i], units);
                points[k++] = PointToNative(point);
            }

            return(points);
        }
Esempio n. 11
0
        public DB.Curve CurveToNative(Curve speckleCurve)
        {
            var pts = new List <XYZ>();

            for (int i = 0; i < speckleCurve.points.Count; i += 3)
            {
                //use PointToNative for conversion as that takes into account the Project Base Point
                var point = new Point(speckleCurve.points[i], speckleCurve.points[i + 1], speckleCurve.points[i + 2], speckleCurve.units);
                pts.Add(PointToNative(point));
            }
            try
            {
                if (speckleCurve.knots != null && speckleCurve.weights != null && speckleCurve.knots.Any() && speckleCurve.weights.Any())
                {
                    var weights      = speckleCurve.weights.GetRange(0, pts.Count);
                    var speckleKnots = new List <double>(speckleCurve.knots);
                    if (speckleKnots.Count != pts.Count + speckleCurve.degree + 1)
                    {
                        // Curve has rhino knots, repeat first and last.
                        speckleKnots.Insert(0, speckleKnots[0]);
                        speckleKnots.Add(speckleKnots[speckleKnots.Count - 1]);
                    }

                    //var knots = speckleKnots.GetRange(0, pts.Count + speckleCurve.degree + 1);
                    var curve = NurbSpline.CreateCurve(speckleCurve.degree, speckleKnots, pts, weights);
                    return(curve);
                }
                else
                {
                    var weights = speckleCurve.weights.GetRange(0, pts.Count);
                    var curve   = NurbSpline.CreateCurve(pts, weights);
                    return(curve);
                }
            }
            catch (Exception e)
            {
                if (e is Autodesk.Revit.Exceptions.ArgumentException)
                {
                    throw e;                                           // prob a closed, periodic curve
                }
                return(null);
            }
        }
        public static SpecklePoint PointToSpeckle(TopSolid.Kernel.G.D3.Point TSPoint)
        {
            SpecklePoint SpPoint = new SpecklePoint(TSPoint.X, TSPoint.Y, TSPoint.Z);

            return(SpPoint);
        }