Beispiel #1
0
        public static Autodesk.DesignScript.Geometry.Surface ToDSGeo(this SketchUpNET.Surface v, Transform t = null)
        {
            try
            {
                List <Autodesk.DesignScript.Geometry.Curve> curves = new List <Autodesk.DesignScript.Geometry.Curve>();
                foreach (Edge c in v.OuterEdges.Edges)
                {
                    curves.Add(c.ToDSGeo(t).ToNurbsCurve());
                }
                int a = 0;
                Autodesk.DesignScript.Geometry.PolyCurve pc = Autodesk.DesignScript.Geometry.PolyCurve.ByJoinedCurves(curves);
                Autodesk.DesignScript.Geometry.Surface   s  = Autodesk.DesignScript.Geometry.Surface.ByPatch(pc);

                List <Autodesk.DesignScript.Geometry.Surface> inner = v.InnerLoops(t);

                foreach (Autodesk.DesignScript.Geometry.Surface srf in inner)
                {
                    Autodesk.DesignScript.Geometry.Geometry[] geo = s.Split(srf);
                    if (geo.Count() == 2)
                    {
                        s = (Autodesk.DesignScript.Geometry.Surface)geo[0];
                    }
                }
                return(s);
            }
            catch { return(null); }
        }
Beispiel #2
0
        /// <summary>
        /// Converts a SketchUp Surface to a Rhino Surface
        /// </summary>
        public static Rhino.Geometry.Brep[] ToRhinoGeo(this SketchUpNET.Surface v, Transform t = null)
        {
            List <Rhino.Geometry.Curve> curves = new List <Rhino.Geometry.Curve>();
            var tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;

            foreach (SketchUpNET.Edge c in v.OuterEdges.Edges)
            {
                curves.Add(c.ToRhinoGeo(t).ToNurbsCurve());
            }

            Rhino.Geometry.Brep[] b = Rhino.Geometry.Brep.CreatePlanarBreps(curves, tol);
            if (b == null)
            {
                return new Rhino.Geometry.Brep[] { }
            }
            ;

            List <Rhino.Geometry.Brep> breps = v.InnerLoops(t);

            if (breps.Count > 0 && b.Length > 0)
            {
                Rhino.Geometry.Brep[] tmp = Rhino.Geometry.Brep.CreateBooleanDifference(b, breps, 0);

                if (tmp.Length > 0)
                {
                    return(tmp);
                }
            }

            return(b);
        }
Beispiel #3
0
        public static List <Rhino.Geometry.Brep> InnerLoops(this SketchUpNET.Surface v, Transform t = null)
        {
            List <Rhino.Geometry.Brep> breps = new List <Rhino.Geometry.Brep>();

            foreach (Loop loop in v.InnerEdges)
            {
                List <Rhino.Geometry.Curve> curves = new List <Rhino.Geometry.Curve>();
                foreach (SketchUpNET.Edge c in loop.Edges)
                {
                    curves.Add(c.ToRhinoGeo(t).ToNurbsCurve());
                }

                Rhino.Geometry.Curve[] crv = Rhino.Geometry.Curve.JoinCurves(curves);
                Rhino.Geometry.Surface b   = Rhino.Geometry.Surface.CreateExtrusion(crv[0], v.Normal.ToRhinoGeo());
                breps.Add(b.ToBrep());
            }
            return(breps);
        }
Beispiel #4
0
        public static List <Autodesk.DesignScript.Geometry.Surface> InnerLoops(this SketchUpNET.Surface v, Transform t = null)
        {
            List <Autodesk.DesignScript.Geometry.Surface> surfaces = new List <Autodesk.DesignScript.Geometry.Surface>();

            foreach (Loop loop in v.InnerEdges)
            {
                List <Autodesk.DesignScript.Geometry.Curve> curves = new List <Autodesk.DesignScript.Geometry.Curve>();
                foreach (Edge c in loop.Edges)
                {
                    curves.Add(c.ToDSGeo(t).ToNurbsCurve());
                }
                int a = 0;
                Autodesk.DesignScript.Geometry.PolyCurve pc = Autodesk.DesignScript.Geometry.PolyCurve.ByJoinedCurves(curves);
                Autodesk.DesignScript.Geometry.Surface   s  = Autodesk.DesignScript.Geometry.Surface.ByPatch(pc);
                surfaces.Add(s);
            }

            return(surfaces);
        }
Beispiel #5
0
        public static Rhino.Geometry.Brep ToRhinoGeo(this SketchUpNET.Surface v, Transform t = null)
        {
            List <Rhino.Geometry.Curve> curves = new List <Rhino.Geometry.Curve>();

            foreach (SketchUpNET.Edge c in v.OuterEdges.Edges)
            {
                curves.Add(c.ToRhinoGeo(t).ToNurbsCurve());
            }

            foreach (Loop loop in v.InnerEdges)
            {
                foreach (SketchUpNET.Edge c in loop.Edges)
                {
                    curves.Add(c.ToRhinoGeo(t).ToNurbsCurve());
                }
            }

            Rhino.Geometry.Curve[] crv = Rhino.Geometry.Curve.JoinCurves(curves);

            Rhino.Geometry.Surface b = Rhino.Geometry.Surface.CreateExtrusion(crv[0], v.Normal.ToRhinoGeo());

            List <Rhino.Geometry.Brep> breps = v.InnerLoops(t);

            Rhino.Geometry.Brep result = b.ToBrep();

            if (breps.Count > 0)
            {
                Rhino.Geometry.Brep[] tmp = Rhino.Geometry.Brep.CreateBooleanDifference(new List <Rhino.Geometry.Brep>()
                {
                    b.ToBrep()
                }, breps, 0);
                if (tmp.Length > 0)
                {
                    result = tmp[0];
                }
            }
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// Converts a SketchUp Surface InnerLoops to a Rhino Geometries
        /// </summary>
        public static List <Rhino.Geometry.Brep> InnerLoops(this SketchUpNET.Surface v, Transform t = null)
        {
            List <Rhino.Geometry.Brep> breps = new List <Rhino.Geometry.Brep>();
            var tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;

            foreach (Loop loop in v.InnerEdges)
            {
                List <Rhino.Geometry.Curve> curves = new List <Rhino.Geometry.Curve>();
                foreach (SketchUpNET.Edge c in loop.Edges)
                {
                    curves.Add(c.ToRhinoGeo(t).ToNurbsCurve());
                }
                Rhino.Geometry.Brep[] b = Rhino.Geometry.Brep.CreatePlanarBreps(curves, tol);
                if (b != null)
                {
                    foreach (var brep in b)
                    {
                        breps.Add(brep);
                    }
                }
            }
            return(breps);
        }