/// <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); }
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); } }
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); }