Exemple #1
0
 public static XYZ ToXYZ(this Grevit.Types.Point p, CoordinatesOverride coordoverride)
 {
     if (coordoverride != null)
     {
         return(coordoverride.ApplyOverride(p));
     }
     else
     {
         return(new XYZ(p.x * GrevitBuildModel.Scale, p.y * GrevitBuildModel.Scale, p.z * GrevitBuildModel.Scale));
     }
 }
        /// <summary>
        /// Converts a List of Grevit Curves to Revit Curves
        /// </summary>
        /// <param name="document">Active Document</param>
        /// <param name="grevitCurves">List of Grevit Curves</param>
        /// <returns>List of Revit Curves</returns>
        public static List <Curve> GrevitCurvesToRevitCurves(Component component, CoordinatesOverride coords = null)
        {
            List <Curve> curvesOut = new List <Curve>();


            if (component.GetType() == typeof(Grevit.Types.Line))
            {
                Grevit.Types.Line line = (Grevit.Types.Line)component;
                curvesOut.Add(Autodesk.Revit.DB.Line.CreateBound(line.from.ToXYZ(coords), line.to.ToXYZ(coords)));
            }
            else if (component.GetType() == typeof(Grevit.Types.Arc))
            {
                Grevit.Types.Arc arc = (Grevit.Types.Arc)component;
                curvesOut.Add(Autodesk.Revit.DB.Arc.Create(arc.center.ToXYZ(coords), arc.radius, arc.start, arc.end, XYZ.BasisX, XYZ.BasisY));
            }
            else if (component.GetType() == typeof(Grevit.Types.Curve3Points))
            {
                Grevit.Types.Curve3Points curve3points = (Grevit.Types.Curve3Points)component;
                curvesOut.Add(Autodesk.Revit.DB.Arc.Create(curve3points.a.ToXYZ(coords), curve3points.c.ToXYZ(coords), curve3points.b.ToXYZ(coords)));
            }
            else if (component.GetType() == typeof(Grevit.Types.PLine))
            {
                Grevit.Types.PLine pline = (Grevit.Types.PLine)component;

                for (int i = 0; i < pline.points.Count - 1; i++)
                {
                    curvesOut.Add(Autodesk.Revit.DB.Line.CreateBound(pline.points[i].ToXYZ(coords), pline.points[i + 1].ToXYZ(coords)));
                }
            }
            else if (component.GetType() == typeof(Spline))
            {
                Spline      spline = (Spline)component;
                IList <XYZ> points = new List <XYZ>();
                foreach (Grevit.Types.Point point in spline.controlPoints)
                {
                    points.Add(point.ToXYZ(coords));
                }
#if (Revit2015 || Revit2016 || Revit2017)
                NurbSpline ns = NurbSpline.Create(points, spline.weights);
#else
                NurbSpline ns = (NurbSpline)NurbSpline.CreateCurve(points, spline.weights);
#endif
                ns.isClosed = spline.isClosed;
                curvesOut.Add(ns);
            }


            return(curvesOut);
        }
Exemple #3
0
 public static XYZ ToXYZ(this Grevit.Types.Point p, CoordinatesOverride coordoverride)
 {
     if (coordoverride != null)
         return coordoverride.ApplyOverride(p);
     else
         return new XYZ(p.x * GrevitBuildModel.Scale, p.y * GrevitBuildModel.Scale, p.z * GrevitBuildModel.Scale);
 }
Exemple #4
0
        /// <summary>
        /// Converts a List of Grevit Curves to Revit Curves
        /// </summary>
        /// <param name="document">Active Document</param>
        /// <param name="grevitCurves">List of Grevit Curves</param>
        /// <returns>List of Revit Curves</returns>
        public static List<Curve> GrevitCurvesToRevitCurves(Component component, CoordinatesOverride coords = null)
        {
            List<Curve> curvesOut = new List<Curve>();


            if (component.GetType() == typeof(Grevit.Types.Line))
            {
                Grevit.Types.Line line = (Grevit.Types.Line)component;
                curvesOut.Add(Autodesk.Revit.DB.Line.CreateBound(line.from.ToXYZ(coords), line.to.ToXYZ(coords)));
            }
            else if (component.GetType() == typeof(Grevit.Types.Arc))
            {
                Grevit.Types.Arc arc = (Grevit.Types.Arc)component;
                curvesOut.Add(Autodesk.Revit.DB.Arc.Create(arc.center.ToXYZ(coords), arc.radius, arc.start, arc.end, XYZ.BasisX, XYZ.BasisY));
            }
            else if (component.GetType() == typeof(Grevit.Types.Curve3Points))
            {
                Grevit.Types.Curve3Points curve3points = (Grevit.Types.Curve3Points)component;
                curvesOut.Add(Autodesk.Revit.DB.Arc.Create(curve3points.a.ToXYZ(coords), curve3points.c.ToXYZ(coords), curve3points.b.ToXYZ(coords)));
            }
            else if (component.GetType() == typeof(Grevit.Types.PLine))
            {
                Grevit.Types.PLine pline = (Grevit.Types.PLine)component;

                for (int i = 0; i < pline.points.Count - 1; i++)
                {
                    curvesOut.Add(Autodesk.Revit.DB.Line.CreateBound(pline.points[i].ToXYZ(coords), pline.points[i + 1].ToXYZ(coords)));
                }
            }
            else if (component.GetType() == typeof(Spline))
            {
                Spline spline = (Spline)component;
                IList<XYZ> points = new List<XYZ>();
                foreach (Grevit.Types.Point point in spline.controlPoints) points.Add(point.ToXYZ(coords));
                NurbSpline ns = NurbSpline.Create(points, spline.weights);
                ns.isClosed = spline.isClosed;
                curvesOut.Add(ns);
            }


            return curvesOut;

        }