public static Point3d CastToPoint3d(GH_Point p) { Point3d p3d = new Point3d(); p.CastTo <Point3d>(out p3d); return(p3d); }
/// <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) { List <Point3d> inPoints = new List <Point3d>(); if (!DA.GetDataList <Point3d>(0, inPoints)) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, Constants.Constants.INPUT_ERROR_MESSAGE); } else { List <double> inMasses = new List <double>(); DA.GetDataList <double>(1, inMasses); ValuesAllocator.MatchLists(inPoints, inMasses); Point3d point3D = new Point3d(0, 0, 0); List <double> distances = new List <double>(); double totalMass = 0; for (int i = 0; i < inPoints.Count; i++) { point3D = point3D + (inPoints[i] * inMasses[i]); totalMass += inMasses[i]; } Point3d center = point3D / totalMass; GH_Point ghCenter = new GH_Point(center); foreach (Point3d pt in inPoints) { distances.Add(ghCenter.Value.DistanceTo(pt)); } DA.SetData(0, ghCenter); DA.SetDataList(1, distances); } }
public override bool CastFrom(object source) { if (source == null) { return(false); } if (source is Point3d) { Value = (Point3d)source; return(true); } GH_Point pointGoo = source as GH_Point; if (pointGoo != null) { Value = pointGoo.Value; return(true); } Point3d point = Point3d.Unset; if (GH_Convert.ToPoint3d(source, ref point, GH_Conversion.Both)) { Value = point; return(true); } return(false); }
// Casting to GH Data Types public bool ConvertToGH_Point <T>(ref T target) { object obj = new GH_Point(Location); target = (T)obj; return(true); }
// =============================================================================================== // method to display output to grasshopper with some optimization in conversion // =============================================================================================== public void DisplayToGrasshopper() { if (Containment[0].Label == 's') { _container = (SurfaceContainment)Containment[0]; var nu = NumberOperations.remap(XMin, XMax, _container.Surface.Domain(0).T0, _container.Surface.Domain(0).T1, Position.X); var nv = NumberOperations.remap(YMin, YMax, _container.Surface.Domain(1).T0, _container.Surface.Domain(1).T1, Position.Y); var vu = NumberOperations.remap(XMin, XMax, _container.Surface.Domain(0).T0, _container.Surface.Domain(0).T1, Velocity.X); var vv = NumberOperations.remap(YMin, YMax, _container.Surface.Domain(1).T0, _container.Surface.Domain(1).T1, Velocity.Y); GHPosition = new GH_Point(_container.Surface.PointAt(nu, nv)); GHVelocity = new GH_Vector(new Vector3d(_container.Surface.PointAt(vu, vv))); } else { GHPosition = new GH_Point(Position); GHVelocity = new GH_Vector(Velocity); } }
/// <summary> /// 将三维树转化为列表 /// </summary> /// <param name="tree"></param> /// <returns></returns> public static List <List <List <Point3d> > > TreeToList3(GH_Structure <GH_Point> tree) { IList <GH_Path> paths = tree.Paths; List <List <List <Point3d> > > list = new List <List <List <Point3d> > >(); IEnumerable <GH_Point> this_branch = new List <GH_Point>(); int pre_num1 = -1; int pre_num2 = -1; for (int i = 0; i < paths.Count; i++) { this_branch = tree.get_Branch(paths[i]).Cast <GH_Point>(); List <GH_Point> this_list = this_branch.ToList(); int now_num1 = GetPathNumber(paths[i], 1); int now_num2 = GetPathNumber(paths[i], 2); if (now_num1 != pre_num1) { list.Add(new List <List <Point3d> >()); list[now_num1].Add(new List <Point3d>()); pre_num1 = now_num1; } else if (now_num2 != pre_num2) { list[now_num1].Add(new List <Point3d>()); pre_num2 = now_num2; } for (int j = 0; j < this_list.Count; j++) { GH_Point raw_item = this_list[j]; Point3d item = new Point3d(); raw_item.CastTo(out item); list[now_num1][now_num2].Add(item); } } return(list); }
///Projection engines public static GH_Point ProjectPointToTopo(Mesh topoMesh, Point3d pt) { GH_Point ghPoint = new GH_Point(); Ray3d ray = new Ray3d(pt, moveDir); double t = Rhino.Geometry.Intersect.Intersection.MeshRay(topoMesh, ray); if (t >= 0.0) { GH_Convert.ToGHPoint(ray.PointAt(t), GH_Conversion.Primary, ref ghPoint); } else { Ray3d rayOpp = new Ray3d(pt, -moveDir); double tOpp = Rhino.Geometry.Intersect.Intersection.MeshRay(topoMesh, rayOpp); if (tOpp >= 0.0) { GH_Convert.ToGHPoint(rayOpp.PointAt(tOpp), GH_Conversion.Primary, ref ghPoint); } else { return(null); } } return(ghPoint); }
/// <summary> /// Converts a point into a GH_Point /// </summary> /// <param name="pt">The point to convert</param> /// <returns>The GH_Point</returns> public static GH_Point ConvertToGHPoint(Point3d pt) { GH_Point ghp = new GH_Point(); bool c = GH_Convert.ToGHPoint(pt, GH_Conversion.Both, ref ghp); return(ghp); }
private List <Vector> GetVectorsFromTree <T>(GH_Structure <T> tree) where T : IGH_Goo { var output = new List <Vector>(); for (int i = 0; i < tree.Branches.Count; i++) { var branchItems = tree[i].Count * 3; output.Add(new Vector(branchItems)); for (int j = 0; j < branchItems; j++) { if (tree[i][j / 3] is GH_Point) { GH_Point p = tree[i][j / 3] as GH_Point; output[i][j] = p.Value[j % 3]; } else if (tree[i][j / 3] is GH_Vector) { GH_Vector p = tree[i][j / 3] as GH_Vector; output[i][j] = p.Value[j % 3]; } output[i].SetMagnitude(); } } return(output); }
public List <Brep> CreateDefBreps(GH_Structure <GH_Point> treePoints, GH_Structure <GH_Integer> treeConnect, Vector3d[] defVectors, double scale, double angle, Point3d center) { List <Brep> breps = new List <Brep>(); for (int j = 0; j < treePoints.PathCount; j++) { List <GH_Point> vertices = (List <GH_Point>)treePoints.get_Branch(j); var mesh = new Mesh(); List <GH_Integer> connect = (List <GH_Integer>)treeConnect.get_Branch(j); for (int i = 0; i < vertices.Count; i++) { GH_Point p = vertices[i]; Point3d new_p = Point3d.Add(p.Value, defVectors[connect[i].Value] * scale); mesh.Vertices.Add(new_p); } mesh.Faces.AddFace(0, 1, 5, 4); mesh.Faces.AddFace(1, 2, 6, 5); mesh.Faces.AddFace(2, 3, 7, 6); mesh.Faces.AddFace(0, 3, 7, 4); mesh.Faces.AddFace(4, 5, 6, 7); mesh.Faces.AddFace(0, 1, 2, 3); Brep new_brep = Brep.CreateFromMesh(mesh, false); Vector3d vecAxis = new Vector3d(0, 0, 1); new_brep.Rotate(angle, vecAxis, center); breps.Add(new_brep); } return(breps); }
public static bool CheckHaltingConditions(GH_Point traveller, Basis start, Basis outBasis, Vector3d previous, out bool add, StaticSettings settings) { var stop = settings.stop; var surface = settings.surface; var bounds = settings.bounds; var snapTol = settings.snapTol; var snapAngle = settings.snapAngle; add = false; if (stop && !previous.IsZero && CheckStopped(previous)) { return(false); } if (CheckIfOffSurface(outBasis, surface)) { return(false); } if (CheckInsideBounds(outBasis, traveller, bounds, ref add)) { return(false); } if (CheckIfOrbitting(outBasis, start, previous, snapTol, snapAngle, ref add)) { return(false); } add = true; return(true); }
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) { Instance i = null; DA.GetData <Instance>(0, ref i); GH_Point p = new GH_Point(new Rhino.Geometry.Point3d(i.Transformation.X, i.Transformation.Y, i.Transformation.Z)); GH_Number scale = new GH_Number(i.Transformation.Scale); GH_String name = new GH_String(i.Name); GH_String parent = new GH_String(i.Parent.Name); List <GH_Brep> surfaces = new List <GH_Brep>(); List <GH_Brep> inner = new List <GH_Brep>(); foreach (Surface srf in i.Parent.Surfaces) { surfaces.Add(new GH_Brep(srf.ToRhinoGeo(i.Transformation))); } DA.SetData(0, p); DA.SetData(1, name); DA.SetData(2, scale); DA.SetDataList(3, surfaces); DA.SetData(4, parent); DA.SetDataList(5, inner); }
/// <summary> /// Provides an user-friendly description of a <see cref="Slot"/>. /// Required by Grasshopper. /// </summary> /// <returns>A string.</returns> public override string ToString( ) { if (!IsValid) { return(IsValidWhyNot); } var pt = new GH_Point(AbsoluteCenter); var diagonal = new GH_Vector(Diagonal); var plane = new GH_Plane(BasePlane); var containment = ""; if (AllowsAnyModule) { containment = "all Modules"; } if (IsContradictory) { containment = "no Modules"; } if (!IsContradictory && !AllowsAnyModule) { var count = AllowedModuleNames.Count; if (count == 1) { containment = "Module '" + AllowedModuleNames[0] + "'"; } else { containment = count + " Modules"; } } return("Slot allows placement of " + containment + ". Slot dimensions are " + diagonal + ", center is at " + pt + ", base plane is " + plane + "."); }
/// <summary> /// Casts the <see cref="Slot"/> to a <see cref="GH_Point"/> (from /// <see cref="AbsoluteCenter"/>, to a <see cref="Box"/> (from /// <see cref="Cage"/>) or to a <see cref="Brep"/> (from /// <see cref="Cage"/>). Required by Grasshopper for automatic type /// casting. /// </summary> /// <param name="target">The target Grasshopper geometry.</param> /// <returns>True when successful.</returns> public bool CastTo <T>(out T target) { if (typeof(T) == typeof(GH_Point)) { var absoluteCenter = new GH_Point(AbsoluteCenter); target = (T)absoluteCenter.Duplicate(); return(true); } if (typeof(T) == typeof(GH_Vector)) { var diagonal = new GH_Vector(Diagonal); target = (T)diagonal.Duplicate(); return(true); } if (typeof(T) == typeof(GH_Box)) { var box = new GH_Box(Cage); target = (T)box.Duplicate(); return(true); } if (typeof(T) == typeof(GH_Brep)) { var boxBrep = new GH_Brep(Cage.ToBrep()); target = (T)boxBrep.Duplicate(); return(true); } target = default; return(false); }
private static bool CheckInsideBounds(Basis outBasis, GH_Point traveller, GH_Brep bounds, ref bool add) { // check if ptOut is inside bounds, if they are given if (bounds.IsValid && !bounds.Value.IsPointInside(outBasis.Point.Value, 0.001d, false)) { Curve curve; Curve[] overlaps; Point3d[] intersections; curve = Curve.CreateControlPointCurve(new Point3d[] { traveller.Value, outBasis.Point.Value }); Rhino.Geometry.Intersect.Intersection.CurveBrep(curve, bounds.Value, 0.001d, out overlaps, out intersections); // if we're outside the bounds, but there is an intersection, add that intersection point to the results // if there are no intersections it's because we're starting from outside the bounds, don't add these if (intersections.Length > 0) { outBasis.Point.Value = intersections[0]; add = true; } return(true); } return(false); }
/// <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) { List <GH_Brep> OutputBreps = new List <GH_Brep>(); List <GH_Brep> SourceBreps = new List <GH_Brep>(); int Number = default(int); GH_Point SourcePt = default(GH_Point); if (!DA.GetDataList <GH_Brep>(0, SourceBreps)) { return; } if (!DA.GetData(1, ref SourcePt)) { return; } if (!DA.GetData(2, ref Number)) { return; } if (SourceBreps.Count < Math.Abs(Number)) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "面的块数大于SourceBreps的块数"); Number = SourceBreps.Count; } OutputBreps = SourceBreps.OrderByDescending(item => - item.Value.ClosestPoint(SourcePt.Value).DistanceTo(SourcePt.Value)).ToList(); DA.SetDataList(0, OutputBreps.GetRange(0, Number)); }
///<summary> /// Verify validity of each input set with each error handled w/ separate message ///</summary> public bool FullErrorCheck(GH_Point pt, GH_Mesh msh, GH_Number tol, GH_Integer step, GH_Vector vec) { bool flag = true; flag = flag && MeshTolVecErrorCheck(msh, tol, vec); flag = flag && PointStepErrorCheck(pt, step); return(flag); }
public void GeneratePreViewMeshVertices(GH_Structure <IGH_GeometricGoo> inGeoTree) { string key = "Leopard(" + this.InstanceGuid + ")"; RhinoDoc.ActiveDoc.Layers.Add("Leopard_Preview", System.Drawing.Color.Maroon); int layer = RhinoDoc.ActiveDoc.Layers.Find("Leopard_Preview", true); Rhino.DocObjects.RhinoObject[] obj = RhinoDoc.ActiveDoc.Objects.FindByUserString(key, "*", true); if (obj.Length == 0) //if no preview item { int count = 0; foreach (IGH_GeometricGoo goo in inGeoTree.AllData(false)) { PlanktonMesh pMesh = new PlanktonMesh(); Mesh mesh; if (!goo.CastTo <Mesh>(out mesh)) { RhinoApp.WriteLine("input invalid"); } pMesh = mesh.ToPlanktonMesh(); PlanktonXYZ[] xyz = pMesh.Vertices.GetPositions(); List <Point3d> oVertices = new List <Point3d>(); for (int i = 0; i < xyz.Length; i++) { oVertices.Add(xyz[i].ToPoint3d()); } count++; int vCount = 0; foreach (Point3d p in oVertices) { string keyV = "Leopard(" + this.InstanceGuid + vCount + ")"; Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes(); att.SetUserString(keyV, count.ToString()); att.LayerIndex = layer; GH_Point point = new GH_Point(p); if (goo is IGH_BakeAwareData) { IGH_BakeAwareData data = (IGH_BakeAwareData)point; Guid guid; data.BakeGeometry(RhinoDoc.ActiveDoc, att, out guid); } vCount++; } } } }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Surface surface = new GH_Surface(); GH_String lvlbtm = new GH_String(""); GH_String style = new GH_String(""); GH_String layer = new GH_String(""); GH_Number taperAng = new GH_Number(0); GH_Number height = new GH_Number(); GH_Point stop = new GH_Point(); GH_Point sbtm = new GH_Point(); GH_Boolean structural = new GH_Boolean(true); List <Parameter> param = new List <Parameter>(); if (!DA.GetDataList <Parameter>("Parameters", param)) { param = new List <Parameter>(); } DA.GetData <GH_Surface>("Surface", ref surface); DA.GetData <GH_String>("Layer", ref layer); //DA.GetData<GH_String>("Style", ref style); DA.GetData <GH_Number>("taperAngle", ref taperAng); DA.GetData <GH_Number>("height", ref height); Slab s = new Slab(); s.FamilyOrStyle = style.Value; s.TypeOrLayer = layer.Value; s.levelbottom = lvlbtm.Value; s.structural = structural.Value; s.surface = new Profile(); s.surface.profile = new List <Loop>(); Loop loop = new Loop() { outline = new List <Component>() }; foreach (Rhino.Geometry.BrepEdge be in surface.Value.Edges) { loop.outline.Add(be.ToNurbsCurve().ToGrevitCurve()); } s.surface.profile.Add(loop); s.height = height.Value; s.parameters = param; //s.top = ComponentUtilities.GHPoint2Point(stop); //s.bottom = ComponentUtilities.GHPoint2Point(sbtm); s.slope = taperAng.Value; s.GID = this.InstanceGuid.ToString(); //SetPreview(s.GID, surface.Value); DA.SetData("GrevitComponent", s); }
/// <summary> /// Compute the closest point and index from the tree using our constructed index. /// </summary> private (GH_Point[], GH_Integer[]) FindClosePt(GH_Point gpt, GH_Integer gcount, GH_Integer gidx) { var cloud = pointCloudList[gidx.Value]; KdTreeNode <double, int>[] results = cloud.GetNearestNeighbours(PtToArray(gpt), gcount.Value); var indexList = (from node in results select new GH_Integer(node.Value)).ToArray(); var pointList = (from node in results select new GH_Point(PtFromArray(node.Point))).ToArray(); return(pointList, indexList); }
// Casting to GH Data Types public bool ConvertToGH_Point <T>(ref T target) { if (Location.Count == 1) { object obj = new GH_Point(Location[0]); target = (T)obj; return(true); } return(false); }
public static ResthopperObject GetResthopperPoint(GH_Point goo) { var pt = goo.Value; ResthopperObject rhObj = new ResthopperObject(); rhObj.Type = pt.GetType().FullName; rhObj.Data = JsonConvert.SerializeObject(pt, GeometryResolver.Settings); return(rhObj); }
public static List <IGH_GeometricGoo> ConvertPointsToGeo(List <Point3d> pts) { List <IGH_GeometricGoo> geos = new List <IGH_GeometricGoo>(); for (int i = 0; i < pts.Count; i++) { GH_Point point = new GH_Point(pts[i]); geos.Add(point); } return(geos); }
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); }
internal static IEnumerable <IGH_Goo> PromptPoint(UIDocument doc, string prompt) { IGH_Goo goo = null; if (PickPoint(doc, prompt + " : ", out var point)) { goo = new GH_Point(point.ToRhino().Scale(Revit.ModelUnits)); } yield return(goo); }
internal static IEnumerable <IGH_Goo> PromptPoint(UIDocument doc, string prompt) { IGH_Goo goo = null; if (PickPoint(doc, prompt + " : ", out var point)) { goo = new GH_Point(point.ToPoint3d()); } yield return(goo); }
internal static IEnumerable <IGH_Goo> PromptPoint(string prompt) { IGH_Goo goo = null; if (PickPoint(prompt + " : ", out var point)) { goo = new GH_Point(point.ToRhino()); } yield return(goo); }
public void GetPointsVectors(out GH_Point[] pts, out GH_Vector[] vecs) { pts = new GH_Point[Particles.Count]; vecs = new GH_Vector[Particles.Count]; for (int i = 0; i < Particles.Count; i++) { pts[i] = new GH_Point(Particles[i].pos); vecs[i] = new GH_Vector(Particles[i].vel); } }
public void GetPointsVectors(out GH_Point[] pts, out GH_Vector[] vecs) { pts = new GH_Point[Agents.Count]; vecs = new GH_Vector[Agents.Count]; for (int i = 0; i < Agents.Count; i++) { pts[i] = new GH_Point(Agents[i].position); vecs[i] = new GH_Vector(Agents[i].velocity); } }
public SuperPoint(GH_Point pp) { Point3d p = pp.Value; data.uvs = ""; data.normals = ""; data.faces = ""; data.vertices = new List<double>(); data.vertices.Add(Math.Round(p.Y * 1, 3)); data.vertices.Add(Math.Round(p.Z * 1, 3)); data.vertices.Add(Math.Round(p.X * 1, 3)); }
public SuperPoint(GH_Point pp, string guid) { parentGuid = guid; Point3d p = pp.Value; data.uvs = ""; data.normals = ""; data.faces = ""; data.vertices = new List<double>(); data.vertices.Add(Math.Round(p.Y * 1, 3)); data.vertices.Add(Math.Round(p.Z * 1, 3)); data.vertices.Add(Math.Round(p.X * 1, 3)); }
public void Add(Point3d position, bool wrapped) { if (Count >= size) { structure.RemoveData(structure.get_FirstItem(false)); if(structure.get_Branch(0).Count == 0) { structure.RemovePath(new GH_Path(0)); } } IGH_Goo pt = new GH_Point(position); if (wrapped) { structure.Append(pt, new GH_Path(nextPathIndex)); nextPathIndex++; } else { structure.Append(pt, new GH_Path(nextPathIndex)); } }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Surface surface = new GH_Surface(); GH_String level = new GH_String(); GH_String family = new GH_String(""); GH_String type = new GH_String(""); GH_Boolean structural = new GH_Boolean(false); GH_Number slope = new GH_Number(0.0); List<Parameter> parameters = new List<Parameter>(); if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>(); DA.GetData<GH_Surface>("Surface", ref surface); GH_Point slopeTopPoint = new GH_Point(surface.Value.Edges[0].PointAtStart); GH_Point slopeBottomPoint = new GH_Point(surface.Value.Edges[0].PointAtEnd); //DA.GetData<GH_String>("Family", ref family); //DA.GetData<GH_String>("Type", ref type); DA.GetData<GH_String>("Levelbottom", ref level); DA.GetData<GH_Boolean>("Structural", ref structural); DA.GetData<GH_Point>("SlopeTopPoint", ref slopeTopPoint); DA.GetData<GH_Point>("SlopeBottomPoint", ref slopeBottomPoint); DA.GetData<GH_Number>("Slope", ref slope); Slab slab = new Slab(); slab.FamilyOrStyle = family.Value; slab.TypeOrLayer = type.Value; slab.levelbottom = level.Value; slab.structural = structural.Value; slab.surface = new Profile(); slab.surface.profile = new List<Loop>(); Loop loop = new Loop(); loop.outline = new List<Component>(); foreach (Rhino.Geometry.BrepEdge be in surface.Value.Edges) { loop.outline.Add(be.ToNurbsCurve().ToGrevitCurve()); } slab.surface.profile.Add(loop); slab.parameters = parameters; slab.top = slopeTopPoint.ToGrevitPoint(); slab.bottom = slopeBottomPoint.ToGrevitPoint(); slab.slope = slope.Value; slab.GID = this.InstanceGuid.ToString(); DA.SetData("GrevitComponent", slab); }
protected override void SolveInstance(IGH_DataAccess DA) { Instance i = null; DA.GetData<Instance>(0, ref i); GH_Point p = new GH_Point(new Rhino.Geometry.Point3d(i.Transformation.X, i.Transformation.Y, i.Transformation.Z)); GH_Number scale = new GH_Number(i.Transformation.Scale); GH_String name = new GH_String(i.Name); GH_String parent = new GH_String(i.Parent.Name); List<GH_Brep> surfaces = new List<GH_Brep>(); List<GH_Brep> inner = new List<GH_Brep>(); foreach (Surface srf in i.Parent.Surfaces) surfaces.Add(new GH_Brep(srf.ToRhinoGeo(i.Transformation))); DA.SetData(0, p); DA.SetData(1, name); DA.SetData(2, scale); DA.SetDataList(3, surfaces); DA.SetData(4, parent); DA.SetDataList(5, inner); }
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); }
public void Add(Point3d position) { IGH_Goo pt = new GH_Point(position); structure.Append(pt, new GH_Path(nextPathIndex)); }
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); }
protected override void SolveInstance(IGH_DataAccess DA) { GH_String content = new GH_String(); GH_Point location = new GH_Point(); GH_String view = new GH_String(); List<Parameter> parameters = new List<Parameter>(); if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>(); DA.GetData<GH_Point>("Location", ref location); DA.GetData<GH_String>("Text", ref content); DA.GetData<GH_String>("View", ref view); TextNote textnote = new TextNote(); textnote.text = content.Value; textnote.view = view.Value; textnote.location = location.ToGrevitPoint(); textnote.parameters = parameters; textnote.GID = this.InstanceGuid.ToString(); DA.SetData("GrevitComponent", textnote); }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Surface surface = new GH_Surface(); GH_String lvlbtm = new GH_String(""); GH_String style = new GH_String(""); GH_String layer = new GH_String(""); GH_Number taperAng = new GH_Number(0); GH_Number height = new GH_Number(); GH_Point stop = new GH_Point(); GH_Point sbtm = new GH_Point(); GH_Boolean structural = new GH_Boolean(true); List<Parameter> param = new List<Parameter>(); if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>(); DA.GetData<GH_Surface>("Surface", ref surface); DA.GetData<GH_String>("Layer", ref layer); //DA.GetData<GH_String>("Style", ref style); DA.GetData<GH_Number>("taperAngle", ref taperAng); DA.GetData<GH_Number>("height", ref height); Slab s = new Slab(); s.FamilyOrStyle = style.Value; s.TypeOrLayer = layer.Value; s.levelbottom = lvlbtm.Value; s.structural = structural.Value; s.surface = new Surface(); s.surface.outline = new List<Component>(); foreach (Rhino.Geometry.BrepEdge be in surface.Value.Edges) { s.surface.outline.Add(be.ToNurbsCurve().ToGrevitCurve()); } s.height = height.Value; s.parameters = param; //s.top = ComponentUtilities.GHPoint2Point(stop); //s.bottom = ComponentUtilities.GHPoint2Point(sbtm); s.slope = taperAng.Value; s.GID = this.InstanceGuid.ToString(); //SetPreview(s.GID, surface.Value); DA.SetData("GrevitComponent", s); }
protected override void SolveInstance(IGH_DataAccess DA) { SpatialGraph gph = new SpatialGraph(); int indx = 0; if (!DA.GetData(0, ref gph)) return; if (!DA.GetData(1, ref indx)) return; if (indx > gph.nodes.Count - 1) indx = 0; GH_Point ghPoint = new GH_Point(gph.nodes[indx]); int[] neighbors = gph.NeighboringIndexesOf(indx); double[] weights = gph.NeighboringWeightsOf(indx); List<Line> lines = gph.EdgesToLines(); List<GH_Line> ghLines = new List<GH_Line>(); foreach (int neighbor in neighbors) ghLines.Add(new GH_Line(new Line(gph.nodes[indx], gph.nodes[neighbor]))); DA.SetData(0, ghPoint); DA.SetDataList(1, neighbors); DA.SetDataList(2, ghLines); DA.SetDataList(3, weights); }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Point curve = new GH_Point(); DA.GetData<GH_Point>("Point", ref curve); GH_String layer = new GH_String(string.Empty); DA.GetData<GH_String>("Layer", ref layer); DrawingPoint arc = new DrawingPoint(); arc.point = curve.ToGrevitPoint(); arc.TypeOrLayer = layer.Value; arc.GID = this.InstanceGuid.ToString(); DA.SetData("GrevitComponent", arc); }
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); }
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); }