protected override void SolveInstance(IGH_DataAccess DA) { GH_String style = new GH_String(""); GH_String layer = new GH_String(""); GH_Point stop = new GH_Point(); GH_Point sbtm = new GH_Point(); List <Parameter> param = new List <Parameter>(); if (!DA.GetDataList <Parameter>("Parameters", param)) { param = new List <Parameter>(); } DA.GetData <GH_String>("Style", ref style); DA.GetData <GH_String>("Layer", ref layer); DA.GetData <GH_Point>("PointTop", ref stop); DA.GetData <GH_Point>("PointBottom", ref sbtm); Column s = new Column(style.Value, layer.Value, param, sbtm.ToGrevitPoint(), stop.ToGrevitPoint(), "", true); SetGID(s); Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(sbtm.Value, 0.5); Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(new Rhino.Geometry.Point3d(stop.Value.X - sbtm.Value.X, stop.Value.Y - sbtm.Value.Y, stop.Value.Z - sbtm.Value.Z))); SetPreview(s.GID, srf.ToBrep()); DA.SetData("GrevitComponent", s); }
public void drawColumn(Rhino.Geometry.Point3d point1, double length, double radius) { Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(point1, radius); Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(0, 0, (length * -1))); SetPreview(srf.ToBrep()); }
public void drawColumn(Rhino.Geometry.Point3d point1, Rhino.Geometry.Point3d point2, double radius) { Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(point1, new Rhino.Geometry.Vector3d((point2 - point1))); Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(plane, point1, radius); Rhino.Geometry.Surface srf = Rhino.Geometry.Surface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d((point2 - point1))); SetPreview(srf.ToBrep()); }
protected override void SolveInstance(IGH_DataAccess DA) { Types.Assembly assembly = new Types.Assembly(); DA.GetData <Types.Assembly>("Material", ref assembly); GH_Point point = new GH_Point(); GH_Integer piles = new GH_Integer(1); GH_Number radius = new GH_Number(0); GH_Number plateThickness = new GH_Number(0); GH_Number plateLength = new GH_Number(0); GH_Number plateWidth = new GH_Number(0); GH_Number pileLength = new GH_Number(0); DA.GetData <GH_Point>("Point", ref point); DA.GetData <GH_Number>("Pile Radius", ref radius); DA.GetData <GH_Integer>("Piles", ref piles); DA.GetData <GH_Number>("Plate Thickness", ref plateThickness); DA.GetData <GH_Number>("Plate Length", ref plateLength); DA.GetData <GH_Number>("Plate Width", ref plateWidth); DA.GetData <GH_Number>("Pile Length", ref pileLength); drawExtrusion(point.Value, plateLength.Value, plateWidth.Value, plateThickness.Value); Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(point.Value, (plateWidth.Value / 2) * 0.8); double numberOfPiles = piles.Value; for (int i = 1; i <= piles.Value; i++) { double iteration = i; double factor = 2.0 * Math.PI * (iteration / numberOfPiles); Rhino.Geometry.Point3d center = (piles.Value == 1)? point.Value : circle.ToNurbsCurve().PointAt(factor); drawColumn(center, pileLength.Value, radius.Value); } double calculationVolume = (piles.Value * pileLength.Value * radius.Value) + (plateThickness.Value * plateLength.Value * plateWidth.Value); Types.Result result = new Types.Result() { GlobalWarmingPotential = new Types.UnitDouble <Types.LCA.CO2e>(assembly.GlobalWarmingPotential.Value * calculationVolume), Acidification = new Types.UnitDouble <Types.LCA.kgSO2>(assembly.Acidification.Value * calculationVolume), DepletionOfNonrenewbles = new Types.UnitDouble <Types.LCA.MJ>(assembly.DepletionOfNonrenewbles.Value * calculationVolume), DepletionOfOzoneLayer = new Types.UnitDouble <Types.LCA.kgCFC11>(assembly.DepletionOfOzoneLayer.Value * calculationVolume), Eutrophication = new Types.UnitDouble <Types.LCA.kgPhostphate>(assembly.Eutrophication.Value * calculationVolume), FormationTroposphericOzone = new Types.UnitDouble <Types.LCA.kgNOx>(assembly.FormationTroposphericOzone.Value * calculationVolume) }; DA.SetData("LCA Result", result); }
public static Rhino.Commands.Result AddCircle(Rhino.RhinoDoc doc) { Rhino.Geometry.Point3d center = new Rhino.Geometry.Point3d(0, 0, 0); const double radius = 10.0; Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(center, radius); if (doc.Objects.AddCircle(c) != Guid.Empty) { doc.Views.Redraw(); return(Rhino.Commands.Result.Success); } return(Rhino.Commands.Result.Failure); }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Point point = new GH_Point(); Grevit.Types.Wall wall = null; GH_String layer = new GH_String(""); GH_String style = new GH_String(""); List <Parameter> param = new List <Parameter>(); if (!DA.GetDataList <Parameter>("Parameters", param)) { param = new List <Parameter>(); } DA.GetData <GH_Point>("Point", ref point); DA.GetData <GH_String>("Layer", ref layer); DA.GetData <GH_String>("Style", ref style); DA.GetData <Wall>("wall", ref wall); Door d = new Door(); SetGID(d); d.stalledForReference = true; d.TypeOrLayer = layer.Value; d.FamilyOrStyle = style.Value; d.locationPoint = point.ToGrevitPoint(); d.parameters = param; SetGID(d); Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(point.Value, 0.5); Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(0, 0, 2)); SetPreview(d.GID, srf.ToBrep()); GH_Surface ghb = new GH_Surface(srf); DA.SetData("GrevitComponent", d); }
public static Rhino.Commands.Result AddCylinder(Rhino.RhinoDoc doc) { Rhino.Geometry.Point3d center_point = new Rhino.Geometry.Point3d(0, 0, 0); Rhino.Geometry.Point3d height_point = new Rhino.Geometry.Point3d(0, 0, 10); Rhino.Geometry.Vector3d zaxis = height_point - center_point; Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(center_point, zaxis); const double radius = 5; Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(plane, radius); Rhino.Geometry.Cylinder cylinder = new Rhino.Geometry.Cylinder(circle, zaxis.Length); Rhino.Geometry.Brep brep = cylinder.ToBrep(true, true); if (brep != null) { doc.Objects.AddBrep(brep); doc.Views.Redraw(); } return Rhino.Commands.Result.Success; }
/// <summary> /// Create Rhino open ArcCurve from Edge(Arc). /// </summary> public static Rhino.Geometry.ArcCurve ToRhinoArcCurve(Geometry.Edge obj) { if (obj.Points.Count == 3) { Rhino.Geometry.Arc arc = new Rhino.Geometry.Arc(obj.Points[0].ToRhino(), obj.Points[1].ToRhino(), obj.Points[2].ToRhino()); return(new Rhino.Geometry.ArcCurve(arc)); } else { Rhino.Geometry.Interval interval = new Rhino.Geometry.Interval(obj.StartAngle, obj.EndAngle); Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(obj.Points[0].ToRhino(), obj.XAxis.ToRhino(), obj.Normal.Cross(obj.XAxis).Normalize().ToRhino()); Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(plane, obj.Radius); Rhino.Geometry.Arc arc = new Rhino.Geometry.Arc(circle, interval); return(new Rhino.Geometry.ArcCurve(arc)); } }
public static Rhino.Commands.Result AddCylinder(Rhino.RhinoDoc doc) { Rhino.Geometry.Point3d center_point = new Rhino.Geometry.Point3d(0, 0, 0); Rhino.Geometry.Point3d height_point = new Rhino.Geometry.Point3d(0, 0, 10); Rhino.Geometry.Vector3d zaxis = height_point - center_point; Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(center_point, zaxis); const double radius = 5; Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(plane, radius); Rhino.Geometry.Cylinder cylinder = new Rhino.Geometry.Cylinder(circle, zaxis.Length); Rhino.Geometry.Brep brep = cylinder.ToBrep(true, true); if (brep != null) { doc.Objects.AddBrep(brep); doc.Views.Redraw(); } return(Rhino.Commands.Result.Success); }
/// <summary> /// Get the circumscribed center from the face /// </summary> /// <param name="f">A face index.</param> /// <returns>The location of the specified face's circumcenter</returns> public PlanktonXYZ GetFaceCircumCenter(int f) { // Gene Added function // temperary using Rhino circle to find the circumscribed center, because it is easier. if (this.GetFaceVertices(f).Count() != 3) { return(PlanktonXYZ.Zero); } else { int[] v = this.GetFaceVertices(f); Rhino.Geometry.Circle circum = new Rhino.Geometry.Circle( new Rhino.Geometry.Point3d(_mesh.Vertices[v[0]].X, _mesh.Vertices[v[0]].X, _mesh.Vertices[v[0]].X), new Rhino.Geometry.Point3d(_mesh.Vertices[v[1]].X, _mesh.Vertices[v[1]].X, _mesh.Vertices[v[1]].X), new Rhino.Geometry.Point3d(_mesh.Vertices[v[2]].X, _mesh.Vertices[v[2]].X, _mesh.Vertices[v[2]].X)); return(new PlanktonXYZ((float)circum.Center.X, (float)circum.Center.Y, (float)circum.Center.Z)); } }
bool CreateHole(out Rhino.Geometry.Brep outBrep) { outBrep = null; // Make sure the "hole" goes completely through the solid so // the Boolean operation will succeed. Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d(0.0, 0.0, -1.0); Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(origin, 4.0); Rhino.Geometry.Cylinder cylinder = new Rhino.Geometry.Cylinder(circle, 12.0); Rhino.Geometry.Brep brep = cylinder.ToBrep(true, true); bool rc = brep.IsValid; if (rc) { outBrep = brep; } return(rc); }
bool CreateSolid(double tolerance, out Rhino.Geometry.Brep outBrep) { outBrep = null; Rhino.Geometry.Point3d origin = new Rhino.Geometry.Point3d(0.0, 0.0, 0.0); Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(origin, 10.0); Rhino.Geometry.ArcCurve curve = new Rhino.Geometry.ArcCurve(circle); Rhino.Geometry.Vector3d direction = new Rhino.Geometry.Vector3d(0, 0, 10); Rhino.Geometry.Surface surface = Rhino.Geometry.Surface.CreateExtrusion(curve, direction); Rhino.Geometry.Brep brep = Rhino.Geometry.Brep.CreateFromSurface(surface); Rhino.Geometry.Brep solid = brep.CapPlanarHoles(tolerance); bool rc = solid.IsValid; if (rc) { outBrep = solid; } return(rc); }
public void drawColumn(Rhino.Geometry.Point3d point1, Rhino.Geometry.Point3d point2, double radius) { Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(point1, new Rhino.Geometry.Vector3d((point2 - point1))); Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(plane,point1,radius); Rhino.Geometry.Surface srf = Rhino.Geometry.Surface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d((point2 - point1))); SetPreview(srf.ToBrep()); }
/// <summary> /// Create Rhino closed ArcCurve from Edge(Circle). /// </summary> public static Rhino.Geometry.ArcCurve ToRhinoArcCurveFromCircle(Geometry.Edge obj) { Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(obj.Points[0].ToRhino(), obj.Normal.ToRhino()); Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(plane, obj.Radius); return(new Rhino.Geometry.ArcCurve(circle)); }
public void drawColumn(Rhino.Geometry.Point3d point1, double length, double radius) { Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(point1,radius); Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(0,0,(length*-1))); SetPreview(srf.ToBrep()); }
public override void BakeGeometry(Rhino.RhinoDoc doc, Rhino.DocObjects.ObjectAttributes att, List<Guid> obj_ids) { Rhino.Geometry.Transform zDown_airy = Rhino.Geometry.Transform.Translation(0, 0, 2d); Rhino.DocObjects.ObjectAttributes a2 = att.Duplicate(); a2.LayerIndex = 2; Rhino.DocObjects.ObjectAttributes a3 = att.Duplicate(); a3.LayerIndex = 3; Rhino.DocObjects.ObjectAttributes a4 = att.Duplicate(); a4.LayerIndex = 4; Rhino.DocObjects.ObjectAttributes a5 = att.Duplicate(); a5.LayerIndex = 5; Rhino.DocObjects.ObjectAttributes a6 = att.Duplicate(); a6.LayerIndex = 6; Rhino.DocObjects.ObjectAttributes a7 = att.Duplicate(); a7.LayerIndex = 7; foreach (var leaf in listLeaf) { var airySrf=leaf.airySrf.Duplicate() as Rhino.Geometry.NurbsSurface; airySrf.Transform(zScale); airySrf.Transform(zDown_airy); Guid id = doc.Objects.AddSurface(airySrf, a2); obj_ids.Add(id); var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zDown_eq); id = doc.Objects.AddSurface(srf, a3); obj_ids.Add(id); } foreach (var branch in listBranch) { //var airyCrv=branch.airyCrv.Duplicate() as Rhino.Geometry.NurbsCurve; //airyCrv.Transform(zDown_airy); //Guid id = doc.Objects.AddCurve(airyCrv, a2); //obj_ids.Add(id); if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce||branch.branchType == branch.type.open) { var crv = branch.shellCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zDown_eq); Guid id = doc.Objects.AddCurve(crv, a7); obj_ids.Add(id); } } if (crossMagenta != null) { foreach (var line in crossMagenta) { Guid id = doc.Objects.AddLine(line, a4); obj_ids.Add(id); } } if (listBranch != null) { foreach (var branch in listBranch) { if (branch.branchType == branch.type.fix) { if (branch.tuples != null) { foreach (var tup in branch.tuples) { var circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), 0.5); circle.Transform(zDown); Guid id = doc.Objects.AddCircle(circle, a6); obj_ids.Add(id); circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, branch.slice2.height), 0.5); circle.Transform(zDown_eq); id = doc.Objects.AddCircle(circle, a6); obj_ids.Add(id); } } } if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce||branch.branchType==branch.type.open) { if (branch.tuples != null) { foreach (var tup in branch.tuples) { var D = tup.SPK[0, 0]/2d; if (D > 0) { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); Guid id = doc.Objects.AddLine(line, a5); obj_ids.Add(id); } } } } } } }
protected override void SolveInstance(IGH_DataAccess DA) { GH_String style = new GH_String(""); GH_String layer = new GH_String(""); GH_Point stop = new GH_Point(); GH_Point sbtm = new GH_Point(); List<Parameter> param = new List<Parameter>(); if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>(); DA.GetData<GH_String>("Style", ref style); DA.GetData<GH_String>("Layer", ref layer); DA.GetData<GH_Point>("PointTop", ref stop); DA.GetData<GH_Point>("PointBottom", ref sbtm); Column s = new Column(style.Value,layer.Value,param,sbtm.ToGrevitPoint(),stop.ToGrevitPoint(),"",true ); SetGID(s); Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(sbtm.Value, 0.5); Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(new Rhino.Geometry.Point3d(stop.Value.X - sbtm.Value.X, stop.Value.Y - sbtm.Value.Y, stop.Value.Z - sbtm.Value.Z))); SetPreview(s.GID, srf.ToBrep()); DA.SetData("GrevitComponent", s); }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Point point = new GH_Point(); Grevit.Types.Wall wall = null; GH_String layer = new GH_String(""); GH_String style = new GH_String(""); List<Parameter> param = new List<Parameter>(); if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>(); DA.GetData<GH_Point>("Point", ref point); DA.GetData<GH_String>("Layer", ref layer); DA.GetData<GH_String>("Style", ref style); DA.GetData<Wall>("wall", ref wall); Door d = new Door(); SetGID(d); d.stalledForReference = true; d.TypeOrLayer = layer.Value; d.FamilyOrStyle = style.Value; d.locationPoint = point.ToGrevitPoint(); d.parameters = param; SetGID(d); Rhino.Geometry.Circle c = new Rhino.Geometry.Circle(point.Value, 0.5); Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(c.ToNurbsCurve(), new Rhino.Geometry.Vector3d(0,0, 2)); SetPreview(d.GID, srf.ToBrep()); GH_Surface ghb = new GH_Surface(srf); DA.SetData("GrevitComponent", d); }
public override void BakeGeometry(Rhino.RhinoDoc doc, Rhino.DocObjects.ObjectAttributes att, List <Guid> obj_ids) { Rhino.Geometry.Transform zDown_airy = Rhino.Geometry.Transform.Translation(0, 0, 2d); Rhino.DocObjects.ObjectAttributes a2 = att.Duplicate(); a2.LayerIndex = 2; Rhino.DocObjects.ObjectAttributes a3 = att.Duplicate(); a3.LayerIndex = 3; Rhino.DocObjects.ObjectAttributes a4 = att.Duplicate(); a4.LayerIndex = 4; Rhino.DocObjects.ObjectAttributes a5 = att.Duplicate(); a5.LayerIndex = 5; Rhino.DocObjects.ObjectAttributes a6 = att.Duplicate(); a6.LayerIndex = 6; Rhino.DocObjects.ObjectAttributes a7 = att.Duplicate(); a7.LayerIndex = 7; foreach (var leaf in listLeaf) { var airySrf = leaf.airySrf.Duplicate() as Rhino.Geometry.NurbsSurface; airySrf.Transform(zScale); airySrf.Transform(zDown_airy); Guid id = doc.Objects.AddSurface(airySrf, a2); obj_ids.Add(id); var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zDown_eq); id = doc.Objects.AddSurface(srf, a3); obj_ids.Add(id); } foreach (var branch in listBranch) { //var airyCrv=branch.airyCrv.Duplicate() as Rhino.Geometry.NurbsCurve; //airyCrv.Transform(zDown_airy); //Guid id = doc.Objects.AddCurve(airyCrv, a2); //obj_ids.Add(id); if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce) { var crv = branch.shellCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zDown_eq); Guid id = doc.Objects.AddCurve(crv, a7); obj_ids.Add(id); } } if (crossMagenta != null) { foreach (var line in crossMagenta) { Guid id = doc.Objects.AddLine(line, a4); obj_ids.Add(id); } } if (listBranch != null) { foreach (var branch in listBranch) { if (branch.branchType == branch.type.fix) { if (branch.tuples != null) { foreach (var tup in branch.tuples) { var circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), 0.5); circle.Transform(zDown); Guid id = doc.Objects.AddCircle(circle, a6); obj_ids.Add(id); circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, branch.slice2.height), 0.5); circle.Transform(zDown_eq); id = doc.Objects.AddCircle(circle, a6); obj_ids.Add(id); } } } if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce) { if (branch.tuples != null) { foreach (var tup in branch.tuples) { var D = tup.SPK[0, 0] / 2d; if (D > 0) { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); Guid id = doc.Objects.AddLine(line, a5); obj_ids.Add(id); } } } } } } }
private string getInputs(GH_Component ThisComponent, IGH_DataAccess DA, int i) { string datahere = ""; string paramType = ""; try { if (ThisComponent.Params.Input[i].Access == GH_ParamAccess.item) { convetToItem(ThisComponent, i, DA); IGH_Goo inputObject = null; DA.GetData(i, ref inputObject); paramType = inputObject.GetType().ToString(); if (paramType == "Grasshopper.Kernel.Types.GH_Line") { convetToItem(ThisComponent, i, DA); Rhino.Geometry.Line inputLine = Rhino.Geometry.Line.Unset; DA.GetData(i, ref inputLine); datahere = "\"gCPy.Line(" + inputLine.FromX.ToString() + ", " + inputLine.FromY.ToString() + ", " + inputLine.FromZ.ToString() + ", " + inputLine.ToX.ToString() + ", " + inputLine.ToY.ToString() + ", " + inputLine.ToZ.ToString() + ")\""; } else if (paramType == "Grasshopper.Kernel.Types.GH_Point") { convetToItem(ThisComponent, i, DA); Rhino.Geometry.Point3d inputPoint = Rhino.Geometry.Point3d.Unset; DA.GetData(i, ref inputPoint); datahere = "\"gCPy.Point(" + inputPoint.X.ToString() + ", " + inputPoint.Y.ToString() + ", " + inputPoint.Z.ToString() + ")\""; } else if (paramType == "Grasshopper.Kernel.Types.GH_Circle") { convetToItem(ThisComponent, i, DA); Rhino.Geometry.Circle inputCircle = Rhino.Geometry.Circle.Unset; DA.GetData(i, ref inputCircle); datahere = "\"gCPy.Circle(" + inputCircle.Center.X.ToString() + "," // xpos + inputCircle.Center.Y.ToString() + "," // ypos + inputCircle.Center.Z.ToString() + "," // zpos + inputCircle.Radius.ToString() + "," // radius + inputCircle.Plane.XAxis.ToString() + "," // x axis vector0 , x axis vector1 , x axis vector 2 + inputCircle.Plane.YAxis.ToString() + "," // y axis vector + inputCircle.Plane.ZAxis.ToString() + ")\""; // z axis vector } else if (paramType == "Grasshopper.Kernel.Types.GH_Curve") { datahere += "\"Ok This is a curve ... Take Care .. add all your things here\""; } else if (paramType == "Grasshopper.Kernel.Types.GH_String") { convetToItem(ThisComponent, i, DA); string inputString = string.Empty; DA.GetData(i, ref inputString); datahere = "\"" + inputString.Replace(Environment.NewLine, "\\n").Replace("'", @"\'").Replace("\"", "\\\\" + "\"").Replace("\\n", "\\\\n") + "\""; } else if (paramType == "Grasshopper.Kernel.Types.GH_Integer") { convetToItem(ThisComponent, i, DA); int inputInt = 0; DA.GetData(i, ref inputInt); datahere = inputInt.ToString(); } else if (paramType == "Grasshopper.Kernel.Types.GH_Number") { convetToItem(ThisComponent, i, DA); double inputNum = 0.0; DA.GetData(i, ref inputNum); datahere = inputNum.ToString(); } else if (paramType == "Grasshopper.Kernel.Types.GH_Boolean") { convetToItem(ThisComponent, i, DA); bool inputBool = false; DA.GetData(i, ref inputBool); datahere = inputBool ? "True" : "False"; } else { datahere = "None"; } } else { string thisInputString = ThisComponent.Params.Input[i].VolatileData.DataDescription(false, false).Trim().Replace(System.Environment.NewLine, ","); datahere = recomposeInputString(thisInputString); } } catch (Exception errf) { //MessageBox.Show(errf.ToString()); } return(datahere); }
public override void DrawViewportWires(Grasshopper.Kernel.IGH_PreviewArgs args) { if (Hidden) { return; } if (listArrow != null) { args.Display.DrawLines(listArrow, System.Drawing.Color.Red); } //targetSrf if (listPnt != null) { args.Display.DrawPoints(targetSrf, Rhino.Display.PointStyle.Simple, 1, System.Drawing.Color.White); } //eigenvectors if (crossCyan != null) { args.Display.DrawLines(crossCyan, System.Drawing.Color.Cyan); } if (crossMagenta != null) { args.Display.DrawLines(crossMagenta, System.Drawing.Color.Magenta); } if (listError != null) { foreach (var error in listError) { args.Display.DrawCurve(error, System.Drawing.Color.Red, 10); } } /*if (listSlice != null) { foreach (var slice in listSlice.Values) { var pl = slice.pl; args.Display.DrawPolygon(new Rhino.Geometry.Point3d[] { pl.PointAt(-2, -2), pl.PointAt(-2, 2), pl.PointAt(2, 2), pl.PointAt(2, -2) }, System.Drawing.Color.Azure, true); } }*/ foreach (var branch in listBranch) { switch (branch.branchType) { case Mothra4.branch.type.fix: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Orange, 3); break; case Mothra4.branch.type.reinforce: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Cyan, 3); break; case Mothra4.branch.type.kink: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Purple, 3); break; case Mothra4.branch.type.open: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Green, 3); break; } } foreach (var leaf in listLeaf) { if (leaf.airySrf != null) { var srf = leaf.airySrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zScale); args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3); } } foreach (var leaf in listLeaf) { if (leaf.shellSrf != null) { var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zDown_eq); args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3); } } /*foreach (var branch in listBranch) { if (branch.airyCrv != null) { var crv = branch.airyCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zScale); args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 4); } }*/ foreach (var branch in listBranch) { if (branch.branchType == branch.type.fix) { double x = 0, y = 0, z = branch.slice2.height; for (int i = 0; i < branch.N; i++) { x += branch.crv.Points[i].Location.X; y += branch.crv.Points[i].Location.Y; z += branch.crv.Points[i].Location.Z; } x /= branch.N; y /= branch.N; args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); } } foreach (var branch in listBranch) { if (branch.shellCrv != null) { if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce || branch.branchType == branch.type.open) { var crv = branch.shellCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zDown_eq); args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 3); } } } //find max value of reinforcement if (listBranch != null) { foreach (var branch in listBranch) { if (branch.tuples != null) { if (branch.branchType == branch.type.fix) { foreach (var tup in branch.tuples) { var circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), 0.5); circle.Transform(zDown); args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2); circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, branch.slice2.height), 0.5); circle.Transform(zDown_eq); args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2); } } else { foreach (var tup in branch.tuples) { var D = tup.SPK[0, 0]/2d; if (D > 0) { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); args.Display.DrawLine(line, System.Drawing.Color.Red, 2); } else { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); args.Display.DrawLine(line, System.Drawing.Color.Blue, 2); } } } } } } /* if (a != null) { args.Display.DrawPoints(a, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue); }*/ if (a2 != null) { args.Display.DrawPoints(a2, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue); } }
protected override void SolveInstance(IGH_DataAccess DA) { Types.Assembly assembly = new Types.Assembly(); DA.GetData<Types.Assembly>("Material", ref assembly); GH_Point point = new GH_Point(); GH_Integer piles = new GH_Integer(1); GH_Number radius = new GH_Number(0); GH_Number plateThickness = new GH_Number(0); GH_Number plateLength = new GH_Number(0); GH_Number plateWidth = new GH_Number(0); GH_Number pileLength = new GH_Number(0); DA.GetData<GH_Point>("Point", ref point); DA.GetData<GH_Number>("Pile Radius", ref radius); DA.GetData<GH_Integer>("Piles", ref piles); DA.GetData<GH_Number>("Plate Thickness", ref plateThickness); DA.GetData<GH_Number>("Plate Length", ref plateLength); DA.GetData<GH_Number>("Plate Width", ref plateWidth); DA.GetData<GH_Number>("Pile Length", ref pileLength); drawExtrusion(point.Value, plateLength.Value, plateWidth.Value, plateThickness.Value); Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(point.Value, (plateWidth.Value / 2) * 0.8); double numberOfPiles = piles.Value; for (int i = 1; i <= piles.Value; i++) { double iteration = i; double factor = 2.0 * Math.PI * (iteration / numberOfPiles); Rhino.Geometry.Point3d center = (piles.Value == 1)? point.Value : circle.ToNurbsCurve().PointAt(factor); drawColumn(center, pileLength.Value, radius.Value); } double calculationVolume = (piles.Value * pileLength.Value * radius.Value) + (plateThickness.Value * plateLength.Value * plateWidth.Value); Types.Result result = new Types.Result() { GlobalWarmingPotential = new Types.UnitDouble<Types.LCA.CO2e>(assembly.GlobalWarmingPotential.Value * calculationVolume), Acidification = new Types.UnitDouble<Types.LCA.kgSO2>(assembly.Acidification.Value * calculationVolume), DepletionOfNonrenewbles = new Types.UnitDouble<Types.LCA.MJ>(assembly.DepletionOfNonrenewbles.Value * calculationVolume), DepletionOfOzoneLayer = new Types.UnitDouble<Types.LCA.kgCFC11>(assembly.DepletionOfOzoneLayer.Value * calculationVolume), Eutrophication = new Types.UnitDouble<Types.LCA.kgPhostphate>(assembly.Eutrophication.Value * calculationVolume), FormationTroposphericOzone = new Types.UnitDouble<Types.LCA.kgNOx>(assembly.FormationTroposphericOzone.Value * calculationVolume) }; DA.SetData("LCA Result", result); }
public override void DrawViewportWires(Grasshopper.Kernel.IGH_PreviewArgs args) { if (Hidden) { return; } if (listArrow != null) { args.Display.DrawLines(listArrow, System.Drawing.Color.Red); } //targetSrf if (listPnt != null) { args.Display.DrawPoints(targetSrf, Rhino.Display.PointStyle.Simple, 1, System.Drawing.Color.White); } //eigenvectors if (crossCyan != null) { args.Display.DrawLines(crossCyan, System.Drawing.Color.Cyan); } if (crossMagenta != null) { args.Display.DrawLines(crossMagenta, System.Drawing.Color.Magenta); } if (listError != null) { foreach (var error in listError) { args.Display.DrawCurve(error, System.Drawing.Color.Red, 10); } } /*if (listSlice != null) * { * foreach (var slice in listSlice.Values) * { * var pl = slice.pl; * args.Display.DrawPolygon(new Rhino.Geometry.Point3d[] { pl.PointAt(-2, -2), pl.PointAt(-2, 2), pl.PointAt(2, 2), pl.PointAt(2, -2) }, System.Drawing.Color.Azure, true); * } * }*/ foreach (var branch in listBranch) { switch (branch.branchType) { case Mothra4.branch.type.fix: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Orange, 3); break; case Mothra4.branch.type.reinforce: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Cyan, 3); break; case Mothra4.branch.type.kink: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Purple, 3); break; case Mothra4.branch.type.open: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Green, 3); break; } } foreach (var leaf in listLeaf) { if (leaf.airySrf != null) { var srf = leaf.airySrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zScale); srf.Transform(zDown2); args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3); } } foreach (var leaf in listLeaf) { if (leaf.shellSrf != null) { var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zDown_eq); args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3); } } /*foreach (var branch in listBranch) * { * if (branch.airyCrv != null) * { * var crv = branch.airyCrv.Duplicate() as Rhino.Geometry.NurbsCurve; * crv.Transform(zScale); * args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 4); * } * }*/ foreach (var branch in listBranch) { if (branch.branchType == branch.type.fix) { double x = 0, y = 0, z = branch.slice2.height; for (int i = 0; i < branch.N; i++) { x += branch.crv.Points[i].Location.X; y += branch.crv.Points[i].Location.Y; z += branch.crv.Points[i].Location.Z; } x /= branch.N; y /= branch.N; args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); } if (branch.branchType == branch.type.open && branch.endTypeL == branch.endtype.fix) { double x = branch.crv.Points[0].Location.X; double y = branch.crv.Points[0].Location.Y; double z = branch.sliceL.height; args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); } if (branch.branchType == branch.type.open && branch.endTypeR == branch.endtype.fix) { double x = branch.crv.Points[branch.crv.Points.Count - 1].Location.X; double y = branch.crv.Points[branch.crv.Points.Count - 1].Location.Y; double z = branch.sliceR.height; args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); } } foreach (var branch in listBranch) { if (branch.shellCrv != null) { if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce || branch.branchType == branch.type.open) { var crv = branch.shellCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zDown_eq); args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 3); } } } //find max value of reinforcement if (listBranch != null) { foreach (var branch in listBranch) { if (branch.tuples != null) { if (branch.branchType == branch.type.fix) { foreach (var tup in branch.tuples) { var circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), 0.5); circle.Transform(zDown); args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2); circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, branch.slice2.height), 0.5); circle.Transform(zDown_eq); args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2); } } else { foreach (var tup in branch.tuples) { var D = tup.SPK[0, 0] / 2d; if (D > 0) { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); args.Display.DrawLine(line, System.Drawing.Color.Red, 2); } else { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); args.Display.DrawLine(line, System.Drawing.Color.Blue, 2); } } } } } } /* * if (a != null) * { * args.Display.DrawPoints(a, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue); * * }*/ if (a2 != null) { args.Display.DrawPoints(a2, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue); } }
protected override void SolveInstance(IGH_DataAccess DA) { GH_String level = new GH_String("none"); GH_String family = new GH_String("none"); GH_String type = new GH_String("none"); GH_Point topPoint = new GH_Point(); GH_Point bottomPoint = new GH_Point(); GH_String gid = new GH_String(""); List<Parameter> parameters = new List<Parameter>(); if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>(); DA.GetData<GH_String>("Family", ref family); DA.GetData<GH_String>("Type", ref type); DA.GetData<GH_String>("Level", ref level); DA.GetData<GH_Point>("PointTop", ref topPoint); DA.GetData<GH_Point>("PointBottom", ref bottomPoint); DA.GetData<GH_String>("GID", ref gid); Column column = new Column(family.Value,type.Value,parameters, topPoint.ToGrevitPoint(), bottomPoint.ToGrevitPoint(),level.Value,true); SetGID(column); Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(bottomPoint.Value,0.5); Rhino.Geometry.Surface srf = Rhino.Geometry.NurbsSurface.CreateExtrusion(circle.ToNurbsCurve(), new Rhino.Geometry.Vector3d(new Rhino.Geometry.Point3d(topPoint.Value.X-bottomPoint.Value.X,topPoint.Value.Y-bottomPoint.Value.Y,topPoint.Value.Z-bottomPoint.Value.Z))); SetPreview(column.GID, srf.ToBrep()); DA.SetData("GrevitComponent", column); }