/// <summary> /// You will need to override this method to solve the component. /// </summary> /// <param name="DA">Grasshopper's DataAccess interface</param> protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { /// Note that you will need to call the SolveInstance method of the base class to process the default parameters and connect them to the framework. base.SolveInstance(DA); DA.SetData(1, ((SimpleAssessmentExample)this.Assessment).EmbodiedEnergy); DA.SetData(2, "Embodied energy: " + ((SimpleAssessmentExample)this.Assessment).EmbodiedEnergy.ToString("0.00")); }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { double v = -1.0; DA.GetData(1, ref v); if (!FriedChiken.isInitialized) { Rhino.Geometry.Curve c = null; if (!DA.GetData(0, ref c)) return; if (c.IsPolyline()) { Rhino.Geometry.Polyline pl = null; if (c.TryGetPolyline(out pl)) { nNewNodes = pl.Count(); nElements = nNewNodes - 1; newNodes.Clear(); newNodes.AddRange(pl); lGeometry.Clear(); for (int i = 0; i < nElements; i++) { lGeometry.Add(new Rhino.Geometry.Line(newNodes[i], newNodes[i + 1])); } mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]); } List<mikity.NumericalMethodHelper.elements.isoparametricElement> e = new List<mikity.NumericalMethodHelper.elements.isoparametricElement>(); for (int i = 0; i < nElements; i++) { e.Add(new mikity.NumericalMethodHelper.elements.isoparametricElement(i, i + 1)); } lCV.Clear(); pS = new GH_particleSystem(particles); for (int i = 0; i < e.Count; i++) { lCV.Add(new constrainVolumeObject(v / nElements)); lCV[i].addElement(e[i]); pS.Value.addObject(lCV[i]); } lGeometry.Clear(); for (int i = 0; i < nElements; i++) { lGeometry.Add(new Rhino.Geometry.Line(pS.Value.particles[i, 0], pS.Value.particles[i, 1], pS.Value.particles[i, 2], pS.Value.particles[i + 1, 0], pS.Value.particles[i + 1, 1], pS.Value.particles[i + 1, 2])); } } } else { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted"); return; } } else { if (lCV != null && v > 0) { for (int i = 0; i < lCV.Count; i++) { lCV[i].refVolume = v / nElements; } } } DA.SetData(0, pS); DA.SetDataList(1, newNodes); }