本文整理汇总了C#中IGH_DataAccess.GetDataList方法的典型用法代码示例。如果您正苦于以下问题:C# IGH_DataAccess.GetDataList方法的具体用法?C# IGH_DataAccess.GetDataList怎么用?C# IGH_DataAccess.GetDataList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGH_DataAccess
的用法示例。
在下文中一共展示了IGH_DataAccess.GetDataList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SolveInstance
/// <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)
{
//Input
List<Line> bars = new List<Line>();
if(!DA.GetDataList(0, bars)) { return; }
List<Point3d> nodes = new List<Point3d>();
if(!DA.GetDataList(1, nodes)) { return; }
List<double> displacements = new List<double>();
if(!DA.GetDataList(2, displacements)) { return; }
List<Color> gradientColours = new List<Color>();
if(!DA.GetDataList(3, gradientColours)) { return; }
//Calculate
lines = new List<Line>();
for(int i=0; i<bars.Count; i++)
{
lines.Add(bars[i]);
}
List<double> barDispl = calcBarDisplacements(bars, nodes, displacements);
colours = mapDisplToColour(barDispl, gradientColours);
}
示例2: GetInputs
protected override bool GetInputs(IGH_DataAccess da)
{
agents = new List<IQuelea>();
emitters = new List<AbstractEmitterType>();
environment = new WorldEnvironmentType();
// Then we need to access the input parameters individually.
// When data cannot be extracted from a parameter, we should abort this
// method.
if (!da.GetDataList(nextInputIndex++, agents)) return false;
if (!da.GetDataList(nextInputIndex++, emitters)) return false;
da.GetData(nextInputIndex++, ref environment);
// We should now validate the data and warn the user if invalid data is
// supplied.
if (agents.Count <= 0)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, RS.agentsCountErrorMessage);
return false;
}
if (emitters.Count <= 0)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, RS.emittersCountErrorMessage);
return false;
}
return true;
}
示例3: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
string name = null;
GH_RobotSystem robotSystem = null;
var initCommandsGH = new List<GH_Command>();
var targetsA = new List<GH_Target>();
var targetsB = new List<GH_Target>();
var multiFileIndices = new List<int>();
double stepSize = 1;
if (!DA.GetData(0, ref name)) { return; }
if (!DA.GetData(1, ref robotSystem)) { return; }
if (!DA.GetDataList(2, targetsA)) { return; }
DA.GetDataList(3, targetsB);
DA.GetDataList(4, initCommandsGH);
DA.GetDataList(5, multiFileIndices);
if (!DA.GetData(6, ref stepSize)) { return; }
var initCommands = initCommandsGH.Count > 0 ? new Robots.Commands.Group(initCommandsGH.Select(x => x.Value)) : null;
var targets = new List<IEnumerable<Target>>();
targets.Add(targetsA.Select(x => x.Value));
if (targetsB.Count > 0) targets.Add(targetsB.Select(x => x.Value));
var program = new Program(name, robotSystem.Value, targets, initCommands, multiFileIndices, stepSize);
DA.SetData(0, new GH_Program(program));
if (program.Code != null)
{
var path = DA.ParameterTargetPath(2);
var structure = new GH_Structure<GH_String>();
for (int i = 0; i < program.Code.Count; i++)
{
var tempPath = path.AppendElement(i);
for (int j = 0; j < program.Code[i].Count; j++)
{
structure.AppendRange(program.Code[i][j].Select(x => new GH_String(x)), tempPath.AppendElement(j));
}
}
DA.SetDataTree(1, structure);
}
DA.SetData(2, program.Duration);
if (program.Warnings.Count > 0)
{
DA.SetDataList(3, program.Warnings);
this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Warnings in program");
}
if (program.Errors.Count > 0)
{
DA.SetDataList(4, program.Errors);
this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Errors in program");
}
}
示例4: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
GH_RobotSystem robotSystem = null;
var targets = new List<GH_Target>();
var prevJointsText = new List<GH_String>();
bool drawMeshes = false;
if (!DA.GetData(0, ref robotSystem)) { return; }
if (!DA.GetDataList(1, targets)) { return; }
DA.GetDataList(2, prevJointsText);
if (!DA.GetData(3, ref drawMeshes)) { return; }
List<double[]> prevJoints = null;
if (prevJointsText.Count > 0)
{
prevJoints = new List<double[]>();
foreach (var text in prevJointsText)
{
if (text != null)
{
string[] jointsText = text.Value.Split(',');
var prevJoint = new double[jointsText.Length];
for (int i = 0; i < jointsText.Length; i++)
if (!GH_Convert.ToDouble_Secondary(jointsText[i], ref prevJoint[i])) throw new Exception(" Previous joints not formatted correctly.");
prevJoints.Add(prevJoint);
}
}
}
var kinematics = robotSystem.Value.Kinematics(targets.Select(x => x.Value), prevJoints, drawMeshes);
var errors = kinematics.SelectMany(x => x.Errors);
if (errors.Count() > 0)
{
this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Errors in solution");
}
var strings = kinematics.SelectMany(x => x.Joints).Select(x => new GH_Number(x).ToString());
var joints = string.Join(",", strings);
var planes = kinematics.SelectMany(x => x.Planes);
if (drawMeshes)
{
var meshes = kinematics.SelectMany(x => x.Meshes);
DA.SetDataList(0, meshes.Select(x => new GH_Mesh(x)));
}
DA.SetData(1, joints);
DA.SetDataList(2, planes.Select(x => new GH_Plane(x)));
DA.SetDataList(3, errors);
}
示例5: GetInputs
protected override bool GetInputs(IGH_DataAccess da)
{
obs = new List<Brep>();
cont = new List<Brep>();
if (!da.GetData(0, ref u_count)) return false;
if (!da.GetData(1, ref v_count)) return false;
if (!da.GetData(2, ref srf)) return false;
da.GetDataList(3, cont);
da.GetDataList(4, obs);
return true;
}
示例6: GetInputs
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
protected override bool GetInputs(IGH_DataAccess da)
{
breps = new List<Brep>();
obs = new List<Brep>();
if (!da.GetData(nextInputIndex++, ref x_count)) return false;
if (!da.GetData(nextInputIndex++, ref y_count)) return false;
if (!da.GetData(nextInputIndex++, ref z_count)) return false;
if (!da.GetDataList(nextInputIndex++, breps)) return false;
da.GetDataList(4, obs);
return true;
}
示例7: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
List<GH_Element> elements = new List<GH_Element>();
List<GH_Support> supports = new List<GH_Support>();
List<GH_Load> loads = new List<GH_Load>();
int modelType = 0;
if (!DA.GetDataList<GH_Element>(0, elements))
{
return;
}
if (!DA.GetDataList<GH_Support>(1, supports))
{
return;
}
if (!DA.GetDataList<GH_Load>(2, loads))
{
return;
}
if (!DA.GetData(3, ref modelType))
{
return;
}
//Clear current structure... Perhaps change this for a more parametric approach, or opening existing files
GH_Model model = null;
switch (modelType)
{
case 0:
model = new GH_Model(ModelType.Truss2D);
break;
case 1:
model = new GH_Model(ModelType.Full3D);
break;
default:
throw new Exception("Model type does not exist or not yet implemented");
}
model.Elements = elements;
model.Loads = loads;
model.Supports = supports;
model.AssembleSharpModel();
DA.SetData(0, model);
}
示例8: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
bool reset = false;
DA.GetData(6, ref reset);
if (reset)
Particle.Zones.Clear(); //= new List<Particle>();
List<Point3d> origin = new List<Point3d>();
DA.GetDataList<Point3d>(1, origin);
foreach (Point3d pt in origin) //FIXME: remove duplicates for each component calling
Particle.Create(pt);
double D = 25;
DA.GetData<double>(2, ref D);
Particle.step_size = D;
double dk = 1.2;
DA.GetData<double>(4, ref dk);
Particle.eatable_distance = D * dk;
double di = 4;
DA.GetData<double>(3, ref di);
Particle.infuence_distance = D * di;
int loop = 1;
DA.GetData<int>(5, ref loop);
List<Point3d> food = new List<Point3d>();
bool haveFood = (DA.GetDataList<Point3d>(0, food));
if (haveFood)
{
while (loop > 0)
{
for (int i = food.Count() - 1; i >= 0; i--)
{
// if food is eatable
if (Particle.IsEatable(food[i]))
{
food.RemoveAt(i); // eat it
//Print("food at index " + i + " was removed");
}
}
Particle.Move();
loop--;
}
}
DA.SetDataList(0, Particle.Connections());
}
示例9: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
#if DEBUG
Rhino.RhinoApp.WriteLine("Assessment " + this.Name + " is solving");
#endif
// check dependencies
if (this.m_Assessment == null) { return; }
// check if the controller is online
SOGrasshopperController con = SOGrasshopperController.GetInstance(OnPingDocument());
List<SODesigner_GHData> designersList = new List<SODesigner_GHData>();
DA.GetDataList<SODesigner_GHData>(0, designersList);
this.m_Assessment.ClearDesigners();
foreach (SODesigner_GHData data in designersList)
{
this.m_Assessment.AddDesigner(data.Value);
}
List<SOAnalysis_GHData> analysisList = new List<SOAnalysis_GHData>();
DA.GetDataList<SOAnalysis_GHData>(1, analysisList);
this.m_Assessment.ClearAnalysis();
foreach (SOAnalysis_GHData data in analysisList)
{
this.m_Assessment.AddAnalysis(data.Value);
}
List<SOAssessment_GHData> assessmentsList = new List<SOAssessment_GHData>();
DA.GetDataList<SOAssessment_GHData>(2, assessmentsList);
this.m_Assessment.ClearAssessments();
foreach (SOAssessment_GHData data in assessmentsList)
{
this.m_Assessment.AddAssessment(data.Value);
}
// run the assessment
try
{
this.m_Assessment.RunAssessment();
}
catch (Exception)
{
return;
}
SOAssessment_GHData assessment = new SOAssessment_GHData(this.m_Assessment);
DA.SetData(0, assessment);
}
示例10: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
SpringMesh iSpringMesh = new SpringMesh();
List<Circle> iCircles = new List<Circle>();
double iBendingStiffness = double.NaN;
double iStiffness = double.NaN;
List<double> iPlanarRegionBendingStiffness = new List<double>();
List<double> iPlanarRegionStiffness = new List<double>();
DA.GetData<SpringMesh>(0, ref iSpringMesh);
DA.GetDataList<Circle>(1, iCircles);
DA.GetData<double>(2, ref iBendingStiffness);
DA.GetData<double>(3, ref iStiffness);
DA.GetDataList<double>(4, iPlanarRegionBendingStiffness);
DA.GetDataList<double>(5, iPlanarRegionStiffness);
SpringMesh oSpringMesh = new SpringMesh(iSpringMesh);
foreach (Edge edge in iSpringMesh.Edges)
{
edge.RestLength = Utils.Distance(oSpringMesh.Vertices[edge.FirstVertexIndex].Position, oSpringMesh.Vertices[edge.SecondVertexIndex].Position);
edge.Stiffness = iStiffness;
if (edge.SecondTriangleIndex >= 0)
{
edge.RestAngle = Utils.AngleBetweenTwoTriangles(
iSpringMesh.Vertices[edge.FirstVertexIndex].Position,
iSpringMesh.Vertices[edge.SecondVertexIndex].Position,
iSpringMesh.Vertices[edge.FirstAdjacentVertexIndex].Position,
iSpringMesh.Vertices[edge.SecondAdjacentVertexIndex].Position
);
}
edge.BendingStiffness = iBendingStiffness;
}
for (int i = 0; i < oSpringMesh.Vertices.Count; i++)
for (int j = 0; j < iCircles.Count; j++ )
if (Utils.Distance(iCircles[j].Center, oSpringMesh.Vertices[i].Position) <= iCircles[j].Radius)
{
foreach (Edge edge in oSpringMesh.Edges)
if (edge.FirstVertexIndex == i || edge.SecondVertexIndex == i)
{
edge.Stiffness = iPlanarRegionStiffness[j];
edge.RestAngle = Math.PI;
edge.BendingStiffness = iPlanarRegionBendingStiffness[j];
}
break;
}
DA.SetData(0, oSpringMesh);
}
示例11: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
string name = String.Empty;
bool gravityOn = false;
Vector3d gravField = Vector3d.Unset;
List<PointLoadCarrier> ptLds = new List<PointLoadCarrier>();
if (!DA.GetData(0, ref name)) { return; }
if (!DA.GetData(1, ref gravityOn)) { return; }
if (!DA.GetData(2, ref gravField)) { return; }
if(!DA.GetDataList(3, ptLds))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "No pointloads provided");
}
WR_LoadCombination loadComb;
if(gravityOn)
{
loadComb = new WR_LoadCombination(name, new WR_Vector(gravField.X, gravField.Y, gravField.Z));
}
else
{
loadComb = new WR_LoadCombination(name, gravityOn);
}
foreach (PointLoadCarrier plc in ptLds)
{
loadComb.AddPointLoad(plc.CIForce, plc.CIMoment, plc.CIPos);
}
DA.SetData(0, loadComb);
}
示例12: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
// Indata
WR_Structure structure = null;
bool go = false;
List<int> modes = new List<int>();
double sFac = 0;
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
if (!DA.GetData(0, ref structure)) { return; }
if (!DA.GetData(1, ref go)) { return; }
if (!DA.GetDataList(2, modes)) { return; }
if (!DA.GetData(3, ref sFac)) { return; }
if (go)
{
_resElems = new List<ResultElement>();
_log.Clear();
watch.Restart();
// Solve
WR_ModeShapeOptimizer optimizer = new WR_ModeShapeOptimizer(structure);
watch.Stop();
_log.Add(String.Format("Initialising: {0}ms", watch.ElapsedMilliseconds));
watch.Restart();
//Run
optimizer.Run(modes, sFac);
watch.Stop();
_log.Add(String.Format("Run mode shape optimization: {0}ms", watch.ElapsedMilliseconds));
watch.Restart();
// Extract results
List<WR_IElement> elems = structure.GetAllElements();
for (int i = 0; i < elems.Count; i++)
{
if (elems[i] is WR_Element3d)
{
WR_Element3d el3d = (WR_Element3d)elems[i];
ResultElement re = new ResultElement(el3d);
_resElems.Add(re);
}
}
watch.Stop();
_log.Add(String.Format("Extract results: {0}ms", watch.ElapsedMilliseconds));
}
DA.SetDataList(0, _log);
DA.SetDataList(1, _resElems);
}
示例13: SolveInstance
/// <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)
{
var parameters = new List<RhinoNestKernel.Nesting.RhinoNestObject>();
//Declaration.
var Object = new List<Guid>();
var orientation = new OrientationGoo();
var criterion = new CriterionGoo();
var copies = 0;
var priority = 0;
//clear value and get the objects.
if (!da.GetDataList(0, Object)) return;
da.GetData(1, ref copies);
da.GetData(2, ref priority);
da.GetData(3, ref orientation);
da.GetData(4, ref criterion);
var organizer = new RhinoNestKernel.Curves.OrganizeObjects(Object);
var res = organizer.Sort();
foreach (var rhinoNestObject in organizer.Result)
{
rhinoNestObject.Parameters.Priority = priority;
rhinoNestObject.Parameters.Copies = copies;
rhinoNestObject.Parameters.Criterion = criterion.Value.Constraint;
rhinoNestObject.Parameters.Orientation = orientation.Value.Constraint;
parameters.Add(rhinoNestObject);
}
//Put the list to Output.
da.SetDataList(0, parameters);
}
示例14: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
string name = null;
GH_Plane tcp = null;
double weight = 0;
GH_Mesh mesh = null;
GH_Point centroid = null;
List<GH_Plane> planes = new List<GH_Plane>();
if (!DA.GetData(0, ref name)) { return; }
if (!DA.GetData(1, ref tcp)) { return; }
DA.GetDataList(2, planes);
if (!DA.GetData(3, ref weight)) { return; }
DA.GetData(4, ref centroid);
DA.GetData(5, ref mesh);
var tool = new Tool(tcp.Value, name, weight, centroid?.Value, mesh?.Value);
if (planes.Count > 0)
{
if (planes.Count != 4)
this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, " Calibration input must be 4 planes");
else
tool.FourPointCalibration(planes[0].Value, planes[1].Value, planes[2].Value, planes[3].Value);
}
DA.SetData(0, new GH_Tool(tool));
DA.SetData(1, tool.Tcp);
}
示例15: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
// Declare a variable for the input
List<Point3d> positions = new List<Point3d>();
bool UX = false;
bool UY = false;
bool UZ = false;
bool RX = false;
bool RY = false;
bool RZ = false;
// Use the DA object to retrieve the data inside the first input parameter.
// If the retieval fails (for example if there is no data) we need to abort.
if (!DA.GetDataList<Point3d>(0, positions)) { return; }
if (!DA.GetData(1, ref UX )) { return; }
if (!DA.GetData(2, ref UY)) { return; }
if (!DA.GetData(3, ref UZ)) { return; }
if (!DA.GetData(4, ref RX)) { return; }
if (!DA.GetData(5, ref RY)) { return; }
if (!DA.GetData(6, ref RZ)) { return; }
//Create node constrain
GH_NodeSupport nodeSupport = new GH_NodeSupport(positions, UX, UY, UZ, RX, RY, RZ);
//Return
DA.SetData(0, nodeSupport);
}