public View3D ViewToSpeckle(ViewInfo view) { // get orientation vectors var up = view.Viewport.CameraUp; var forward = view.Viewport.CameraDirection; up.Unitize(); forward.Unitize(); var _view = new View3D(); _view.name = view.Name; _view.upDirection = new Vector(up.X, up.Y, up.Z, "none"); _view.forwardDirection = new Vector(forward.X, forward.Y, forward.Z, "none"); _view.origin = PointToSpeckle(view.Viewport.CameraLocation); _view.target = PointToSpeckle(view.Viewport.TargetPoint); _view.isOrthogonal = (view.Viewport.IsParallelProjection) ? true : false; _view.units = ModelUnits; // get view bounding box var near = view.Viewport.GetNearPlaneCorners(); var far = view.Viewport.GetFarPlaneCorners(); if (near.Length > 0 && far.Length > 0) { var box = new RH.Box(new BoundingBox(near[0], far[3])); _view.boundingBox = BoxToSpeckle(box); } // attach props AttachViewParams(_view, view); return(_view); }
/// <summary> /// Initializes a new instance of the AbstractEnvironmentComponent class. /// </summary> public AxisAlignedBoxEnvironmentComponentOld() : base(RS.AABoxEnvName, RS.AABoxEnvNickName, RS.AABoxEnvDescription, RS.icon_AABoxEnvironment, RS.AABoxEnvOldGuid) { Interval interval = new Interval(-RS.boxBoundsDefault, RS.boxBoundsDefault); box = new Box(Plane.WorldXY, interval, interval, interval); }
public Mesh Metaball(double iso) { this.use_iso = iso; Plane plane = new Plane(); Plane.FitPlaneToPoints(use_charges, out plane); plane.Origin = use_charges[0]; Interval xSize = new Interval(-use_radii[0], use_radii[0]); Box box = new Box(plane, xSize, xSize, xSize); int num27 = use_charges.Count - 1; for (int i = 1; i <= num27; i++) { plane.Origin = use_charges[i]; box.Union(plane.PointAt(-use_radii[i], -use_radii[i], -use_radii[i])); box.Union(plane.PointAt(use_radii[i], use_radii[i], use_radii[i])); } box.Inflate(res); int xSet = (int)Math.Round((double)(box.X.Length / res)); int ySet = (int)Math.Round((double)(box.Y.Length / res)); int zSet = (int)Math.Round((double)(box.Z.Length / res)); double xLength = box.X.Length / ((double)xSet); double yLength = box.Y.Length / ((double)ySet); double zLength = box.Z.Length / ((double)zSet); double xBase = xLength / 2.0; double yBase = yLength / 2.0; double zBase = zLength / 2.0; plane.Origin = box.GetCorners()[0]; List<Point3d> list = new List<Point3d>(); Mesh mesh = new Mesh(); for (int j = 0; j <= xSet - 1; j++) { for (int m = 0; m <= ySet - 1; m++) { for (int n = 0; n <= zSet - 1; n++) { Point3d item = plane.PointAt(xBase + (xLength * j), yBase + (yLength * m), zBase + (zLength * n)); int xSet1 = use_charges.Count - 1; for (int k = 0; k <= xSet1; k++) { if (item.DistanceTo(use_charges[k]) < (use_radii[k] + res)) { Plane pl = plane; pl.Origin = item; Mesh other = this.local_tet(pl, xBase, yBase, zBase); mesh.Append(other); list.Add(item); break; } } } } } mesh.Vertices.CombineIdentical(true, true); mesh.UnifyNormals(); return mesh; }
// Copy Constructor public AxisAlignedBoxEnvironmentType(AxisAlignedBoxEnvironmentType environment) { this.environment = environment.environment; this.Wrap = environment.Wrap; minX = environment.minX; maxX = environment.maxX; minY = environment.minY; maxY = environment.maxY; minZ = environment.minZ; maxZ = environment.maxZ; Width = maxX - minX; Height = maxY - minY; Depth = maxZ - minZ; }
// Constructor with initial values. public AxisAlignedBoxEnvironmentType(Box box, bool wrap) { environment = box; Wrap = wrap; BoundingBox boundingBox = environment.BoundingBox; minX = boundingBox.Corner(true, false, false).X; maxX = boundingBox.Corner(false, false, false).X; minY = boundingBox.Corner(false, true, false).Y; maxY = boundingBox.Corner(false, false, false).Y; minZ = boundingBox.Corner(false, false, true).Z; maxZ = boundingBox.Corner(false, false, false).Z; Width = maxX - minX; Height = maxY - minY; Depth = maxZ - minZ; }
// Default Constructor. Defaults to continuous flow, creating a new Agent every timestep. public AxisAlignedBoxEnvironmentType() { Interval interval = new Interval(-RS.boxBoundsDefault, RS.boxBoundsDefault); environment = new Box(Plane.WorldXY, interval, interval, interval); BoundingBox boundingBox = environment.BoundingBox; minX = boundingBox.Corner(true, false, false).X; maxX = boundingBox.Corner(false, false, false).X; minY = boundingBox.Corner(false, true, false).Y; maxY = boundingBox.Corner(false, false, false).Y; minZ = boundingBox.Corner(false, false, true).Z; maxZ = boundingBox.Corner(false, false, false).Z; Width = maxX - minX; Height = maxY - minY; Depth = maxZ - minZ; }
protected override void DrawForeground(Rhino.Display.DrawEventArgs e) { if (Recs != null) e.Display.DrawPointCloud(Srcs, 5, System.Drawing.Color.Green); if (Srcs != null) e.Display.DrawPointCloud(Srcs, 5, System.Drawing.Color.Red); if (Dir != null) e.Display.DrawLineArrow(Dir, System.Drawing.Color.Red, 3, .1); if (Reflections != null) foreach (Rhino.Geometry.Polyline L in Reflections) e.Display.DrawDottedPolyline(L.AsEnumerable<Point3d>(), System.Drawing.Color.GreenYellow, false); if (Speakers != null) foreach (Rhino.Geometry.Line Sp in Speakers) { //TODO: Draw Speaker Cabinets, for clarity. Rhino.Geometry.Box BB = new Box(new Rhino.Geometry.Plane(Sp.From, Sp.UnitTangent), new BoundingBox(-.125, -.15, -.18, .125, .15, .18)); e.Display.DrawBox(BB, System.Drawing.Color.Blue); e.Display.DrawLineArrow(Sp, System.Drawing.Color.Blue, 1, .05); } }
/***************************************************/ public static RHG.Mesh CreatePreviewMesh(RHG.Box box, RHG.MeshingParameters parameters) { return(CreatePreviewMesh(box.ToBrep(), parameters)); }
/// <summary> /// Test a box for Box inclusion. /// </summary> /// <param name="box">Box to test.</param> /// <param name="strict">If true, the box needs to be fully on the inside of this Box. /// I.e. coincident boxes will be considered 'outside'.</param> /// <returns>true if the box is (strictly) on the inside of this Box.</returns> public bool Contains(Box box, bool strict) { if (!box.IsValid) { return false; } Point3d[] c = box.GetCorners(); for (int i = 0; i < c.Length; i++) { if (!Contains(c[i], strict)) { return false; } } return true; }
//Breps Open or Closed public void BrepSlice(bool overhangregions) { bool horizontalslices = true; #region Check if Planes are Horizontal int untrue = 0; foreach (Plane sliceplane in slicePlanes) { if (sliceplane.ZAxis != Plane.WorldXY.ZAxis) { untrue += 1; } } if (untrue > 0) { horizontalslices = false; WarningMessages.Add("Slice Planes are not aligned with World Z Axis (horizontal), some slicing options will be unavailable"); } #endregion double layerHeight = layerOffset; int perimeters = Shell; double offsetDistance = perimeters * crossSec; BoundingBox b_box = bboxAll(Breps); Box bbox = new Box(Plane.WorldXY, b_box); if (slicePlanes.Count<2 && horizontalslices) { int noLevels = (int)Math.Round((bbox.Z.Max / layerHeight), 0); for (int i = 1; i < noLevels; i++) { Point3d zPt = new Point3d(0, 0, i * layerHeight); Plane zPlane = new Plane(zPt, Plane.WorldXY.ZAxis); slicePlanes.Add(zPlane); } } //Regions List<Curve>[] openregions = new List<Curve>[slicePlanes.Count]; List<Brep>[] regions = new List<Brep>[slicePlanes.Count]; List<Brep>[] r_PerimeterR = new List<Brep>[slicePlanes.Count]; List<Brep>[] r_InfillR = new List<Brep>[slicePlanes.Count]; //List<Brep>[] r_BridgesR = new List<Brep>[slicePlanes.Count]; //List<Brep>[] r_OverhangsR = new List<Brep>[slicePlanes.Count]; if (validPosition(Configuration, bbox)) { for (int j = 0; j < slicePlanes.Count; j++) { List<Curve> openR = new List<Curve>(); List<Brep> regionsR = new List<Brep>(); List<Brep> r_PerR = new List<Brep>(); List<Brep> r_InfR = new List<Brep>(); //List<Brep> r_BrdgR = new List<Brep>(); //List<Brep> r_OverhgR = new List<Brep>(); #region Slice SliceUnionRegions(Breps, slicePlanes[j], out regionsR, out openR); #endregion #region Skein Region if (Shell > 0 && horizontalslices) { foreach (Brep reg in regionsR) { Boolean isClosed = false; List<Curve> offsetloops = new List<Curve>(); //List<Curve> aloops = (reg.DuplicateEdgeCurves(true).ToList()); //List<Curve> loops = Curve.JoinCurves(aloops,Tolerance, true).ToList(); var loops = reg.Loops; #region Divide into Regions #region Find Perimiter Regions foreach (BrepLoop iloop in loops) { Curve loop = iloop.To3dCurve(); Plane frame = horizFrame(loop, 0.5); List<Curve> offLoops = new List<Curve>(); for (int o = 1; o <= perimeters; o++) { if (loop.Offset(frame, (crossSec * o), Tolerance, CurveOffsetCornerStyle.Sharp) == null) { break; } offLoops = loop.Offset(frame, (crossSec * o), Tolerance, CurveOffsetCornerStyle.Sharp).ToList(); } if (offLoops.Count > 1) { List<Curve> joinLoops = Curve.JoinCurves(offLoops, Tolerance, true).ToList(); offsetloops.AddRange(joinLoops); } else if (offLoops.Count == 1) { offsetloops.AddRange(offLoops); } else { WarningMessages.Add("Object contains elements that are too small to slice. Try a smaller nozzle."); continue; } } #endregion //Create Perimeter Skin Region if (!(offsetloops.Count < 1)) { for (int l = 0; l < loops.Count; l++) { Curve loop = loops[l].To3dCurve(); if (loop.IsClosed && offsetloops[l].IsClosed) { isClosed = (loop.IsClosed && offsetloops[l].IsClosed); List<Curve> perHatch = new List<Curve>(); if (loops[l].LoopType == BrepLoopType.Inner) { loop.Reverse(); offsetloops[l].Reverse(); } perHatch.Add(loop); perHatch.Add(offsetloops[l]); r_PerR.AddRange(Brep.CreatePlanarBreps(perHatch).ToList()); } else { continue; } } #endregion } r_InfR.AddRange(Brep.CreatePlanarBreps(offsetloops).ToList()); } //TODO other region detection r_PerimeterR[j] = r_PerR; r_InfillR[j] = r_InfR; } else if (overhangregions && horizontalslices) { continue; } //Otherwise just add undivided regions else { regions[j] = regionsR; } openregions[j] = openR; #endregion } } openRegions = openregions; Regions = regions; regionPerimeter = r_PerimeterR; regionInfill = r_InfillR; //regionBridges = r_BridgesR; //regionOverhangs = r_OverhangsR; }
public bool validPosition(Dictionary<string, string> Settings, Box bbox) { //Check if bounding box of an object is within a specific 3d domain. Interval xDomain = new Interval(0, 200); Interval yDomain = new Interval(0, 200); Interval zDomain = new Interval(0, 125); if (xDomain.IncludesInterval(bbox.X) && yDomain.IncludesInterval(bbox.Y) && zDomain.IncludesInterval(bbox.Z)) { if (!(zDomain.Min == bbox.Z.Min)) { ErrorMessages.Add("Object is not Aligned with PrintBed!"); return validZ = false; } return validPos = true; } else { ErrorMessages.Add("Object is outside of Printable Area!"); } return validPos = false; }
/// <summary> /// Draws the edges of a Box object. /// </summary> /// <param name="box">Box to draw.</param> /// <param name="color">Color to draw in.</param> public void DrawBox(Box box, System.Drawing.Color color) { DrawBox(box, color, 1); }
/***************************************************/ public static BHG.BoundingBox FromRhino(this RHG.Box box) { return(box.BoundingBox.FromRhino()); }
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)) { LogDebug("Skipping input tree... same input"); continue; } inputGroup.CacheTree(tree); IGH_ContextualParameter contextualParameter = inputGroup.Param as IGH_ContextualParameter; if (contextualParameter != null) { switch (ParamTypeName(inputGroup.Param)) { case "Number": { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { double[] doubles = new double[entree.Value.Count]; for (int i = 0; i < doubles.Length; i++) { ResthopperObject restobj = entree.Value[i]; doubles[i] = JsonConvert.DeserializeObject <double>(restobj.Data); } contextualParameter.AssignContextualData(doubles); break; } } break; case "Integer": { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { int[] integers = new int[entree.Value.Count]; for (int i = 0; i < integers.Length; i++) { ResthopperObject restobj = entree.Value[i]; integers[i] = JsonConvert.DeserializeObject <int>(restobj.Data); } contextualParameter.AssignContextualData(integers); break; } } break; case "Point": { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { Point3d[] points = new Point3d[entree.Value.Count]; for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; points[i] = JsonConvert.DeserializeObject <Rhino.Geometry.Point3d>(restobj.Data); } contextualParameter.AssignContextualData(points); break; } } break; case "Line": { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { Line[] lines = new Line[entree.Value.Count]; for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; lines[i] = JsonConvert.DeserializeObject <Rhino.Geometry.Line>(restobj.Data); } contextualParameter.AssignContextualData(lines); break; } } break; case "Text": { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { string[] strings = new string[entree.Value.Count]; for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; strings[i] = restobj.Data.Trim(new char[] { '"' }); } contextualParameter.AssignContextualData(strings); break; } } break; case "Geometry": { foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GeometryBase[] geometries = new GeometryBase[entree.Value.Count]; for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(restobj.Data); geometries[i] = Rhino.Runtime.CommonObject.FromJSON(dict) as GeometryBase; } contextualParameter.AssignContextualData(geometries); break; } } break; } continue; } inputGroup.Param.VolatileData.Clear(); inputGroup.Param.ExpireSolution(false); // mark param as expired but don't recompute just yet! 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 static Response Grasshopper(NancyContext ctx) { // load grasshopper file var archive = new GH_Archive(); // TODO: stream to string var body = ctx.Request.Body.ToString(); string json = string.Empty; using (var reader = new StreamReader(ctx.Request.Body)) { json = reader.ReadToEnd(); } //GrasshopperInput input = Newtonsoft.Json.JsonConvert.DeserializeObject<GrasshopperInput>(json); //JsonSerializerSettings settings = new JsonSerializerSettings(); //settings.ContractResolver = new DictionaryAsArrayResolver(); Schema input = JsonConvert.DeserializeObject <Schema>(json); string grasshopperXml = string.Empty; if (input.Algo != null) { // If request contains markup byte[] byteArray = Convert.FromBase64String(input.Algo); grasshopperXml = System.Text.Encoding.UTF8.GetString(byteArray); } else { // If request contains pointer string pointer = input.Pointer; grasshopperXml = GetGhxFromPointer(pointer); } if (!archive.Deserialize_Xml(grasshopperXml)) { throw new Exception(); } var definition = new GH_Document(); if (!archive.ExtractObject(definition, "Definition")) { throw new Exception(); } // Set input params foreach (var obj in definition.Objects) { var group = obj as GH_Group; if (group == null) { continue; } if (group.NickName.Contains("RH_IN")) { // It is a RestHopper input group! GHTypeCodes code = (GHTypeCodes)Int32.Parse(group.NickName.Split(':')[1]); var param = group.Objects()[0]; //GH_Param<IGH_Goo> goo = obj as GH_Param<IGH_Goo>; // SetData foreach (Resthopper.IO.DataTree <ResthopperObject> tree in input.Values) { string paramname = tree.ParamName; if (group.NickName == paramname) { switch (code) { case GHTypeCodes.Boolean: //PopulateParam<GH_Boolean>(goo, tree); Param_Boolean boolParam = param as Param_Boolean; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Boolean> objectList = new List <GH_Boolean>(); 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); boolParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Point: //PopulateParam<GH_Point>(goo, tree); Param_Point ptParam = param as Param_Point; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Point> objectList = new List <GH_Point>(); 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); ptParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Vector: //PopulateParam<GH_Vector>(goo, tree); Param_Vector vectorParam = param as Param_Vector; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Vector> objectList = new List <GH_Vector>(); 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); vectorParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Integer: //PopulateParam<GH_Integer>(goo, tree); Param_Integer integerParam = param as Param_Integer; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Integer> objectList = new List <GH_Integer>(); 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); integerParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Number: //PopulateParam<GH_Number>(goo, tree); Param_Number numberParam = param as Param_Number; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Number> objectList = new List <GH_Number>(); 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); numberParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Text: //PopulateParam<GH_String>(goo, tree); Param_String stringParam = param as Param_String; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_String> objectList = new List <GH_String>(); 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); stringParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Line: //PopulateParam<GH_Line>(goo, tree); Param_Line lineParam = param as Param_Line; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Line> objectList = new List <GH_Line>(); 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); lineParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Curve: //PopulateParam<GH_Curve>(goo, tree); Param_Curve curveParam = param as Param_Curve; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Curve> objectList = new List <GH_Curve>(); 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 { Rhino.Geometry.NurbsCurve data = JsonConvert.DeserializeObject <Rhino.Geometry.NurbsCurve>(restobj.Data); Rhino.Geometry.Curve c = new Rhino.Geometry.NurbsCurve(data); ghCurve = new GH_Curve(c); } curveParam.AddVolatileData(path, i, ghCurve); } } break; case GHTypeCodes.Circle: //PopulateParam<GH_Circle>(goo, tree); Param_Circle circleParam = param as Param_Circle; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Circle> objectList = new List <GH_Circle>(); 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); circleParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.PLane: //PopulateParam<GH_Plane>(goo, tree); Param_Plane planeParam = param as Param_Plane; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Plane> objectList = new List <GH_Plane>(); 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); planeParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Rectangle: //PopulateParam<GH_Rectangle>(goo, tree); Param_Rectangle rectangleParam = param as Param_Rectangle; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Rectangle> objectList = new List <GH_Rectangle>(); 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); rectangleParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Box: //PopulateParam<GH_Box>(goo, tree); Param_Box boxParam = param as Param_Box; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Box> objectList = new List <GH_Box>(); 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); boxParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Surface: //PopulateParam<GH_Surface>(goo, tree); Param_Surface surfaceParam = param as Param_Surface; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Surface> objectList = new List <GH_Surface>(); 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); surfaceParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Brep: //PopulateParam<GH_Brep>(goo, tree); Param_Brep brepParam = param as Param_Brep; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Brep> objectList = new List <GH_Brep>(); 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); brepParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Mesh: //PopulateParam<GH_Mesh>(goo, tree); Param_Mesh meshParam = param as Param_Mesh; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Mesh> objectList = new List <GH_Mesh>(); 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); meshParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Slider: //PopulateParam<GH_Number>(goo, tree); GH_NumberSlider sliderParam = param as GH_NumberSlider; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Number> objectList = new List <GH_Number>(); 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); sliderParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.BooleanToggle: //PopulateParam<GH_Boolean>(goo, tree); GH_BooleanToggle toggleParam = param as GH_BooleanToggle; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Boolean> objectList = new List <GH_Boolean>(); for (int i = 0; i < entree.Value.Count; i++) { ResthopperObject restobj = entree.Value[i]; bool rhBoolean = JsonConvert.DeserializeObject <bool>(restobj.Data); GH_Boolean data = new GH_Boolean(rhBoolean); toggleParam.AddVolatileData(path, i, data); } } break; case GHTypeCodes.Panel: //PopulateParam<GH_String>(goo, tree); GH_Panel panelParam = param as GH_Panel; foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree) { GH_Path path = new GH_Path(GhPath.FromString(entree.Key)); List <GH_Panel> objectList = new List <GH_Panel>(); 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); panelParam.AddVolatileData(path, i, data); } } break; } } } } } Schema OutputSchema = new Schema(); OutputSchema.Algo = Utils.Base64Encode(string.Empty); // Parse output params foreach (var obj in definition.Objects) { var group = obj as GH_Group; if (group == null) { continue; } if (group.NickName.Contains("RH_OUT")) { // It is a RestHopper output group! GHTypeCodes code = (GHTypeCodes)Int32.Parse(group.NickName.Split(':')[1]); var param = group.Objects()[0] as IGH_Param; if (param == null) { continue; } try { param.CollectData(); param.ComputeData(); } catch (Exception) { param.Phase = GH_SolutionPhase.Failed; // TODO: throw something better throw; } // Get data Resthopper.IO.DataTree <ResthopperObject> OutputTree = new Resthopper.IO.DataTree <ResthopperObject>(); OutputTree.ParamName = group.NickName; var volatileData = param.VolatileData; for (int p = 0; p < volatileData.PathCount; p++) { List <ResthopperObject> ResthopperObjectList = new List <ResthopperObject>(); foreach (var goo in volatileData.get_Branch(p)) { if (goo == null) { continue; } else if (goo.GetType() == typeof(GH_Boolean)) { GH_Boolean ghValue = goo as GH_Boolean; bool rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <bool>(rhValue)); } else if (goo.GetType() == typeof(GH_Point)) { GH_Point ghValue = goo as GH_Point; Point3d rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Point3d>(rhValue)); } else if (goo.GetType() == typeof(GH_Vector)) { GH_Vector ghValue = goo as GH_Vector; Vector3d rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Vector3d>(rhValue)); } else if (goo.GetType() == typeof(GH_Integer)) { GH_Integer ghValue = goo as GH_Integer; int rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <int>(rhValue)); } else if (goo.GetType() == typeof(GH_Number)) { GH_Number ghValue = goo as GH_Number; double rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <double>(rhValue)); } else if (goo.GetType() == typeof(GH_String)) { GH_String ghValue = goo as GH_String; string rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <string>(rhValue)); } else if (goo.GetType() == typeof(GH_Line)) { GH_Line ghValue = goo as GH_Line; Line rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Line>(rhValue)); } else if (goo.GetType() == typeof(GH_Curve)) { GH_Curve ghValue = goo as GH_Curve; Curve rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Curve>(rhValue)); } else if (goo.GetType() == typeof(GH_Circle)) { GH_Circle ghValue = goo as GH_Circle; Circle rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Circle>(rhValue)); } else if (goo.GetType() == typeof(GH_Plane)) { GH_Plane ghValue = goo as GH_Plane; Plane rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Plane>(rhValue)); } else if (goo.GetType() == typeof(GH_Rectangle)) { GH_Rectangle ghValue = goo as GH_Rectangle; Rectangle3d rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Rectangle3d>(rhValue)); } else if (goo.GetType() == typeof(GH_Box)) { GH_Box ghValue = goo as GH_Box; Box rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Box>(rhValue)); } else if (goo.GetType() == typeof(GH_Surface)) { GH_Surface ghValue = goo as GH_Surface; Brep rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Brep>(rhValue)); } else if (goo.GetType() == typeof(GH_Brep)) { GH_Brep ghValue = goo as GH_Brep; Brep rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Brep>(rhValue)); } else if (goo.GetType() == typeof(GH_Mesh)) { GH_Mesh ghValue = goo as GH_Mesh; Mesh rhValue = ghValue.Value; ResthopperObjectList.Add(GetResthopperObject <Mesh>(rhValue)); } } GhPath path = new GhPath(new int[] { p }); OutputTree.Add(path.ToString(), ResthopperObjectList); } OutputSchema.Values.Add(OutputTree); } } if (OutputSchema.Values.Count < 1) { throw new System.Exceptions.PayAttentionException("Looks like you've missed something..."); // TODO } string returnJson = JsonConvert.SerializeObject(OutputSchema); return(returnJson); }
/// <summary> /// Asks the user to select a Box in the viewport. /// </summary> /// <param name="box">If the result is Success, this parameter will be filled out.</param> /// <param name="mode">A particular "get box" mode, or <see cref="GetBoxMode.All"/>.</param> /// <param name="basePoint">Optional base point. Supply Point3d.Unset if you don't want to use this.</param> /// <param name="prompt1">Optional first prompt. Supply null to use the default prompt.</param> /// <param name="prompt2">Optional second prompt. Supply null to use the default prompt.</param> /// <param name="prompt3">Optional third prompt. Supply null to use the default prompt.</param> /// <returns>Commands.Result.Success if successful.</returns> public static Commands.Result GetBox(out Rhino.Geometry.Box box, GetBoxMode mode, Point3d basePoint, string prompt1, string prompt2, string prompt3) { Point3d[] corners = new Point3d[8]; // 19 Feb 2010 S. Baer // On Win x64 builds the .NET framework appears to have problems if you don't initialize the array // before passing it off to unmanaged code. for (int i = 0; i < corners.Length; i++) corners[i] = new Point3d(); Rhino.Commands.Result rc = (Rhino.Commands.Result)UnsafeNativeMethods.RHC_RhinoGetBox(corners, (int)mode, basePoint, prompt1, prompt2, prompt3); // David: This code is untested. box = new Box(); if (rc == Rhino.Commands.Result.Success) { Vector3d x = corners[1] - corners[0]; Vector3d y = corners[3] - corners[0]; Vector3d z = corners[4] - corners[0]; // Create a singular box. if (x.IsZero && y.IsZero && z.IsZero) { box = new Box(new Plane(corners[0], new Vector3d(0, 0, 1)), new Interval(), new Interval(), new Interval()); return rc; } // Create a linear box. if (x.IsZero && y.IsZero) { box = new Box(new Plane(corners[0], z), new Interval(), new Interval(), new Interval(0, z.Length)); return rc; } // Boxes were getting inverted if the "height" pick was on the negative side of the base plane. Plane base_plane = new Plane(corners[0], x, y); Point3d C0, C1; base_plane.RemapToPlaneSpace(corners[0], out C0); base_plane.RemapToPlaneSpace(corners[6], out C1); Interval ix = new Interval(C0.X, C1.X); ix.MakeIncreasing(); Interval iy = new Interval(C0.Y, C1.Y); iy.MakeIncreasing(); Interval iz = new Interval(C0.Z, C1.Z); iz.MakeIncreasing(); box = new Box(base_plane, ix, iy, iz); } return rc; }
/// <summary> /// Call this method to get a box at the specified index. /// </summary> /// <param name="index"> /// The zero based index of the item in the list. Valid values are greater /// than or equal to 0 and less than Count. /// </param> /// <param name="box"> /// Will contain the box at the requested index if the index is in range /// and the primitive at the requested index is a box. /// </param> /// <returns> /// Return true if the index is in range and the primitive at the requested /// index is a box otherwise returns false. /// </returns> public bool TryGetBox(int index, out Box box) { var origin = new Point3d(); var xaxis = new Vector3d(); var yaxis = new Vector3d(); var min_x = 0.0; var max_x = 0.0; var min_y = 0.0; var max_y = 0.0; var min_z = 0.0; var max_z = 0.0; if (UnsafeNativeMethods.Rdk_CustomMeshes_Box(ConstPointer(), index, ref origin, ref xaxis, ref yaxis, ref min_x, ref max_x, ref min_y, ref max_y, ref min_z, ref max_z)) { box = new Box(new Plane(origin, xaxis, yaxis), new Interval(min_x, max_x), new Interval(min_y, max_y), new Interval(min_z, max_z)); return true; } box = new Box(); return false; }
/// <summary> /// Add primitive box and material. /// </summary> /// <param name="box">Box to add.</param> /// <param name="material"> /// Material to add, may be null if not needed. /// </param> public void Add(Box box, RenderMaterial material) { var material_pointer = (null == material ? IntPtr.Zero : material.ConstPointer()); var pointer = NonConstPointer(); UnsafeNativeMethods.Rdk_CustomMeshes_AddBox(pointer, box.Plane.Origin, box.Plane.XAxis, box.Plane.YAxis, box.X.Min, box.X.Max, box.Y.Min, box.Y.Max, box.Z.Min, box.Z.Max, material_pointer); }
/***************************************************/ public static void RenderRhinoWires(RHG.Box box, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawBox(box, bhColour, thickness); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { ObjRef obj_ref; var rc = RhinoGet.GetOneObject( "Select surface to split", true, ObjectType.Surface, out obj_ref); if (rc != Result.Success) return rc; var surface = obj_ref.Surface(); if (surface == null) return Result.Failure; obj_ref = null; rc = RhinoGet.GetOneObject( "Select cutting curve", true, ObjectType.Curve, out obj_ref); if (rc != Result.Success) return rc; var curve = obj_ref.Curve(); if (curve == null) return Result.Failure; var brep_face = surface as BrepFace; if (brep_face == null) return Result.Failure; var split_brep = brep_face.Split( new List<Curve> {curve}, doc.ModelAbsoluteTolerance); if (split_brep == null) { RhinoApp.WriteLine("Unable to split surface."); return Result.Nothing; } var meshes = Mesh.CreateFromBrep(split_brep); foreach (var mesh in meshes) { var bbox = mesh.GetBoundingBox(true); switch (bbox.IsDegenerate(doc.ModelAbsoluteTolerance)) { case 3: case 2: return Result.Failure; case 1: // rectangle // box with 8 corners flattened to rectangle with 4 corners var rectangle_corners = bbox.GetCorners().Distinct().ToList(); // add 1st point as last to close the loop rectangle_corners.Add(rectangle_corners[0]); doc.Objects.AddPolyline(rectangle_corners); doc.Views.Redraw(); break; case 0: // box var brep_box = new Box(bbox).ToBrep(); doc.Objects.AddBrep(brep_box); doc.Views.Redraw(); break; } } return Result.Success; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // 1. Retrieve and validate data var cell = new UnitCell(); GeometryBase designSpace = null; Plane orientationPlane = Plane.Unset; double xCellSize = 0; double yCellSize = 0; double zCellSize = 0; double minLength = 0; // the trim tolerance (i.e. minimum strut length) double maxLength = 0; bool strictlyIn = false; if (!DA.GetData(0, ref cell)) { return; } if (!DA.GetData(1, ref designSpace)) { return; } if (!DA.GetData(2, ref orientationPlane)) { return; } if (!DA.GetData(3, ref xCellSize)) { return; } if (!DA.GetData(4, ref yCellSize)) { return; } if (!DA.GetData(5, ref zCellSize)) { return; } if (!DA.GetData(6, ref minLength)) { return; } if (!DA.GetData(7, ref maxLength)) { return; } if (!DA.GetData(8, ref strictlyIn)) { return; } if (!cell.isValid) { return; } if (!designSpace.IsValid) { return; } if (!orientationPlane.IsValid) { return; } if (xCellSize == 0) { return; } if (yCellSize == 0) { return; } if (zCellSize == 0) { return; } if (minLength>=xCellSize || minLength>=yCellSize || minLength>=zCellSize) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Tolerance parameter cannot be larger than the unit cell dimensions."); return; } // 2. Validate the design space int spaceType = FrameTools.ValidateSpace(ref designSpace); if (spaceType == 0) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Design space must be a closed Brep, Mesh or Surface"); return; } double tol = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance; // 3. Compute oriented bounding box and its corner points Box bBox = new Box(); designSpace.GetBoundingBox(orientationPlane, out bBox); Point3d[] bBoxCorners = bBox.GetCorners(); // Set basePlane based on the bounding box Plane basePlane = new Plane(bBoxCorners[0], bBoxCorners[1], bBoxCorners[3]); // 4. Determine number of iterations required to fill the box, and package into array double xLength = bBoxCorners[0].DistanceTo(bBoxCorners[1]); double yLength = bBoxCorners[0].DistanceTo(bBoxCorners[3]); double zLength = bBoxCorners[0].DistanceTo(bBoxCorners[4]); int nX = (int)Math.Ceiling(xLength / xCellSize); // Roundup to next integer if non-integer int nY = (int)Math.Ceiling(yLength / yCellSize); int nZ = (int)Math.Ceiling(zLength / zCellSize); float[] N = new float[3] { nX, nY, nZ }; // 5. Initialize nodeTree var lattice = new Lattice(); // 6. Prepare cell (this is a UnitCell object) cell = cell.Duplicate(); cell.FormatTopology(); // 7. Define iteration vectors in each direction (accounting for Cell Size) Vector3d vectorU = xCellSize * basePlane.XAxis; Vector3d vectorV = yCellSize * basePlane.YAxis; Vector3d vectorW = zCellSize * basePlane.ZAxis; // 8. Map nodes to design space // Loop through the uvw cell grid for (int u = 0; u <= N[0]; u++) { for (int v = 0; v <= N[1]; v++) { for (int w = 0; w <= N[2]; w++) { // Construct cell path in tree GH_Path treePath = new GH_Path(u, v, w); // Fetch the list of nodes to append to, or initialise it var nodeList = lattice.Nodes.EnsurePath(treePath); // This loop maps each node in the cell for (int i = 0; i < cell.Nodes.Count; i++) { double usub = cell.Nodes[i].X; // u-position within unit cell (local) double vsub = cell.Nodes[i].Y; // v-position within unit cell (local) double wsub = cell.Nodes[i].Z; // w-position within unit cell (local) double[] uvw = { u + usub, v + vsub, w + wsub }; // uvw-position (global) // Check if the node belongs to another cell (i.e. it's relative path points outside the current cell) bool isOutsideCell = (cell.NodePaths[i][0] > 0 || cell.NodePaths[i][1] > 0 || cell.NodePaths[i][2] > 0); // Check if current uvw-position is beyond the upper boundary bool isOutsideSpace = (uvw[0] > N[0] || uvw[1] > N[1] || uvw[2] > N[2]); if (isOutsideCell || isOutsideSpace) { nodeList.Add(null); } else { // Compute position vector Vector3d V = uvw[0] * vectorU + uvw[1] * vectorV + uvw[2] * vectorW; var newNode = new LatticeNode(basePlane.Origin + V); // Check if point is inside - use unstrict tolerance, meaning it can be outside the surface by the specified tolerance bool isInside = FrameTools.IsPointInside(designSpace, newNode.Point3d, spaceType, tol, strictlyIn); // Set the node state (it's location wrt the design space) if (isInside) { newNode.State = LatticeNodeState.Inside; } else { newNode.State = LatticeNodeState.Outside; } // Add node to tree nodeList.Add(newNode); } } } } } // 9. Map struts to the node tree lattice.UniformMapping(cell, designSpace, spaceType, N, minLength, maxLength); // 10. Set output DA.SetDataList(0, lattice.Struts); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // SET ALL INPUT PARAMETERS Polyline plA = default(Polyline); if (!Polyline3D.ConvertCurveToPolyline(DA.Fetch<Curve>("A"), out plA)) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert to polyline from curve"); return; } Polyline plB = default(Polyline); if (!Polyline3D.ConvertCurveToPolyline(DA.Fetch<Curve>("B"), out plB)) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert to polyline from curve"); return; } Plane pln = DA.Fetch<Plane>("Plane"); double tolerance = DA.Fetch<double>("Tolerance"); if (pln.Equals(default(Plane))) { pln = plA.FitPlane(); } Point3d ptCenter = new Box(pln, plB).Center; List<Polyline> outCurves = new List<Polyline>(); List<Polyline> outDisplacedCurves = new List<Polyline>(); foreach (List<IntPoint> path in ClipperLib.Clipper.MinkowskiSum(plA.ToPath2D(pln, tolerance), plB.ToPath2D(pln, tolerance), true)) { Polyline plSum = path.ToPolyline(pln, tolerance, true); //Polyline plDisplacedSum = new Polyline(plSum); //plDisplacedSum.Transform(Transform.Translation(-new Vector3d(ptCenter))); outCurves.Add(plSum); //outDisplacedCurves.Add(plDisplacedSum); } // OUTPUT LOGIC DA.SetDataList("Sum", outCurves); DA.SetDataList("DisplacedSum", outCurves); }
/// <summary> /// Aligned Boundingbox solver. Gets the plane aligned boundingbox. /// </summary> /// <param name="plane">Orientation plane for BoundingBox.</param> /// <param name="worldBox">Aligned box in World coordinates.</param> /// <returns>A BoundingBox in plane coordinates.</returns> public BoundingBox GetBoundingBox(Plane plane, out Box worldBox) { worldBox = Box.Unset; if (!plane.IsValid) { return BoundingBox.Unset; } Transform xform = Geometry.Transform.ChangeBasis(Plane.WorldXY, plane); BoundingBox rc = GetBoundingBox(xform); //Transform unxform; //xform.TryGetInverse(out unxform); //worldBox = new Box(rc); //worldBox.Transform(unxform); worldBox = new Box(plane, rc); return rc; }
// Default Constructor. Defaults to continuous flow, creating a new Agent every timestep. public BoxEmitterType() { Plane pln = new Plane(); Interval size = new Interval(-RS.boxBoundsDefault, RS.boxBoundsDefault); box = new Box(pln, size, size, size); }
/// <summary> /// Draws the edges of a Box object. /// </summary> /// <param name="box">Box to draw.</param> /// <param name="color">Color to draw in.</param> /// <param name="thickness">Thickness (in pixels) of box edges.</param> public void DrawBox(Box box, System.Drawing.Color color, int thickness) { if (!box.IsValid) { return; } bool dx = box.X.IsSingleton; bool dy = box.Y.IsSingleton; bool dz = box.Z.IsSingleton; // If degenerate in all directions, then there's nothing to draw. if (dx && dy && dz) { return; } Point3d[] C = box.GetCorners(); // If degenerate in two directions, we can draw a single line. if (dx && dy) { DrawLine(C[0], C[4], color, thickness); return; } if (dx && dz) { DrawLine(C[0], C[3], color, thickness); return; } if (dy && dz) { DrawLine(C[0], C[1], color, thickness); return; } // If degenerate in one direction, we can draw rectangles. if (dx) { DrawLine(C[0], C[3], color, thickness); DrawLine(C[3], C[7], color, thickness); DrawLine(C[7], C[4], color, thickness); DrawLine(C[4], C[0], color, thickness); return; } if (dy) { DrawLine(C[0], C[1], color, thickness); DrawLine(C[1], C[5], color, thickness); DrawLine(C[5], C[4], color, thickness); DrawLine(C[4], C[0], color, thickness); return; } if (dz) { DrawLine(C[0], C[1], color, thickness); DrawLine(C[1], C[2], color, thickness); DrawLine(C[2], C[3], color, thickness); DrawLine(C[3], C[0], color, thickness); return; } // Draw all 12 edges DrawLine(C[0], C[1], color, thickness); DrawLine(C[1], C[2], color, thickness); DrawLine(C[2], C[3], color, thickness); DrawLine(C[3], C[0], color, thickness); DrawLine(C[0], C[4], color, thickness); DrawLine(C[1], C[5], color, thickness); DrawLine(C[2], C[6], color, thickness); DrawLine(C[3], C[7], color, thickness); DrawLine(C[4], C[5], color, thickness); DrawLine(C[5], C[6], color, thickness); DrawLine(C[6], C[7], color, thickness); DrawLine(C[7], C[4], color, thickness); }
// Constructor with initial values. public BoxEmitterType(Box box, bool continuousFlow, int creationRate, int numAgents, Vector3d velocityMin, Vector3d velocityMax) : base(continuousFlow, creationRate, numAgents, velocityMin, velocityMax) { this.box = box; }
// Constructor with initial values. public BoxEmitterType(Box box) { this.box = box; }
// Copy Constructor public BoxEmitterType(BoxEmitterType boxEmitter) { box = boxEmitter.box; }
//HATCH FILL REGION - infills a planar region with a hatching pattern public void Filler(List<double> infDens, List<double> infRot) { double tolerance = 0.001; //double overlaptol = 0.0; double crossSecHyp = Math.Sqrt(Math.Pow(crossSec, 2) * 2); curveInfill = new List<Curve>[planarBreps.Count]; //Create List of Infill Curves for each Planar Region for (int u = 0; u < planarBreps.Count; u++) { //Rotate Plane for Filling double rotationRad = infRot[u] * 0.0174532925; Plane plane = Plane.WorldXY; plane.Rotate(rotationRad, Plane.WorldXY.ZAxis); //Create Bounding Box Box bbox = new Box(); planarBreps[u].GetBoundingBox(plane, out bbox); //Get Corners Point3d[] cornerPts = bbox.GetCorners(); //Draw Parallel Lines LineCurve baseLine = new LineCurve(cornerPts[0], cornerPts[1]); LineCurve baseLine2 = new LineCurve(cornerPts[3], cornerPts[2]); //int nPts = (int)Math.Round((baseLine.Line.Length/crossSec),0); Point3d[] basePts = new Point3d[0]; Point3d[] basePts2 = new Point3d[0]; double length = baseLine.Line.Length; double floatdivisions = length / crossSec; double density = infDens[u]; int divisions = (int)Math.Round((floatdivisions * density)); //Divide Lines by Fill Density ratio baseLine.DivideByCount(divisions, true, out basePts); baseLine2.DivideByCount(divisions, true, out basePts2); if (divisions == 0) { curveInfill[u] = new List<Curve>(); return; } Curve[][] intCurve = new Curve[basePts.Length][]; List<Curve> intCurves = new List<Curve>(); for (int i = 0; i < basePts.Length; i++) { LineCurve intLine = new LineCurve(basePts[i], basePts2[i]); Point3d[] intPts = new Point3d[0]; BrepFace r_Infill = planarBreps[u].Faces[0]; Curve[] int_Curve = new Curve[0]; //Intersect Curves with Regions Intersection.CurveBrepFace(intLine, r_Infill, tolerance, out int_Curve, out intPts); intCurve[i] = int_Curve; //Convert resulting Curves into LineCurves for (int j = 0; j < int_Curve.Length; j++) { LineCurve line = new LineCurve(int_Curve[j].PointAtStart, int_Curve[j].PointAtEnd); intCurve[i][j] = line; //intCurves[j].Add(int_Curve[j]); intCurves.Add(line); } } //Rotate Array List<Curve>[] int_Curves = RotatetoListArray(intCurve); List<Curve> joinLines = new List<Curve>(); List<Curve> p_lines = new List<Curve>(); for (int l = 0; l < int_Curves.Length; l++) { for (int k = 1; k < int_Curves[l].Count; k += 2) { int_Curves[l][k].Reverse(); } } //Create a list of points for all connected lines in the infill. Do this for each seperate string of segments for (int l = 0; l < int_Curves.Length; l++) { List<Point3d> plinePts = new List<Point3d>(); if (int_Curves[l].Count > 0) { plinePts.Add(int_Curves[l][0].PointAtStart); for (int k = 1; k < int_Curves[l].Count; k++) { plinePts.Add(int_Curves[l][k - 1].PointAtEnd); plinePts.Add(int_Curves[l][k].PointAtStart); plinePts.Add(int_Curves[l][k].PointAtEnd); } PolylineCurve plCurve = new PolylineCurve(plinePts); Curve curve = plCurve.ToNurbsCurve(); p_lines.Add(curve); } } List<Curve> curve_s = p_lines; curveInfill[u] = p_lines; } }
/// <summary> /// Test a box for Box inclusion. This is the same as calling Contains(box,false) /// </summary> /// <param name="box">Box to test.</param> /// <returns>true if the box is on the inside of or coincident with this Box.</returns> public bool Contains(Box box) { return Contains(box, 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; } } }
/// <summary> /// Each implementation of GH_Component must provide a public /// constructor without any arguments. /// Category represents the Tab in which the component will appear, /// Subcategory the panel. If you use non-existing tab or panel names, /// new tabs/panels will automatically be created. /// </summary> public BoxEmitterComponent() : base(RS.boxEmitterName, RS.boxEmitterNickname, RS.boxEmitterDescription, RS.icon_boxEmitter, RS.boxEmitterGuid) { box = new Box(); }