/// <summary> /// Convert a Nucleus PlanarSurface into a Rhino BRep /// </summary> /// <param name="surface"></param> /// <returns></returns> public static RC.Brep Convert(PlanarRegion surface) { if (surface == null || !surface.IsValid) { return(null); } else { var rCrvs = new List <RC.Curve>(); rCrvs.Add(Convert(surface.Perimeter)); if (surface.HasVoids) { foreach (Curve voidCrv in surface.Voids) { rCrvs.Add(Convert(voidCrv)); } } RC.Brep[] result = RC.Brep.CreatePlanarBreps(rCrvs); if (result == null) { result = new RC.Brep[] { RC.Brep.CreatePatch(rCrvs, 1, 1, Tolerance.Distance) }; } if (result != null && result.Length > 0) { return(result[0]); } } return(null); }
static private Rhino.Geometry.Brep SplitClosedFaces(Rhino.Geometry.Brep brep, double tolerance) { Brep brepToSplit = null; while (brepToSplit != brep && brep != null) { brep.Standardize(); brepToSplit = brep; foreach (var face in brepToSplit.Faces) { face.ShrinkFace(BrepFace.ShrinkDisableSide.ShrinkAllSides); var splittersU = face.IsClosed(0) ? face.TrimAwareIsoCurve(1, face.Domain(0).Mid) : null; var splittersV = face.IsClosed(1) ? face.TrimAwareIsoCurve(0, face.Domain(1).Mid) : null; var splittersULength = (splittersU?.Length).GetValueOrDefault(); var splittersVLength = (splittersV?.Length).GetValueOrDefault(); var splittersLength = splittersULength + splittersVLength; if (splittersLength > 0) { var splitters = new Rhino.Geometry.Curve[splittersLength]; splittersU?.CopyTo(splitters, 0); splittersV?.CopyTo(splitters, splittersULength); brep = face.Split(splitters, tolerance); if (brep == null || brep.Faces.Count == brepToSplit.Faces.Count) { return(null); } } } } return(brep); }
public List <Brep> ComputeAnchorGeometry() { Vector3d NormNormalVec = NormalVec / NormalVec.Length; Point3d A = Origin + NormNormalVec * Height1 / 2; Point3d B = Origin - NormNormalVec * Height1 / 2; Point3d C = Origin - NormNormalVec * (Height1 / 2 + Height2); List <Brep> displayGeometry = new List <Brep>(); Rhino.Geometry.Plane planea = new Rhino.Geometry.Plane(A, NormNormalVec); Rhino.Geometry.Plane planeb = new Rhino.Geometry.Plane(B, NormNormalVec); Rhino.Geometry.Plane planec = new Rhino.Geometry.Plane(C, NormNormalVec); Rhino.Geometry.Circle circlea = new Rhino.Geometry.Circle(planea, Radius2); Rhino.Geometry.Circle circleb = new Rhino.Geometry.Circle(planeb, Radius1); Rhino.Geometry.Circle circlec = new Rhino.Geometry.Circle(planec, Radius2); Rhino.Geometry.Cylinder cylindera = new Rhino.Geometry.Cylinder(circlea, Height2); Rhino.Geometry.Brep brepa = cylindera.ToBrep(true, true); displayGeometry.Add(brepa); Rhino.Geometry.Cylinder cylinderb = new Rhino.Geometry.Cylinder(circleb, Height1); Rhino.Geometry.Brep brepb = cylinderb.ToBrep(true, true); displayGeometry.Add(brepb); Rhino.Geometry.Cylinder cylinderc = new Rhino.Geometry.Cylinder(circlec, Height2); Rhino.Geometry.Brep brepc = cylinderc.ToBrep(true, true); displayGeometry.Add(brepc); return(displayGeometry); }
/// <summary> /// Convert a planar Rhino surface to a Nucleus planar region /// </summary> /// <param name="brep"></param> /// <returns></returns> public static PlanarRegion ConvertToPlanarRegion(RC.Brep brep, RC.BrepFace face) { //if (face.IsPlanar()) //{ int[] iEdges = face.AdjacentEdges(); RC.Curve[] curves = new RC.Curve[iEdges.Length]; for (int i = 0; i < iEdges.Length; i++) { RC.BrepEdge bEdge = brep.Edges[i]; curves[i] = bEdge; } var joined = RC.Curve.JoinCurves(curves); if (joined.Length > 0) { RC.Curve outer = outerCurve(joined); if (outer != null) { Curve boundary = Convert(outer); var result = new PlanarRegion(boundary); for (int i = 0; i < joined.Length; i++) { if (joined[i] != outer) { Curve voidCrv = Convert(joined[i]); result.Voids.Add(voidCrv); } } return(result); } } //} return(null); }
// edge curve convenience method private List <ICurve> GetSurfaceBrepEdges(RH.Brep brep, bool getExterior = true, bool getInterior = false, bool getBottom = false) { double tol = Doc.ModelAbsoluteTolerance * 1; RH.Curve[] brpCurves = null; if (getInterior) { brpCurves = brep.DuplicateNakedEdgeCurves(false, true); } else { brpCurves = brep.DuplicateNakedEdgeCurves(true, false); } if (getBottom) { double lowestPt = brpCurves.Min(o => o.PointAtStart.Z); brpCurves = brpCurves.Where(o => o.PointAt(0.5).Z == lowestPt).ToArray(); } List <ICurve> outCurves = null; if (brpCurves != null) { outCurves = RH.Curve.JoinCurves(brpCurves, tol).Select(o => (ICurve)ConvertToSpeckle(o)).ToList(); } return(outCurves); }
public Wall BrepToSpeckleWall(RH.Brep brep) { Wall wall = null; BoundingBox brepBox = brep.GetBoundingBox(false); double height = brepBox.Max.Z - brepBox.Min.Z; // extract height var bottomCurves = GetSurfaceBrepEdges(brep, getBottom: true); // extract baseline var intCurves = GetSurfaceBrepEdges(brep, getInterior: true); // extract openings List <Base> openings = new List <Base>(); if (intCurves != null) { foreach (ICurve crv in intCurves) { openings.Add(new Opening(crv)); } } if (bottomCurves != null && height > 0) { wall = new Wall(height, bottomCurves[0], openings) { units = ModelUnits } } ; return(wall); }
/***************************************************/ public static RHG.Surface ToRhino(this BHG.Loft loft) { if (loft == null) { return(null); } List <BHG.ICurve> bCurves = loft.Curves; if (bCurves.Count <= 1) { return(null); } List <RHG.Curve> rCurves = new List <RHG.Curve>(); for (int i = 0; i < bCurves.Count; i++) { rCurves.Add(bCurves[i].IToRhino()); } bool isClosed = bCurves[0].IIsEqual(bCurves[bCurves.Count - 1]); RHG.Brep rloft = RHG.Brep.CreateFromLoft(rCurves, RHG.Point3d.Unset, RHG.Point3d.Unset, RHG.LoftType.Normal, isClosed).FirstOrDefault(); return(rloft?.Surfaces.FirstOrDefault()); }
public static Mesh ToMesh(this rg.Brep brep) { var rgMesh = MeshCompute.CreateFromBrep(brep); var union = new rg.Mesh(); union.Append(rgMesh); return(union.ToMesh()); }
/***************************************************/ /**** Public Methods - Vectors ****/ /***************************************************/ public static bool IsPlanarSurface(this RHG.Brep brep) { bool isPlanarSurface = true; isPlanarSurface &= brep.Surfaces.All(s => s.IsPlanar(BHG.Tolerance.Distance)); isPlanarSurface &= brep.Vertices.Select(x => x.FromRhino()).ToList().IsCoplanar(); return(isPlanarSurface); }
/***************************************************/ public static RHG.GeometryBase ToRhino(this BHG.NurbsSurface surface) { if (surface == null) { return(null); } List <int> uvCount = surface.UVCount(); RHG.NurbsSurface rhSurface = RHG.NurbsSurface.Create(3, true, surface.UDegree + 1, surface.VDegree + 1, uvCount[0], uvCount[1]); for (int i = 0; i < rhSurface.KnotsU.Count; i++) { rhSurface.KnotsU[i] = surface.UKnots[i]; } for (int i = 0; i < rhSurface.KnotsV.Count; i++) { rhSurface.KnotsV[i] = surface.VKnots[i]; } for (int i = 0; i < uvCount[0]; i++) { for (int j = 0; j < uvCount[1]; j++) { rhSurface.Points.SetControlPoint(i, j, new RHG.ControlPoint(surface.ControlPoints[j + (uvCount[1] * i)].ToRhino(), surface.Weights[j + (uvCount[1] * i)])); } } if (!rhSurface.IsValid) { return(null); } if (surface.OuterTrims.Count == 0 && surface.InnerTrims.Count == 0) { return(rhSurface); } else { RHG.Brep brep = new RHG.Brep(); int srf = brep.AddSurface(rhSurface); RHG.BrepFace face = brep.Faces.Add(srf); foreach (BHG.SurfaceTrim trim in surface.OuterTrims) { brep.AddBrepTrim(face, trim, RHG.BrepLoopType.Outer); } foreach (BHG.SurfaceTrim trim in surface.InnerTrims) { brep.AddBrepTrim(face, trim, RHG.BrepLoopType.Inner); } return(brep.IsValid ? brep : null); } }
public static Parasite_BrepSurface ToParasiteType(Rhino.Geometry.Brep brep, Dictionary <string, Parameter> properties = null) { if (!brep.IsValid) { throw new ParasiteArgumentException("Please input a valid Rhino Brep!"); } List <Parasite_Point3d> vertices = brep.Vertices.Select(x => x.Location).Where(y => y.IsValid).Select(z => ToParasiteType(z)).ToList(); return(new Parasite_BrepSurface(vertices, null, properties)); }
public static Profile ToProfile(this rg.Brep brep) { if (brep.Faces.Count > 1) { return(null); } var face = brep.Faces[0]; var outer = face.OuterLoop.To3dCurve().ToPolygon(); var inner = face.Loops.Where(l => l.LoopType == rg.BrepLoopType.Inner).Select(l => l.To3dCurve().ToPolygon()).ToList(); return(new Profile(outer, inner, default(Guid), "")); }
public Roof BrepToSpeckleRoof(RH.Brep brep) { Roof roof = null; var extCurves = GetSurfaceBrepEdges(brep, getExterior: true); // extract outline var intCurves = GetSurfaceBrepEdges(brep, getInterior: true); // extract voids if (extCurves != null) { roof = new Roof(extCurves[0], intCurves); } return(roof); }
public Floor BrepToSpeckleFloor(RH.Brep brep) { Floor floor = null; var extCurves = GetSurfaceBrepEdges(brep, getExterior: true); // extract outline var intCurves = GetSurfaceBrepEdges(brep, getInterior: true); // extract voids if (extCurves != null) { floor = new Floor(extCurves[0], intCurves); } return(floor); }
public Ceiling BrepToSpeckleCeiling(RH.Brep brep) { Ceiling ceiling = null; var extCurves = GetSurfaceBrepEdges(brep, getExterior: true); // extract outline var intCurves = GetSurfaceBrepEdges(brep, getInterior: true); // extract voids if (extCurves != null) { ceiling = new Ceiling(extCurves[0], intCurves); } return(ceiling); }
/// <summary> /// Convert a Rhino BRep to a Nucleus surface /// </summary> /// <param name="brep"></param> /// <returns></returns> public static Surface Convert(RC.Brep brep) { if (brep.Faces.Count > 0) { // TODO: Convert ALL faces RC.BrepFace face = brep.Faces[0]; if (face.IsPlanar()) { return(ConvertToPlanarRegion(brep, face)); } } throw new NotImplementedException(); }
private static rg.Brep ExtrudeBrep(rg.Brep brep, rg.Vector3d dir) { if (dir.IsZero) { return(brep); } List <rg.Curve> edgeCurves = new List <rg.Curve>(); List <rg.Brep> breps; checked { int num = brep.Edges.Count - 1; for (int i = 0; i <= num; i++) { if (brep.Edges[i].TrimCount == 1) { rg.Curve item = brep.Edges[i].DuplicateCurve(); edgeCurves.Add(item); } } if (edgeCurves.Count == 0) { return(brep); } breps = new List <rg.Brep>() { brep }; int num2 = edgeCurves.Count - 1; for (int j = 0; j <= num2; j++) { rg.Surface extrusion = Rhino.Compute.SurfaceCompute.CreateExtrusion(edgeCurves[j], dir); if (extrusion != null) { rg.Brep val2 = extrusion.ToBrep(); // val2.Faces.SplitKinkyFaces(); breps.Add(val2); } } rg.Brep topFace = brep.DuplicateBrep(); topFace.Translate(dir); breps.Add(topFace); } rg.Brep[] array = Rhino.Compute.BrepCompute.JoinBreps(breps, 0.0001); if (array == null) { return(brep); } return(array[0]); }
public static bool CastBrepTo <Q>(Rhino.Geometry.Brep brep, out Q target) { if (brep != null) { if (typeof(Q).IsAssignableFrom(typeof(GH_Brep))) { var gb = new GH_Brep(brep); target = (Q)(object)gb; return(true); } } target = default(Q); return(false); }
public RV.RevitFaceWall BrepToFaceWall(RH.Brep brep, string[] args) { if (brep.Faces.Count > 1) { return(null); } string family = "Default"; string type = "Default"; try { family = args[0]; type = args[1]; } catch { } return(new RV.RevitFaceWall(family, type, BrepToSpeckle(brep), null) { units = ModelUnits }); }
/***************************************************/ public static BHG.IGeometry FromRhino(this RHG.Brep brep) { if (brep == null) { return(null); } string log; if (!brep.IsValidWithLog(out log)) { Reflection.Compute.RecordError("Conversion failed, Rhino Brep is invalid: " + log); return(null); } if (brep.Faces.Count == 0) { return(null); } if (brep.IsSolid) { return(brep.ToBHoMSolid()); } if (brep.IsPlanarSurface()) { BHG.ICurve externalEdge = RHG.Curve.JoinCurves(brep.DuplicateNakedEdgeCurves(true, false)).FirstOrDefault().FromRhino(); List <BHG.ICurve> internalEdges = RHG.Curve.JoinCurves(brep.DuplicateNakedEdgeCurves(false, true)).Select(c => c.FromRhino()).ToList(); return(new BHG.PlanarSurface(externalEdge, internalEdges)); } if (brep.Faces.Count == 1) { return(brep.Faces[0].FromRhino()); } // Default case - return open Polysurface return(new BHG.PolySurface() { Surfaces = brep.Faces.Select(s => s.FromRhino()).ToList() }); }
/***************************************************/ public static RHG.Brep ToRhino(this List <BHG.ISurface> surfaces) { RHG.Brep brep = new RHG.Brep(); for (int i = 0; i < surfaces.Count; i++) { RHG.GeometryBase geo = surfaces[i].IToRhino(); if (geo is RHG.Surface) { brep.AddSurface((RHG.Surface)geo); } else if (geo is RHG.Brep) { brep.Append((RHG.Brep)geo); } } brep.JoinNakedEdges(BHG.Tolerance.Distance); return(brep); }
/***************************************************/ public static RHG.Mesh CreatePreviewMesh(RHG.Brep brep, RHG.MeshingParameters parameters) { RHG.Mesh[] array = RHG.Mesh.CreateFromBrep(brep, parameters); if (array == null) { return(new RHG.Mesh()); } if (array.Length == 1) { return(array[0]); } RHG.Mesh mesh = new RHG.Mesh(); foreach (var faceMesh in array) { mesh.Append(faceMesh); } return(mesh); }
public RV.DirectShape BrepToDirectShape(RH.Brep brep, string[] args) { if (args.Length == 0) { return(null); } if (!Enum.TryParse($"{args[0]}s", out RV.RevitCategory category)) { return(null); } string name = "DirectShape"; try { name = args[1]; } catch { } return(new RV.DirectShape(name, category, new List <Base>() { ConvertToSpeckle(brep) }) { units = ModelUnits }); }
protected override void SolveInstance(IGH_DataAccess DA) { Rhino.Geometry.Brep brep = null; if (!DA.GetData("Surface", ref brep)) { return; } string identifier = "D"; if (!DA.GetData("Identifier", ref identifier)) { // pass } // Convert geometry Geometry.Region region = brep.FromRhino(); ModellingTools.Diaphragm obj = new ModellingTools.Diaphragm(region, identifier); DA.SetData("Diaphragm", obj); }
/***************************************************/ private static int AddVertex(this RHG.Brep brep, RHG.Point3d point) { int id = -1; for (int j = 0; j < brep.Vertices.Count; j++) { if (point.DistanceTo(brep.Vertices[j].Location) <= BHG.Tolerance.Distance) { id = j; break; } } if (id == -1) { brep.Vertices.Add(point, BHG.Tolerance.Distance); id = brep.Vertices.Count - 1; } return(id); }
// edge curve convenience method private List <ICurve> GetSurfaceBrepEdges(RH.Brep brep, bool getExterior = true, bool getInterior = false, bool getBottom = false) { double tol = Doc.ModelAbsoluteTolerance * 1; RH.Curve[] brpCurves = null; if (getInterior) { brpCurves = brep.DuplicateNakedEdgeCurves(false, true); } else { brpCurves = brep.DuplicateNakedEdgeCurves(true, false); } if (getBottom) { var bottomCrv = brpCurves. Where(o => o.IsLinear())?. Where(o => new Vector3d(o.PointAtEnd.X - o.PointAtStart.X, o.PointAtEnd.Y - o.PointAtStart.Y, o.PointAtEnd.Z - o.PointAtStart.Z).IsPerpendicularTo(Vector3d.ZAxis))?. Aggregate((curMin, o) => curMin == null || o.PointAtStart.Z < curMin.PointAtStart.Z ? o : curMin); if (bottomCrv != null) { brpCurves = new RH.Curve[] { bottomCrv } } ; } List <ICurve> outCurves = null; if (brpCurves != null && brpCurves.Count() > 0) { outCurves = (brpCurves.Count() == 1) ? new List <ICurve>() { (ICurve)ConvertToSpeckle(brpCurves[0]) } } : RH.Curve.JoinCurves(brpCurves, tol).Select(o => (ICurve)ConvertToSpeckle(o)).ToList(); return(outCurves); } } }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static BHG.ISolid ToBHoMSolid(this RHG.Brep brep) { RHG.Surface surface = brep.Surfaces.FirstOrDefault(); switch (brep.Surfaces.Count) { case 1: RHG.Sphere sphere; if (surface.TryGetSphere(out sphere)) { return(sphere.FromRhino()); } RHG.Torus torus; if (surface.TryGetTorus(out torus)) { return(torus.FromRhino()); } break; case 2: RHG.Cone cone; if (surface.TryGetCone(out cone)) { return(cone.FromRhino()); } break; case 3: RHG.Cylinder cylinder; if (surface.TryGetCylinder(out cylinder)) { return(cylinder.FromRhino()); } break; } return(new BHG.BoundaryRepresentation(brep.Faces.Select(s => s.FromRhino()).ToList(), brep.GetVolume())); }
bool Add ( DB.Document doc, DB.Document familyDoc, Rhino.Geometry.Brep brep, DeleteElementEnumerator <DB.GenericForm> forms ) { forms.MoveNext(); if (brep.ToSolid() is DB.Solid solid) { if (forms.Current is DB.FreeFormElement freeForm) { freeForm.UpdateSolidGeometry(solid); forms.DeleteCurrent = false; } else { freeForm = DB.FreeFormElement.Create(familyDoc, solid); } brep.TryGetUserString(DB.BuiltInParameter.ELEMENT_IS_CUTTING.ToString(), out bool cutting, false); freeForm.get_Parameter(DB.BuiltInParameter.ELEMENT_IS_CUTTING).Set(cutting ? 1 : 0); if (!cutting) { DB.Category familySubCategory = null; if ( brep.TryGetUserString(DB.BuiltInParameter.FAMILY_ELEM_SUBCATEGORY.ToString(), out DB.ElementId subCategoryId) && DB.Category.GetCategory(doc, subCategoryId) is DB.Category subCategory ) { if (subCategory.Parent.Id == familyDoc.OwnerFamily.FamilyCategory.Id) { familySubCategory = MapCategory(doc, familyDoc, subCategoryId, true); } else { if (subCategory.Parent is null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"'{subCategory.Name}' is not subcategory of '{familyDoc.OwnerFamily.FamilyCategory.Name}'"); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"'{subCategory.Parent.Name} : {subCategory.Name}' is not subcategory of '{familyDoc.OwnerFamily.FamilyCategory.Name}'"); } } } if (familySubCategory is null) { freeForm.get_Parameter(DB.BuiltInParameter.FAMILY_ELEM_SUBCATEGORY).Set(DB.ElementId.InvalidElementId); } else { freeForm.Subcategory = familySubCategory; } brep.TryGetUserString(DB.BuiltInParameter.IS_VISIBLE_PARAM.ToString(), out var visible, true); freeForm.get_Parameter(DB.BuiltInParameter.IS_VISIBLE_PARAM).Set(visible ? 1 : 0); brep.TryGetUserString(DB.BuiltInParameter.GEOM_VISIBILITY_PARAM.ToString(), out var visibility, 57406); freeForm.get_Parameter(DB.BuiltInParameter.GEOM_VISIBILITY_PARAM).Set(visibility); brep.TryGetUserString(DB.BuiltInParameter.MATERIAL_ID_PARAM.ToString(), out DB.ElementId materialId); var familyMaterialId = MapMaterial(doc, familyDoc, materialId, true); freeForm.get_Parameter(DB.BuiltInParameter.MATERIAL_ID_PARAM).Set(familyMaterialId); } return(cutting); } return(false); }
public void SetInputs(List <DataTree <ResthopperObject> > values) { foreach (var tree in values) { if (!_input.TryGetValue(tree.ParamName, out var inputGroup)) { continue; } if (inputGroup.AlreadySet(tree)) { Console.WriteLine("Skipping input tree... same input"); continue; } inputGroup.CacheTree(tree); inputGroup.Param.VolatileData.Clear(); inputGroup.Param.ExpireSolution(true); if (inputGroup.Param is Param_Point) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Point3d rPt = JsonConvert.DeserializeObject <Rhino.Geometry.Point3d>(restobj.Data); GH_Point data = new GH_Point(rPt); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Vector) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Vector3d rhVector = JsonConvert.DeserializeObject <Rhino.Geometry.Vector3d>(restobj.Data); GH_Vector data = new GH_Vector(rhVector); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Integer) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; int rhinoInt = JsonConvert.DeserializeObject <int>(restobj.Data); GH_Integer data = new GH_Integer(rhinoInt); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Number) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; double rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data); GH_Number data = new GH_Number(rhNumber); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_String) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; string rhString = restobj.Data; GH_String data = new GH_String(rhString); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Line) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Line rhLine = JsonConvert.DeserializeObject <Rhino.Geometry.Line>(restobj.Data); GH_Line data = new GH_Line(rhLine); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Curve) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; GH_Curve ghCurve; try { Rhino.Geometry.Polyline data = JsonConvert.DeserializeObject <Rhino.Geometry.Polyline>(restobj.Data); Rhino.Geometry.Curve c = new Rhino.Geometry.PolylineCurve(data); ghCurve = new GH_Curve(c); } catch { var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(restobj.Data); var c = (Rhino.Geometry.Curve)Rhino.Runtime.CommonObject.FromJSON(dict); ghCurve = new GH_Curve(c); } inputGroup.Param.AddVolatileData(path, i, ghCurve); } } continue; } if (inputGroup.Param is Param_Circle) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Circle rhCircle = JsonConvert.DeserializeObject <Rhino.Geometry.Circle>(restobj.Data); GH_Circle data = new GH_Circle(rhCircle); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Plane) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Plane rhPlane = JsonConvert.DeserializeObject <Rhino.Geometry.Plane>(restobj.Data); GH_Plane data = new GH_Plane(rhPlane); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Rectangle) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Rectangle3d rhRectangle = JsonConvert.DeserializeObject <Rhino.Geometry.Rectangle3d>(restobj.Data); GH_Rectangle data = new GH_Rectangle(rhRectangle); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Box) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Box rhBox = JsonConvert.DeserializeObject <Rhino.Geometry.Box>(restobj.Data); GH_Box data = new GH_Box(rhBox); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Surface) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Surface rhSurface = JsonConvert.DeserializeObject <Rhino.Geometry.Surface>(restobj.Data); GH_Surface data = new GH_Surface(rhSurface); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Brep) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Brep rhBrep = JsonConvert.DeserializeObject <Rhino.Geometry.Brep>(restobj.Data); GH_Brep data = new GH_Brep(rhBrep); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Mesh) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; Rhino.Geometry.Mesh rhMesh = JsonConvert.DeserializeObject <Rhino.Geometry.Mesh>(restobj.Data); GH_Mesh data = new GH_Mesh(rhMesh); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is GH_NumberSlider) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; double rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data); GH_Number data = new GH_Number(rhNumber); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is Param_Boolean || inputGroup.Param is GH_BooleanToggle) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; bool boolean = JsonConvert.DeserializeObject <bool>(restobj.Data); GH_Boolean data = new GH_Boolean(boolean); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } if (inputGroup.Param is GH_Panel) { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; string rhString = JsonConvert.DeserializeObject <string>(restobj.Data); GH_String data = new GH_String(rhString); inputGroup.Param.AddVolatileData(path, i, data); } } continue; } } }
public ShadeObject(Rhino.Geometry.Brep brep) : base(brep) { }