protected override void SolveInstance(IGH_DataAccess DA) { GH_Program program = null; DA.GetData(0, ref program); var path = DA.ParameterTargetPath(0); var cellTargets = program.Value.Targets; var groupCount = cellTargets[0].ProgramTargets.Count; var planes = new GH_Structure<GH_Plane>(); var joints = new GH_Structure<GH_Number>(); var configuration = new GH_Structure<GH_String>(); var deltaTime = new GH_Structure<GH_Number>(); for (int i = 0; i < groupCount; i++) { var tempPath = path.AppendElement(i); for (int j = 0; j < cellTargets.Count; j++) { planes.AppendRange(cellTargets[j].ProgramTargets[i].Kinematics.Planes.Select(x => new GH_Plane(x)), tempPath.AppendElement(j)); joints.AppendRange(cellTargets[j].ProgramTargets[i].Kinematics.Joints.Select(x => new GH_Number(x)), tempPath.AppendElement(j)); configuration.Append(new GH_String(cellTargets[j].ProgramTargets[i].Kinematics.Configuration.ToString()), tempPath); deltaTime.Append(new GH_Number(cellTargets[j].DeltaTime), tempPath); } } DA.SetDataTree(0, planes); DA.SetDataTree(1, joints); DA.SetDataTree(2, configuration); DA.SetDataTree(3, deltaTime); }
internal static IEnumerable <GH_String> GetBraceSSection(object steelFigure) { var ghSecStrings = new GH_Structure <GH_String>(); switch (steelFigure) { case StbSecSteelBrace_S_Same figure: ghSecStrings.Append(new GH_String(figure.shape + "(" + figure.strength_main + ")")); break; case StbSecSteelBrace_S_NotSame figure: ghSecStrings.Append(new GH_String(figure.pos + ":" + figure.shape + "(" + figure.strength_main + ")")); break; case StbSecSteelBrace_S_ThreeTypes figure: ghSecStrings.Append(new GH_String(figure.pos + ":" + figure.shape + "(" + figure.strength_main + ")")); break; } return(ghSecStrings); }
internal static IEnumerable <GH_String> GetSlabRcSection(object slabFigure, string strength) { var ghSecString = new GH_Structure <GH_String>(); switch (slabFigure) { case StbSecSlab_RC_Straight figure: ghSecString.Append(new GH_String("t=" + figure.depth + "(" + strength + ")")); break; case StbSecSlab_RC_Taper figure: ghSecString.Append(new GH_String("t=" + figure.pos + ":" + figure.depth + "(" + strength + ")")); break; case StbSecSlab_RC_Haunch figure: ghSecString.Append(new GH_String("t=" + figure.pos + ":" + figure.depth + "(" + strength + ")")); break; } return(ghSecString); }
/// <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) { GH_Structure <IGH_GeometricGoo> tree; if (!DA.GetDataTree(0, out tree)) { return; } GH_Structure <IGH_GeometricGoo> pointTree = new GH_Structure <IGH_GeometricGoo>(); GH_Structure <IGH_GeometricGoo> curveTree = new GH_Structure <IGH_GeometricGoo>(); GH_Structure <IGH_GeometricGoo> srfTree = new GH_Structure <IGH_GeometricGoo>(); GH_Structure <IGH_GeometricGoo> brepTree = new GH_Structure <IGH_GeometricGoo>(); GH_Structure <IGH_GeometricGoo> meshTree = new GH_Structure <IGH_GeometricGoo>(); for (int i = 0; i < tree.Branches.Count; i++) { var path = tree.Paths[i]; var branch = tree.Branches[i]; for (int n = 0; n < branch.Count; n++) { var item = branch[n]; if (item is GH_Point) { pointTree.Append(item, path); } else if (item is GH_Curve || item is GH_Line || item is GH_Arc || item is GH_Circle || item is GH_Rectangle) { curveTree.Append(item, path); } else if (item is GH_Surface) { srfTree.Append(item, path); } else if (item is GH_Brep || item is GH_Box) { brepTree.Append(item, path); } else if (item is GH_Mesh) { meshTree.Append(item, path); } } } DA.SetDataTree(0, pointTree); DA.SetDataTree(1, curveTree); DA.SetDataTree(2, srfTree); DA.SetDataTree(3, brepTree); DA.SetDataTree(4, meshTree); }
private void AddLeaf(object data, GH_Structure <IGH_Goo> tree) { //paths must have at least one element if (!_path.Any()) { _path.Add(0); } var path = new GH_Path(_path.ToArray()); tree.Append(Utilities.TryConvertItemToNative(data, _converter), path); }
internal static IEnumerable <GH_String> GetBeamRcSection(object rcFigure, string strength) { var ghSecStrings = new GH_Structure <GH_String>(); switch (rcFigure) { case StbSecBeam_RC_Straight figure: ghSecStrings.Append(new GH_String("BD-" + figure.width + "x" + figure.depth + "(" + strength + ")")); break; case StbSecBeam_RC_Haunch figure: ghSecStrings.Append(new GH_String(figure.pos + ": BD-" + figure.width + "x" + figure.depth + "(" + strength + ")")); break; case StbSecBeam_RC_Taper figure: ghSecStrings.Append(new GH_String(figure.pos + ": BD-" + figure.width + "x" + figure.depth + "(" + strength + ")")); break; case StbSecBeam_SRC_Straight figure: ghSecStrings.Append(new GH_String("BD-" + figure.width + "x" + figure.depth + "(" + strength + ")")); break; case StbSecBeam_SRC_Haunch figure: ghSecStrings.Append(new GH_String(figure.pos + ": BD-" + figure.width + "x" + figure.depth + "(" + strength + ")")); break; case StbSecBeam_SRC_Taper figure: ghSecStrings.Append(new GH_String(figure.pos + ": BD-" + figure.width + "x" + figure.depth + "(" + strength + ")")); break; } return(ghSecStrings); }
internal static IEnumerable <GH_String> GetColumnSSection(object steelFigure) { var ghSecStrings = new GH_Structure <GH_String>(); switch (steelFigure) { case StbSecSteelColumn_S_Same figure: ghSecStrings.Append(new GH_String(figure.shape + "(" + figure.strength_main + ")")); break; case StbSecSteelColumn_S_NotSame figure: ghSecStrings.Append(new GH_String(figure.pos + ":" + figure.shape + "(" + figure.strength_main + ")")); break; case StbSecSteelColumn_S_ThreeTypes figure: ghSecStrings.Append(new GH_String(figure.pos + ":" + figure.shape + "(" + figure.strength_main + ")")); break; case StbSecSteelColumn_SRC_Same figure: ghSecStrings.Append(GetColumnSrcInnerSteelShape(figure.Item, string.Empty)); break; case StbSecSteelColumn_SRC_NotSame figure: ghSecStrings.Append(GetColumnSrcInnerSteelShape(figure.Item, figure.pos.ToString())); break; case StbSecSteelColumn_SRC_ThreeTypes figure: ghSecStrings.Append(GetColumnSrcInnerSteelShape(figure.Item, figure.pos.ToString())); break; } return(ghSecStrings); }
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)); } }
/// <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) { this.Message = Constants.Constants.PARALLEL_MESSAGE; this.AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, Constants.Constants.PARALLEL_WARNING); int processorCount = Environment.ProcessorCount - 1; double docTollerance = DocumentTolerance(); GH_Structure <GH_Mesh> ghPatches = new GH_Structure <GH_Mesh>(); GH_Structure <GH_Curve> inGhCurves = new GH_Structure <GH_Curve>(); bool areCurvesOK = DA.GetDataTree(0, out inGhCurves); CheckGetDataConversion(areCurvesOK); ConcurrentDictionary <GH_Path, Mesh> patchesPA = new ConcurrentDictionary <GH_Path, Mesh>(); Parallel.ForEach(inGhCurves.Paths, new ParallelOptions { MaxDegreeOfParallelism = processorCount }, path => { Polyline firstPolyline = null; inGhCurves.get_DataItem(path, 0).Value.TryGetPolyline(out firstPolyline); if ((!firstPolyline.IsValid ? true : firstPolyline == null)) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Impossible convert the first Curve in Polyline"); } List <Curve> otherBranchCurves = new List <Curve>(); for (int i = 0; i < inGhCurves.get_Branch(path).Count; i++) { otherBranchCurves.Add(inGhCurves.get_DataItem(path, i).Value.DuplicateCurve()); } patchesPA[path] = Mesh.CreatePatch(firstPolyline, docTollerance, null, otherBranchCurves, null, null, true, 1); }); foreach (KeyValuePair <GH_Path, Mesh> patch in patchesPA) { GH_Mesh ghPatchMesh = null; if (GH_Convert.ToGHMesh(patch.Value, GH_Conversion.Both, ref ghPatchMesh)) { ghPatches.Append(ghPatchMesh, patch.Key); } else { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Conversion Failed"); return; } } DA.SetDataTree(0, ghPatches); }
/// <summary> /// Transform the posed meshes rom the forward kinematics to a datatree /// </summary> /// <param name="forwardKinematics"> The forward kinematics the posed meshes will be extracted from. </param> /// <returns> The data tree structure with all the posed meshes. </returns> public GH_Structure <GH_Mesh> GetPosedMeshesDataTree(ForwardKinematics forwardKinematics) { // Create data tree for output of alle posed meshes GH_Structure <GH_Mesh> meshes = new GH_Structure <GH_Mesh>(); { // Robot pose meshes List <Mesh> posedInternalAxisMeshes = forwardKinematics.PosedInternalAxisMeshes; // Data tree path GH_Path path = new GH_Path(0); // Save the posed meshes for (int i = 0; i < posedInternalAxisMeshes.Count; i++) { meshes.Append(new GH_Mesh(posedInternalAxisMeshes[i]), path); } // Extenal axis meshes List <List <Mesh> > posedExternalAxisMeshes = forwardKinematics.PosedExternalAxisMeshes; // Loop over all the external axes for (int i = 0; i < posedExternalAxisMeshes.Count; i++) { // Data tree path path = new GH_Path(i + 1); // Save the posed meshes for (int j = 0; j < posedExternalAxisMeshes[i].Count; j++) { meshes.Append(new GH_Mesh(posedExternalAxisMeshes[i][j]), path); } } } // Return the data tree stucture return(meshes); }
/// <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) { DA.GetDataTree(0, out GH_Structure <IGH_Goo> objtree); if (objtree.IsEmpty) { listenees.Clear(); btnpress.Clear(); listening = false; AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " No Synapse connected"); return; } GH_Structure <GH_ObjectWrapper> outputs = new GH_Structure <GH_ObjectWrapper>(); for (int bi = 0; bi < objtree.Branches.Count; bi++) { List <IGH_Goo> objs = objtree.Branches[bi]; GH_Path pth = objtree.Paths[bi]; for (int ii = 0; ii < objs.Count; ii++) { GH_ObjectWrapper obj = objs[ii] as GH_ObjectWrapper; if (obj.Value is Control ctrl) { if (ctrl.ID == Guid.Empty.ToString() || ctrl.ID == string.Empty) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, string.Format(" a {0} isn't initialized properly with a valid ID\n this is a code error; contact dev", ctrl.GetType())); listening = true; } else if (!listenees.Contains(ctrl.ID)) { Relisten(ctrl); listening = true; } else if (!listening) { listening = true; } else { outputs.Append(GetCtrlValue(ctrl), pth); } } else { listening = false; // not an Eto control } } } DA.SetDataTree(0, outputs); }
private void getSlices(MeshVoxeliser mvox, ref GH_Structure <GH_Mesh> caveslices, ref GH_Structure <GH_Mesh> sectionboxes, ref GH_Structure <GH_Curve> grid, ref GH_Structure <GH_Curve> links) { foreach (Mesh b in mvox.spanBoxes) { sectionboxes.Append(new GH_Mesh(b)); } foreach (StructuralSpan sp in mvox.structuralSpans) { caveslices.Append(new GH_Mesh(sp.slice)); foreach (Line l in sp.xGrid) { grid.Append(new GH_Curve(l.ToNurbsCurve())); } foreach (Line l in sp.yGrid) { grid.Append(new GH_Curve(l.ToNurbsCurve())); } foreach (Line l in sp.linkElements) { links.Append(new GH_Curve(l.ToNurbsCurve())); } } }
private GH_Structure <GH_Curve> TrimNodes(GH_Structure <GH_Curve> untrimmedNodes, double trimLengthBase, double trimLengthTop, out List <Point3d> trimPoints) { GH_Structure <GH_Curve> trimmedNodes = new GH_Structure <GH_Curve>(); trimPoints = new List <Point3d>(); for (int i = 0; i < untrimmedNodes.PathCount; i++) { GH_Path pth = new GH_Path(i); for (int j = 0; j < untrimmedNodes.get_Branch(i).Count; j++) { if (j == 0) { GH_Curve crv = untrimmedNodes.get_DataItem(pth, j); double discardLength = crv.Value.GetLength() - trimLengthBase; double t = 0; crv.Value.LengthParameter(discardLength, out t); Point3d splitpt = crv.Value.PointAt(t); trimPoints.Add(splitpt); Curve[] splits = crv.Value.Split(t); trimmedNodes.Append(new GH_Curve(splits[1]), pth); } else { GH_Curve crv = untrimmedNodes.get_DataItem(pth, j); double t = 0; crv.Value.LengthParameter(trimLengthTop, out t); Point3d splitpt = crv.Value.PointAt(t); trimPoints.Add(splitpt); Curve[] splits = crv.Value.Split(t); trimmedNodes.Append(new GH_Curve(splits[0]), pth); } } } return(trimmedNodes); }
/// <summary> /// Represents list of edges as tree of Rhino.Line /// </summary> /// <returns>Tree of Rhino.Line</returns> public GH_Structure <GH_Curve> RhinoLinesTree() { GH_Structure <GH_Curve> ls = new GH_Structure <GH_Curve>(); List <int> cs = new List <int>(); int i = 0; List <RREdge> le = new List <RREdge>(); foreach (RREdge e in edg) { if (e.CrossSection != null) { i = cs.IndexOf(e.CrossSection.ID); if (i == -1) { cs.Add(e.CrossSection.ID); i = cs.Count - 1; } ls.Append(e.GetGHCurve(), new GH_Path(i)); } else { le.Add(e); } } GH_Path zp = new GH_Path(cs.Count - 1); foreach (RREdge e in le) { ls.Append(e.GetGHCurve(), zp); } return(ls); }
public static GH_Structure <GH_String> MakeReportForRequests( Dictionary <OSMTag, int> foundItemsForResult) { var output = new GH_Structure <GH_String>(); var tInfo = CultureInfo.CurrentCulture.TextInfo; var requestMetaDataItems = foundItemsForResult.Keys.ToList(); for (int i = 0; i < requestMetaDataItems.Count; i++) { var metaData = requestMetaDataItems[i]; GH_Path path = new GH_Path(i); var count = foundItemsForResult[metaData]; var colorForItem = GetPerceptualColorForTreeItem(requestMetaDataItems.Count, i); var metaDataTitle = tInfo.ToTitleCase(metaData.Name); output.Append(new GH_String(metaDataTitle), path); output.Append(new GH_String(metaData.ToString()), path); output.Append(new GH_String($"{count} found"), path); output.Append(new GH_String(colorForItem.ToString())); if (metaData.Key != null) { var titleName = tInfo.ToTitleCase(metaData.Key.Name); output.Append(new GH_String(titleName), path); var layerName = titleName + "::" + metaDataTitle; output.Append(new GH_String(layerName), path); // Layer path helper } else { output.Append(new GH_String("(No Parent Feature)"), path); output.Append(new GH_String(metaDataTitle + "::"), path); // Layer path helper } if (!string.IsNullOrEmpty(metaData.Description)) { output.Append(new GH_String($"Defined as: {metaData.Description}"), path); } } return(output); }
public GH_Structure <GH_Brep> Wall(IEnumerable <StbWall> walls, IEnumerable <StbOpen> opens) { var brepList = new GH_Structure <GH_Brep>(); if (walls == null) { return(brepList); } foreach ((StbWall wall, int i) in walls.Select((wall, index) => (wall, index))) { StbWallOffset[] offsets = wall.StbWallOffsetList; var curveList = new PolylineCurve[2]; double thickness = BrepMaker.Wall.GetThickness(_sections, wall); string[] nodeIds = wall.StbNodeIdOrder.Split(' '); var wallPts = new List <Point3d>(); foreach (string nodeId in nodeIds) { var offsetVec = new Vector3d(); if (offsets != null) { foreach (StbWallOffset offset in offsets) { if (nodeId == offset.id_node) { offsetVec = new Vector3d(offset.offset_X, offset.offset_Y, offset.offset_Z); break; } } } StbNode node = _nodes.First(n => n.id == nodeId); wallPts.Add(new Point3d(node.X, node.Y, node.Z) + offsetVec); } wallPts.Add(wallPts[0]); var centerCurve = new PolylineCurve(wallPts); Vector3d normal = Vector3d.CrossProduct(centerCurve.TangentAtEnd, centerCurve.TangentAtStart); curveList[0] = new PolylineCurve(wallPts.Select(pt => pt + normal * thickness / 2)); curveList[1] = new PolylineCurve(wallPts.Select(pt => pt - normal * thickness / 2)); Brep brep = Brep.CreateFromLoft(curveList, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0].CapPlanarHoles(_tolerance[0]); CheckBrepOrientation(brep); brep = ApplyWallOpen(opens, wall, wallPts, brep); brepList.Append(new GH_Brep(brep), new GH_Path(0, i)); } return(brepList); }
public static GH_Structure <GH_Number> MultidimensionalArrayToGHTree(double[,] array) { GH_Structure <GH_Number> tree = new GH_Structure <GH_Number>(); if (array.Length != 0) { for (int i = 0; i < array.GetLength(0); i++) { for (int j = 0; j < array.GetLength(1); j++) { tree.Append(new GH_Number(array[i, j]), new GH_Path(i)); } } } return(tree); }
protected override void SolveInstance(IGH_DataAccess DA) { bool run = false; DA.GetData(2, ref run); if (run) { List <FD_Group> FD_G_list = new List <FD_Group>(); GH_Structure <GH_String> undelete = new GH_Structure <GH_String>(); DA.GetDataList(0, FD_G_list); DA.GetDataTree(1, out undelete); undelete.Flatten(); FD_Commander.Select(); foreach (GH_String item in undelete.Branches[0]) { FD_Commander.Unselect(item.ToString()); } FD_Commander.Delete(); int counter = 0; ids = new GH_Structure <GH_String>(); foreach (FD_Group item in FD_G_list) { GH_Path path = new GH_Path(counter); item.Create_Set(); foreach (FD_Object sub_item in item.Members) { ids.Append(new GH_String(sub_item.ID), path); } counter++; } Message = "Done"; DA.SetData(0, Message); } DA.SetDataTree(1, ids); }
public override void DoWork(Action <string, double> ReportProgress, Action Done) { try { Parent.Message = "Receiving..."; var Converter = (Parent as ReceiveLocalComponent).Converter; Base @base = null; try { @base = Operations.Receive(localDataId).Result; } catch (Exception e) { RuntimeMessages.Add((GH_RuntimeMessageLevel.Warning, "Failed to receive local data.")); Done(); return; } if (Converter.CanConvertToNative(@base)) { var converted = Converter.ConvertToNative(@base); data = new GH_Structure <IGH_Goo>(); data.Append(Utilities.TryConvertItemToNative(converted, Converter)); } else if (@base.GetDynamicMembers().Count() == 1) { var treeBuilder = new TreeBuilder(Converter); var tree = treeBuilder.Build(@base[@base.GetDynamicMembers().ElementAt(0)]); data = tree; } else { data = new GH_Structure <IGH_Goo>(); data.Append(new GH_SpeckleBase(@base)); } } catch (Exception e) { // If we reach this, something happened that we weren't expecting... Log.CaptureException(e); RuntimeMessages.Add((GH_RuntimeMessageLevel.Error, "Something went terribly wrong... " + e.Message)); Parent.Message = "Error"; } Done(); }
/// <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) { GH_Structure <IGH_Goo> dataTree = new GH_Structure <IGH_Goo>(); int pair = 0; bool loop = false; if (!DA.GetDataTree(0, out dataTree)) { return; } if (!DA.GetData(1, ref pair)) { return; } if (!DA.GetData(2, ref loop)) { return; } pair = Math.Max(1, pair); GH_Structure <IGH_Goo> outTree = new GH_Structure <IGH_Goo>(); for (int i = 0; i < dataTree.Branches.Count; i++) { var branch = dataTree.Branches[i]; var path = dataTree.Paths[i]; int endIndex = branch.Count; if (!loop) { endIndex -= (pair - 1); } for (int n = 0; n < endIndex; n++) { var npath = path.AppendElement(n); for (int t = 0; t < pair; t++) { outTree.Append(branch[(n + t) % branch.Count], npath); } } } DA.SetDataTree(0, outTree); }
/// <summary> /// Build curves representation with 1D tree structure. branch = one curve /// </summary> /// <param name="inputPlanes"></param> /// <returns></returns> private GH_Structure <GH_Curve> BuildStructureAsCurves(GH_Structure <GH_Plane> inputPlanes) { GH_Structure <GH_Curve> curves = new GH_Structure <GH_Curve>(); for (int i = 0; i < inputPlanes.PathCount; i++) { List <Point3d> cp = new List <Point3d>(); foreach (GH_Plane plane in inputPlanes.get_Branch(i)) { cp.Add(plane.Value.Origin); } GH_Curve cv = new GH_Curve(); cv.CastFrom(Curve.CreateInterpolatedCurve(cp, 3)); curves.Append(cv, new GH_Path(i)); } return(curves); }
public GH_Structure <GH_Point> PointTree(List <int> xyzD) { GH_Structure <GH_Point> pointTree = new GH_Structure <GH_Point>(); GH_Structure <GH_Number> dataTree = this.DataTree(); for (int i = 0; i < dataTree.Paths.Count; i++) { GH_Path path = dataTree.Paths[i]; pointTree.Append( new GH_Point(new Point3d( dataTree.get_DataItem(path, xyzD[0]).Value, dataTree.get_DataItem(path, xyzD[1]).Value, dataTree.get_DataItem(path, xyzD[2]).Value)), path); } return(pointTree); }
public static GH_Structure <GH_Brep> MakeTreeForBuildings(Dictionary <OSMTag, List <Brep> > foundBuildings) { var output = new GH_Structure <GH_Brep>(); var i = 0; foreach (var entry in foundBuildings) { for (int j = 0; j < entry.Value.Count; j++) { GH_Path path = new GH_Path(i, j); // Need to ensure even an empty path exists to enable data matching output.EnsurePath(path); // Need to ensure even an empty path exists to enable data matching GH_Brep brepForPath = new GH_Brep(entry.Value[j]); output.Append(brepForPath, path); } i++; } return(output); }
private GH_Structure <GH_String> MakeTreeFromListofLists(List <List <List <string> > > tagsByGeometryPath) { var tagsAsTree = new GH_Structure <GH_String>(); for (var i = 0; i < tagsByGeometryPath.Count; i++) { for (var j = 0; j < tagsByGeometryPath[i].Count; j++) { var path = new GH_Path(i, j); for (var k = 0; k < tagsByGeometryPath[i][j].Count; k++) { var tagReadout = new GH_String(tagsByGeometryPath[i][j][k]); tagsAsTree.Append(tagReadout, path); } } } return(tagsAsTree); }
public GH_Structure <GH_Line> Posts() { var lines = new GH_Structure <GH_Line>(); if (_members.StbPosts == null) { return(lines); } foreach ((StbPost member, int i) in _members.StbPosts.Select((member, index) => (member, index))) { StbNode nodeBottom = _nodes.First(node => node.id == member.id_node_bottom); StbNode nodeTop = _nodes.First(node => node.id == member.id_node_top); lines.Append(GH_LineFromStbNode(nodeBottom, nodeTop), new GH_Path(0, i)); } return(lines); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { object obj = new object(); if (!DA.GetData(0, ref obj)) { return; } CalcCore.ICalc myCalc; IGH_Goo myGoo = obj as IGH_Goo; myGoo.CastTo <CalcCore.ICalc>(out myCalc); int index = 0; if (!DA.GetData(1, ref index)) { return; } var myOutput = myCalc.GetOutputs()[index]; var myList = new List <double[]>(); if (myOutput.Type == CalcCore.CalcValueType.LISTOFDOUBLEARRAYS) { var temp = myOutput as CalcCore.CalcListOfDoubleArrays; GH_Structure <GH_Number> myTree = new GH_Structure <GH_Number>(); for (int i = 0; i < temp.Value.Count; i++) { for (int j = 0; j < temp.Value[i].Length; j++) { GH_Path myPath = new GH_Path(i); myTree.Append(new GH_Number(temp.Value[i][j]), myPath); } } DA.SetDataTree(0, myTree); } else { var tree = new GH_Structure <GH_String>(); tree.Append(new GH_String(myOutput.ValueAsString)); DA.SetDataTree(0, tree); } return; }
public GH_Structure <GH_Line> Beams() { var lines = new GH_Structure <GH_Line>(); if (_members.StbBeams == null) { return(lines); } foreach ((StbBeam member, int i) in _members.StbBeams.Select((member, index) => (member, index))) { StbNode nodeStart = _nodes.First(node => node.id == member.id_node_start); StbNode nodeEnd = _nodes.First(node => node.id == member.id_node_end); lines.Append(GH_LineFromStbNode(nodeStart, nodeEnd), new GH_Path(0, i)); } return(lines); }
public static GH_Structure <GH_Curve> MakeTreeForWays(Dictionary <OSMTag, List <PolylineCurve> > foundWays) { var output = new GH_Structure <GH_Curve>(); var i = 0; foreach (var entry in foundWays) { for (int j = 0; j < entry.Value.Count; j++) { GH_Path path = new GH_Path(i, j); // Need to ensure even an empty path exists to enable data matching output.EnsurePath(path); // Need to ensure even an empty path exists to enable data matching GH_Curve lineForPath = new GH_Curve(entry.Value[j]); output.Append(lineForPath, path); } i++; } return(output); }
/// <summary> /// Registers all the input parameters for this component. /// </summary> protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddNumberParameter("Sun Hours", "sunhours", "The hours of the year relevant for shade analysis", GH_ParamAccess.list); pManager.AddNumberParameter("Start of winter period", "winterStart", "Start of the winter period given as an hour", GH_ParamAccess.item); pManager.AddNumberParameter("End of winter period", "winterEnd", "End of the winter period given as an hour", GH_ParamAccess.item); pManager.AddTextParameter("Winter Weight String", "winterCoef", "Coeficient for the analysis in the winter period, given as text. The order should be Shade, View and Glare", GH_ParamAccess.item); pManager.AddTextParameter("Summer Weight String", "summerCoef", "Coeficient for the analysis in the Summer period, given as text. The order should be Shade, View and Glare", GH_ParamAccess.item); //Assign initial default data to the input parameters. Param_Number param0 = (Param_Number)pManager[0]; Param_Number param1 = (Param_Number)pManager[1]; Param_Number param2 = (Param_Number)pManager[2]; Param_String param3 = (Param_String)pManager[3]; Param_String param4 = (Param_String)pManager[4]; //Assign default sun hours GH_Structure <GH_Number> data = new GH_Structure <GH_Number>(); foreach (double d in new List <int>(new[] { 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 33, 34, 35, 36, 37, 38, 39, 40, 56, 57, 58, 59, 60, 61, 62, 63, 64, 80, 81, 82, 83, 84, 85, 86, 87, 88, 104, 105, 106, 107, 108, 109, 110, 111, 112, 128, 129, 130, 131, 132, 133, 134, 135, 136, 152, 153, 154, 155, 156, 157, 158, 159, 160, 176, 177, 178, 179, 180, 181, 182, 183, 184, 200, 201, 202, 203, 204, 205, 206, 207, 208, 224, 225, 226, 227, 228, 229, 230, 231, 232, 248, 249, 250, 251, 252, 253, 254, 255, 256, 272, 273, 274, 275, 276, 277, 278, 279, 280, 296, 297, 298, 299, 300, 301, 302, 303, 304, 320, 321, 322, 323, 324, 325, 326, 327, 328, 344, 345, 346, 347, 348, 349, 350, 351, 352, 368, 369, 370, 371, 372, 373, 374, 375, 376, 392, 393, 394, 395, 396, 397, 398, 399, 400, 416, 417, 418, 419, 420, 421, 422, 423, 424, 440, 441, 442, 443, 444, 445, 446, 447, 448, 464, 465, 466, 467, 468, 469, 470, 471, 472, 488, 489, 490, 491, 492, 493, 494, 495, 496, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2200, 2201, 2202, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2226, 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2262, 2263, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2298, 2310, 2311, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, 2345, 2346, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2442, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2598, 2599, 2600, 2601, 2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2629, 2630, 2631, 2632, 2633, 2634, 2646, 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2658, 2670, 2671, 2672, 2673, 2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 2718, 2719, 2720, 2721, 2722, 2723, 2724, 2725, 2726, 2727, 2728, 2729, 2730, 2742, 2743, 2744, 2745, 2746, 2747, 2748, 2749, 2750, 2751, 2752, 2753, 2754, 2766, 2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2790, 2791, 2792, 2793, 2794, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 2802, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2850, 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874, 2886, 2887, 2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898, 2910, 2911, 2912, 2913, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941, 2942, 2943, 2944, 2945, 2946, 2957, 2958, 2959, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969, 2970, 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3029, 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3125, 3126, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138, 3139, 3149, 3150, 3151, 3152, 3153, 3154, 3155, 3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3197, 3198, 3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3211, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3234, 3235, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3269, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3293, 3294, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3305, 3306, 3307, 3317, 3318, 3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3341, 3342, 3343, 3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3365, 3366, 3367, 3368, 3369, 3370, 3371, 3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, 3400, 3401, 3402, 3403, 3413, 3414, 3415, 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, 3426, 3427, 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3444, 3445, 3446, 3447, 3448, 3449, 3450, 3451, 3461, 3462, 3463, 3464, 3465, 3466, 3467, 3468, 3469, 3470, 3471, 3472, 3473, 3474, 3475, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3495, 3496, 3497, 3498, 3499, 3509, 3510, 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518, 3519, 3520, 3521, 3522, 3523, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3544, 3545, 3546, 3547, 3557, 3558, 3559, 3560, 3561, 3562, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3581, 3582, 3583, 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3643, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689, 3690, 3691, 3701, 3702, 3703, 3704, 3705, 3706, 3707, 3708, 3709, 3710, 3711, 3712, 3713, 3714, 3715, 3725, 3726, 3727, 3728, 3729, 3730, 3731, 3732, 3733, 3734, 3735, 3736, 3737, 3738, 3739, 3749, 3750, 3751, 3752, 3753, 3754, 3755, 3756, 3757, 3758, 3759, 3760, 3761, 3762, 3763, 3773, 3774, 3775, 3776, 3777, 3778, 3779, 3780, 3781, 3782, 3783, 3784, 3785, 3786, 3787, 3797, 3798, 3799, 3800, 3801, 3802, 3803, 3804, 3805, 3806, 3807, 3808, 3809, 3810, 3811, 3821, 3822, 3823, 3824, 3825, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3845, 3846, 3847, 3848, 3849, 3850, 3851, 3852, 3853, 3854, 3855, 3856, 3857, 3858, 3859, 3869, 3870, 3871, 3872, 3873, 3874, 3875, 3876, 3877, 3878, 3879, 3880, 3881, 3882, 3883, 3893, 3894, 3895, 3896, 3897, 3898, 3899, 3900, 3901, 3902, 3903, 3904, 3905, 3906, 3907, 3917, 3918, 3919, 3920, 3921, 3922, 3923, 3924, 3925, 3926, 3927, 3928, 3929, 3930, 3931, 3941, 3942, 3943, 3944, 3945, 3946, 3947, 3948, 3949, 3950, 3951, 3952, 3953, 3954, 3955, 3965, 3966, 3967, 3968, 3969, 3970, 3971, 3972, 3973, 3974, 3975, 3976, 3977, 3978, 3979, 3989, 3990, 3991, 3992, 3993, 3994, 3995, 3996, 3997, 3998, 3999, 4000, 4001, 4002, 4003, 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022, 4023, 4024, 4025, 4026, 4027, 4037, 4038, 4039, 4040, 4041, 4042, 4043, 4044, 4045, 4046, 4047, 4048, 4049, 4050, 4051, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 4070, 4071, 4072, 4073, 4074, 4075, 4085, 4086, 4087, 4088, 4089, 4090, 4091, 4092, 4093, 4094, 4095, 4096, 4097, 4098, 4099, 4109, 4110, 4111, 4112, 4113, 4114, 4115, 4116, 4117, 4118, 4119, 4120, 4121, 4122, 4123, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4140, 4141, 4142, 4143, 4144, 4145, 4146, 4147, 4157, 4158, 4159, 4160, 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4181, 4182, 4183, 4184, 4185, 4186, 4187, 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4205, 4206, 4207, 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4217, 4218, 4219, 4229, 4230, 4231, 4232, 4233, 4234, 4235, 4236, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4289, 4290, 4291, 4301, 4302, 4303, 4304, 4305, 4306, 4307, 4308, 4309, 4310, 4311, 4312, 4313, 4314, 4315, 4325, 4326, 4327, 4328, 4329, 4330, 4331, 4332, 4333, 4334, 4335, 4336, 4337, 4338, 4339, 4349, 4350, 4351, 4352, 4353, 4354, 4355, 4356, 4357, 4358, 4359, 4360, 4361, 4362, 4363, 4373, 4374, 4375, 4376, 4377, 4378, 4379, 4380, 4381, 4382, 4383, 4384, 4385, 4386, 4387, 4397, 4398, 4399, 4400, 4401, 4402, 4403, 4404, 4405, 4406, 4407, 4408, 4409, 4410, 4411, 4421, 4422, 4423, 4424, 4425, 4426, 4427, 4428, 4429, 4430, 4431, 4432, 4433, 4434, 4435, 4445, 4446, 4447, 4448, 4449, 4450, 4451, 4452, 4453, 4454, 4455, 4456, 4457, 4458, 4459, 4469, 4470, 4471, 4472, 4473, 4474, 4475, 4476, 4477, 4478, 4479, 4480, 4481, 4482, 4483, 4493, 4494, 4495, 4496, 4497, 4498, 4499, 4500, 4501, 4502, 4503, 4504, 4505, 4506, 4507, 4517, 4518, 4519, 4520, 4521, 4522, 4523, 4524, 4525, 4526, 4527, 4528, 4529, 4530, 4531, 4541, 4542, 4543, 4544, 4545, 4546, 4547, 4548, 4549, 4550, 4551, 4552, 4553, 4554, 4555, 4565, 4566, 4567, 4568, 4569, 4570, 4571, 4572, 4573, 4574, 4575, 4576, 4577, 4578, 4579, 4589, 4590, 4591, 4592, 4593, 4594, 4595, 4596, 4597, 4598, 4599, 4600, 4601, 4602, 4603, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4645, 4646, 4647, 4648, 4649, 4650, 4651, 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4685, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, 4720, 4721, 4722, 4723, 4733, 4734, 4735, 4736, 4737, 4738, 4739, 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4757, 4758, 4759, 4760, 4761, 4762, 4763, 4764, 4765, 4766, 4767, 4768, 4769, 4770, 4771, 4781, 4782, 4783, 4784, 4785, 4786, 4787, 4788, 4789, 4790, 4791, 4792, 4793, 4794, 4795, 4805, 4806, 4807, 4808, 4809, 4810, 4811, 4812, 4813, 4814, 4815, 4816, 4817, 4818, 4819, 4829, 4830, 4831, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840, 4841, 4842, 4843, 4853, 4854, 4855, 4856, 4857, 4858, 4859, 4860, 4861, 4862, 4863, 4864, 4865, 4866, 4867, 4877, 4878, 4879, 4880, 4881, 4882, 4883, 4884, 4885, 4886, 4887, 4888, 4889, 4890, 4891, 4901, 4902, 4903, 4904, 4905, 4906, 4907, 4908, 4909, 4910, 4911, 4912, 4913, 4914, 4915, 4925, 4926, 4927, 4928, 4929, 4930, 4931, 4932, 4933, 4934, 4935, 4936, 4937, 4938, 4939, 4949, 4950, 4951, 4952, 4953, 4954, 4955, 4956, 4957, 4958, 4959, 4960, 4961, 4962, 4963, 4973, 4974, 4975, 4976, 4977, 4978, 4979, 4980, 4981, 4982, 4983, 4984, 4985, 4986, 4987, 4997, 4998, 4999, 5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5021, 5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029, 5030, 5031, 5032, 5033, 5034, 5035, 5046, 5047, 5048, 5049, 5050, 5051, 5052, 5053, 5054, 5055, 5056, 5057, 5058, 5059, 5070, 5071, 5072, 5073, 5074, 5075, 5076, 5077, 5078, 5079, 5080, 5081, 5082, 5083, 5094, 5095, 5096, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5104, 5105, 5106, 5107, 5118, 5119, 5120, 5121, 5122, 5123, 5124, 5125, 5126, 5127, 5128, 5129, 5130, 5131, 5142, 5143, 5144, 5145, 5146, 5147, 5148, 5149, 5150, 5151, 5152, 5153, 5154, 5155, 5166, 5167, 5168, 5169, 5170, 5171, 5172, 5173, 5174, 5175, 5176, 5177, 5178, 5179, 5190, 5191, 5192, 5193, 5194, 5195, 5196, 5197, 5198, 5199, 5200, 5201, 5202, 5203, 5214, 5215, 5216, 5217, 5218, 5219, 5220, 5221, 5222, 5223, 5224, 5225, 5226, 5227, 5238, 5239, 5240, 5241, 5242, 5243, 5244, 5245, 5246, 5247, 5248, 5249, 5250, 5251, 5262, 5263, 5264, 5265, 5266, 5267, 5268, 5269, 5270, 5271, 5272, 5273, 5274, 5275, 5286, 5287, 5288, 5289, 5290, 5291, 5292, 5293, 5294, 5295, 5296, 5297, 5298, 5310, 5311, 5312, 5313, 5314, 5315, 5316, 5317, 5318, 5319, 5320, 5321, 5322, 5334, 5335, 5336, 5337, 5338, 5339, 5340, 5341, 5342, 5343, 5344, 5345, 5346, 5358, 5359, 5360, 5361, 5362, 5363, 5364, 5365, 5366, 5367, 5368, 5369, 5370, 5382, 5383, 5384, 5385, 5386, 5387, 5388, 5389, 5390, 5391, 5392, 5393, 5394, 5406, 5407, 5408, 5409, 5410, 5411, 5412, 5413, 5414, 5415, 5416, 5417, 5418, 5430, 5431, 5432, 5433, 5434, 5435, 5436, 5437, 5438, 5439, 5440, 5441, 5442, 5454, 5455, 5456, 5457, 5458, 5459, 5460, 5461, 5462, 5463, 5464, 5465, 5466, 5478, 5479, 5480, 5481, 5482, 5483, 5484, 5485, 5486, 5487, 5488, 5489, 5490, 5502, 5503, 5504, 5505, 5506, 5507, 5508, 5509, 5510, 5511, 5512, 5513, 5514, 5526, 5527, 5528, 5529, 5530, 5531, 5532, 5533, 5534, 5535, 5536, 5537, 5538, 5550, 5551, 5552, 5553, 5554, 5555, 5556, 5557, 5558, 5559, 5560, 5561, 5562, 5574, 5575, 5576, 5577, 5578, 5579, 5580, 5581, 5582, 5583, 5584, 5585, 5586, 5598, 5599, 5600, 5601, 5602, 5603, 5604, 5605, 5606, 5607, 5608, 5609, 5610, 5622, 5623, 5624, 5625, 5626, 5627, 5628, 5629, 5630, 5631, 5632, 5633, 5634, 5646, 5647, 5648, 5649, 5650, 5651, 5652, 5653, 5654, 5655, 5656, 5657, 5658, 5670, 5671, 5672, 5673, 5674, 5675, 5676, 5677, 5678, 5679, 5680, 5681, 5682, 5694, 5695, 5696, 5697, 5698, 5699, 5700, 5701, 5702, 5703, 5704, 5705, 5706, 5718, 5719, 5720, 5721, 5722, 5723, 5724, 5725, 5726, 5727, 5728, 5729, 5730, 5742, 5743, 5744, 5745, 5746, 5747, 5748, 5749, 5750, 5751, 5752, 5753, 5754, 5766, 5767, 5768, 5769, 5770, 5771, 5772, 5773, 5774, 5775, 5776, 5777, 5778, 5790, 5791, 5792, 5793, 5794, 5795, 5796, 5797, 5798, 5799, 5800, 5801, 5802, 5814, 5815, 5816, 5817, 5818, 5819, 5820, 5821, 5822, 5823, 5824, 5825, 5826, 5838, 5839, 5840, 5841, 5842, 5843, 5844, 5845, 5846, 5847, 5848, 5849, 5850, 5862, 5863, 5864, 5865, 5866, 5867, 5868, 5869, 5870, 5871, 5872, 5873, 5874, 5886, 5887, 5888, 5889, 5890, 5891, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5910, 5911, 5912, 5913, 5914, 5915, 5916, 5917, 5918, 5919, 5920, 5921, 5922, 5934, 5935, 5936, 5937, 5938, 5939, 5940, 5941, 5942, 5943, 5944, 5945, 5946, 5958, 5959, 5960, 5961, 5962, 5963, 5964, 5965, 5966, 5967, 5968, 5969, 5970, 5982, 5983, 5984, 5985, 5986, 5987, 5988, 5989, 5990, 5991, 5992, 5993, 5994, 6006, 6007, 6008, 6009, 6010, 6011, 6012, 6013, 6014, 6015, 6016, 6017, 6018, 6030, 6031, 6032, 6033, 6034, 6035, 6036, 6037, 6038, 6039, 6040, 6041, 6042, 6054, 6055, 6056, 6057, 6058, 6059, 6060, 6061, 6062, 6063, 6064, 6065, 6066, 6078, 6079, 6080, 6081, 6082, 6083, 6084, 6085, 6086, 6087, 6088, 6089, 6090, 6102, 6103, 6104, 6105, 6106, 6107, 6108, 6109, 6110, 6111, 6112, 6113, 6114, 6126, 6127, 6128, 6129, 6130, 6131, 6132, 6133, 6134, 6135, 6136, 6137, 6138, 6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157, 6158, 6159, 6160, 6161, 6162, 6174, 6175, 6176, 6177, 6178, 6179, 6180, 6181, 6182, 6183, 6184, 6185, 6186, 6198, 6199, 6200, 6201, 6202, 6203, 6204, 6205, 6206, 6207, 6208, 6209, 6210, 6222, 6223, 6224, 6225, 6226, 6227, 6228, 6229, 6230, 6231, 6232, 6233, 6246, 6247, 6248, 6249, 6250, 6251, 6252, 6253, 6254, 6255, 6256, 6257, 6270, 6271, 6272, 6273, 6274, 6275, 6276, 6277, 6278, 6279, 6280, 6281, 6294, 6295, 6296, 6297, 6298, 6299, 6300, 6301, 6302, 6303, 6304, 6305, 6318, 6319, 6320, 6321, 6322, 6323, 6324, 6325, 6326, 6327, 6328, 6329, 6342, 6343, 6344, 6345, 6346, 6347, 6348, 6349, 6350, 6351, 6352, 6353, 6366, 6367, 6368, 6369, 6370, 6371, 6372, 6373, 6374, 6375, 6376, 6377, 6390, 6391, 6392, 6393, 6394, 6395, 6396, 6397, 6398, 6399, 6400, 6401, 6414, 6415, 6416, 6417, 6418, 6419, 6420, 6421, 6422, 6423, 6424, 6425, 6438, 6439, 6440, 6441, 6442, 6443, 6444, 6445, 6446, 6447, 6448, 6449, 6462, 6463, 6464, 6465, 6466, 6467, 6468, 6469, 6470, 6471, 6472, 6473, 6486, 6487, 6488, 6489, 6490, 6491, 6492, 6493, 6494, 6495, 6496, 6497, 6510, 6511, 6512, 6513, 6514, 6515, 6516, 6517, 6518, 6519, 6520, 6521, 6534, 6535, 6536, 6537, 6538, 6539, 6540, 6541, 6542, 6543, 6544, 6545, 6559, 6560, 6561, 6562, 6563, 6564, 6565, 6566, 6567, 6568, 6569, 6583, 6584, 6585, 6586, 6587, 6588, 6589, 6590, 6591, 6592, 6593, 6607, 6608, 6609, 6610, 6611, 6612, 6613, 6614, 6615, 6616, 6617, 6631, 6632, 6633, 6634, 6635, 6636, 6637, 6638, 6639, 6640, 6641, 6655, 6656, 6657, 6658, 6659, 6660, 6661, 6662, 6663, 6664, 6665, 6679, 6680, 6681, 6682, 6683, 6684, 6685, 6686, 6687, 6688, 6689, 6703, 6704, 6705, 6706, 6707, 6708, 6709, 6710, 6711, 6712, 6713, 6727, 6728, 6729, 6730, 6731, 6732, 6733, 6734, 6735, 6736, 6737, 6751, 6752, 6753, 6754, 6755, 6756, 6757, 6758, 6759, 6760, 6761, 6775, 6776, 6777, 6778, 6779, 6780, 6781, 6782, 6783, 6784, 6785, 6799, 6800, 6801, 6802, 6803, 6804, 6805, 6806, 6807, 6808, 6809, 6823, 6824, 6825, 6826, 6827, 6828, 6829, 6830, 6831, 6832, 6833, 6847, 6848, 6849, 6850, 6851, 6852, 6853, 6854, 6855, 6856, 6857, 6871, 6872, 6873, 6874, 6875, 6876, 6877, 6878, 6879, 6880, 6881, 6895, 6896, 6897, 6898, 6899, 6900, 6901, 6902, 6903, 6904, 6905, 6919, 6920, 6921, 6922, 6923, 6924, 6925, 6926, 6927, 6928, 6929, 6943, 6944, 6945, 6946, 6947, 6948, 6949, 6950, 6951, 6952, 6953, 6967, 6968, 6969, 6970, 6971, 6972, 6973, 6974, 6975, 6976, 6977, 6991, 6992, 6993, 6994, 6995, 6996, 6997, 6998, 6999, 7000, 7001, 7015, 7016, 7017, 7018, 7019, 7020, 7021, 7022, 7023, 7024, 7025, 7039, 7040, 7041, 7042, 7043, 7044, 7045, 7046, 7047, 7048, 7049, 7063, 7064, 7065, 7066, 7067, 7068, 7069, 7070, 7071, 7072, 7073, 7087, 7088, 7089, 7090, 7091, 7092, 7093, 7094, 7095, 7096, 7097, 7111, 7112, 7113, 7114, 7115, 7116, 7117, 7118, 7119, 7120, 7121, 7135, 7136, 7137, 7138, 7139, 7140, 7141, 7142, 7143, 7144, 7159, 7160, 7161, 7162, 7163, 7164, 7165, 7166, 7167, 7168, 7183, 7184, 7185, 7186, 7187, 7188, 7189, 7190, 7191, 7192, 7207, 7208, 7209, 7210, 7211, 7212, 7213, 7214, 7215, 7216, 7231, 7232, 7233, 7234, 7235, 7236, 7237, 7238, 7239, 7240, 7255, 7256, 7257, 7258, 7259, 7260, 7261, 7262, 7263, 7264, 7279, 7280, 7281, 7282, 7283, 7284, 7285, 7286, 7287, 7288, 7303, 7304, 7305, 7306, 7307, 7308, 7309, 7310, 7311, 7312, 7327, 7328, 7329, 7330, 7331, 7332, 7333, 7334, 7335, 7336, 7351, 7352, 7353, 7354, 7355, 7356, 7357, 7358, 7359, 7360, 7375, 7376, 7377, 7378, 7379, 7380, 7381, 7382, 7383, 7384, 7399, 7400, 7401, 7402, 7403, 7404, 7405, 7406, 7407, 7408, 7423, 7424, 7425, 7426, 7427, 7428, 7429, 7430, 7431, 7432, 7447, 7448, 7449, 7450, 7451, 7452, 7453, 7454, 7455, 7456, 7471, 7472, 7473, 7474, 7475, 7476, 7477, 7478, 7479, 7480, 7495, 7496, 7497, 7498, 7499, 7500, 7501, 7502, 7503, 7504, 7519, 7520, 7521, 7522, 7523, 7524, 7525, 7526, 7527, 7528, 7543, 7544, 7545, 7546, 7547, 7548, 7549, 7550, 7551, 7552, 7567, 7568, 7569, 7570, 7571, 7572, 7573, 7574, 7575, 7576, 7591, 7592, 7593, 7594, 7595, 7596, 7597, 7598, 7599, 7600, 7615, 7616, 7617, 7618, 7619, 7620, 7621, 7622, 7623, 7624, 7639, 7640, 7641, 7642, 7643, 7644, 7645, 7646, 7647, 7648, 7663, 7664, 7665, 7666, 7667, 7668, 7669, 7670, 7671, 7672, 7687, 7688, 7689, 7690, 7691, 7692, 7693, 7694, 7695, 7696, 7711, 7712, 7713, 7714, 7715, 7716, 7717, 7718, 7719, 7720, 7735, 7736, 7737, 7738, 7739, 7740, 7741, 7742, 7743, 7744, 7759, 7760, 7761, 7762, 7763, 7764, 7765, 7766, 7767, 7768, 7783, 7784, 7785, 7786, 7787, 7788, 7789, 7790, 7791, 7792, 7807, 7808, 7809, 7810, 7811, 7812, 7813, 7814, 7815, 7816, 7831, 7832, 7833, 7834, 7835, 7836, 7837, 7838, 7839, 7840, 7856, 7857, 7858, 7859, 7860, 7861, 7862, 7863, 7864, 7880, 7881, 7882, 7883, 7884, 7885, 7886, 7887, 7888, 7904, 7905, 7906, 7907, 7908, 7909, 7910, 7911, 7912, 7928, 7929, 7930, 7931, 7932, 7933, 7934, 7935, 7936, 7952, 7953, 7954, 7955, 7956, 7957, 7958, 7959, 7960, 7976, 7977, 7978, 7979, 7980, 7981, 7982, 7983, 7984, 8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8024, 8025, 8026, 8027, 8028, 8029, 8030, 8031, 8032, 8048, 8049, 8050, 8051, 8052, 8053, 8054, 8055, 8056, 8072, 8073, 8074, 8075, 8076, 8077, 8078, 8079, 8080, 8096, 8097, 8098, 8099, 8100, 8101, 8102, 8103, 8104, 8120, 8121, 8122, 8123, 8124, 8125, 8126, 8127, 8128, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8168, 8169, 8170, 8171, 8172, 8173, 8174, 8175, 8176, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8223, 8224, 8240, 8241, 8242, 8243, 8244, 8245, 8246, 8247, 8248, 8264, 8265, 8266, 8267, 8268, 8269, 8270, 8271, 8272, 8288, 8289, 8290, 8291, 8292, 8293, 8294, 8295, 8296, 8312, 8313, 8314, 8315, 8316, 8317, 8318, 8319, 8320, 8336, 8337, 8338, 8339, 8340, 8341, 8342, 8343, 8344, 8360, 8361, 8362, 8363, 8364, 8365, 8366, 8367, 8368, 8384, 8385, 8386, 8387, 8388, 8389, 8390, 8391, 8392, 8408, 8409, 8410, 8411, 8412, 8413, 8414, 8415, 8416, 8432, 8433, 8434, 8435, 8436, 8437, 8438, 8439, 8440, 8456, 8457, 8458, 8459, 8460, 8461, 8462, 8463, 8464, 8480, 8481, 8482, 8483, 8484, 8485, 8486, 8487, 8488, 8504, 8505, 8506, 8507, 8508, 8509, 8510, 8511, 8512, 8528, 8529, 8530, 8531, 8532, 8533, 8534, 8535, 8536, 8552, 8553, 8554, 8555, 8556, 8557, 8558, 8559, 8560, 8576, 8577, 8578, 8579, 8580, 8581, 8582, 8583, 8584, 8600, 8601, 8602, 8603, 8604, 8605, 8606, 8607, 8608, 8624, 8625, 8626, 8627, 8628, 8629, 8630, 8631, 8632, 8648, 8649, 8650, 8651, 8652, 8653, 8654, 8655, 8656, 8672, 8673, 8674, 8675, 8676, 8677, 8678, 8679, 8680, 8696, 8697, 8698, 8699, 8700, 8701, 8702, 8703, 8704, 8720, 8721, 8722, 8723, 8724, 8725, 8726, 8727, 8728, 8744, 8745, 8746, 8747, 8748, 8749, 8750, 8751, 8752 })) { data.Append(new GH_Number(d)); } param0.PersistentData.ClearData(); param0.PersistentData.AppendRange(data); //Assign default start and end of winter period based on winter official dates param1.PersistentData.ClearData(); param1.PersistentData.Append(new GH_Number(8472)); param2.PersistentData.ClearData(); param2.PersistentData.Append(new GH_Number(1872)); //Assign default weights for winter and summer periods based on the following order: shade, view, glare string[] coefs = { "1,1,-1", "-1,1,-1" }; param3.PersistentData.ClearData(); param3.PersistentData.Append(new GH_String(coefs[1])); param4.PersistentData.ClearData(); param4.PersistentData.Append(new GH_String(coefs[0])); }
public GH_Structure <GH_Number> DataTree() { GH_Structure <GH_Number> dataTree = new GH_Structure <GH_Number>(); GH_Structure <GH_Integer> indices = new GH_Structure <GH_Integer>(); for (int i = 0; i < trainedVectors.GetLength(0); i++) { GH_Path p = new GH_Path(Utils.ReverseArray(this.adressBook[i])); indices.Append(new GH_Integer(i), p); } indices.Flatten(); dataTree = new GH_Structure <GH_Number>(); GH_Structure <GH_Number> valueTree = Utils.MultidimensionalArrayToGHTree(trainedVectors); for (int i = 0; i < indices.DataCount; i++) { dataTree.AppendRange(valueTree.Branches[indices.Branches[0][i].Value], new GH_Path(this.adressBook[i])); } return(dataTree); }
public GH_Structure <GH_Brep> Slab(IEnumerable <StbSlab> slabs) { var brepList = new GH_Structure <GH_Brep>(); if (slabs == null) { return(brepList); } foreach ((StbSlab slab, int i) in slabs.Select((slab, index) => (slab, index))) { StbSlabOffset[] offsets = slab.StbSlabOffsetList; var curveList = new PolylineCurve[2]; double depth = BrepMaker.Slab.GetDepth(_sections, slab); string[] nodeIds = slab.StbNodeIdOrder.Split(' '); var topPts = new List <Point3d>(); foreach (string nodeId in nodeIds) { var offsetVec = new Vector3d(); if (offsets != null) { foreach (StbSlabOffset offset in offsets) { if (nodeId == offset.id_node) { offsetVec = new Vector3d(offset.offset_X, offset.offset_Y, offset.offset_Z); } } } StbNode node = _nodes.First(n => n.id == nodeId); topPts.Add(new Point3d(node.X, node.Y, node.Z) + offsetVec); } topPts.Add(topPts[0]); curveList[0] = new PolylineCurve(topPts); brepList.Append(CreateSlabBrep(depth, curveList, topPts), new GH_Path(0, i)); } return(brepList); }
protected override void SolveInstance(IGH_DataAccess DA) { GH_Structure<IGH_Goo> Input = new GH_Structure<IGH_Goo>(); DA.GetDataTree("Input", out Input); GH_Structure<HashType> Output = new GH_Structure<HashType>(); bool bEnumerate = false; DA.GetData("Enumerate", ref bEnumerate); // iterate through all the sources by the Params.input value (and thus bypass the DA object, is this ugly?) foreach (IGH_Param Param in this.Params.Input[0].Sources) { foreach (GH_Path path in Input.Paths) { String nickname = Param.NickName; if (nickname.Length == 0) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Nickname of the connected component is empty"); nickname = "Anonymous"; } List<object> DataList = new List<object>(); IEnumerable Data = Param.VolatileData.get_Branch(path); if (Data != null) { foreach (object item in Data) { if (item != null) { DataList.Add(item); } else { DataList.Add(""); } } } // // Add the data to the list. If result is a tree or something similar: this means the results will be flattened. if (Data == null || DataList.Count == 0) { } else if (DataList.Count == 1) { // If the component has a single output: name it singular Output.Append(new HashType(nickname, DataList[0]), path); } else if (DataList.Count > 1) { // .. otherwise: add a int j = 0; if (bEnumerate) { foreach (object item in DataList) { Output.Append(new HashType(String.Format("{0}_{1}", nickname, j), item), path); j++; } } else { Output.Append(new HashType(nickname, DataList), path); } } } } DA.SetDataTree(0, Output); }
protected override void SolveInstance(IGH_DataAccess DA) { //declare input variables to load into AuthToken authToken = new AuthToken(); string sheetName = ""; string worksheet = ""; bool includeBlankCells = false; bool rangeSpecified = false; SpreadsheetRange range = new SpreadsheetRange(); bool rowsColumns = false; bool formulasValues = false; //declare output variables List<string> metaData = new List<string>(); GH_Structure<GH_String> values = new GH_Structure<GH_String>(); GH_Structure<GH_String> addresses = new GH_Structure<GH_String>(); //get data from inputs if (!DA.GetData<AuthToken>("Token", ref authToken)) { return; //exit if no token } if (!authToken.IsValid) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The provided authentication token appears to be invalid. Try re-running the Google Authenticator component."); return; //exit if invalid token } if (!DA.GetData<string>("Name", ref sheetName)) { return; //exit if no name provided } DA.GetData<string>("Worksheet", ref worksheet); DA.GetData<bool>("Include Blank Cells?", ref includeBlankCells); if (DA.GetData<SpreadsheetRange>("Spreadsheet Range", ref range)) { rangeSpecified = true; } DA.GetData<bool>("Organize by Rows or Columns", ref rowsColumns); DA.GetData<bool>("Read Formulas or Values", ref formulasValues); //set up oAuth parameters OAuth2Parameters parameters = GDriveUtil.GetParameters(authToken); //establish spreadsheetservice SpreadsheetsService service = GDriveUtil.GetSpreadsheetsService(parameters); //get spreadsheet by name SpreadsheetEntry spreadsheet = GDriveUtil.findSpreadsheetByName(sheetName, service); if (spreadsheet == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Specified Spreadsheet not found."); return; } //gather spreadsheet metadata metaData.Add("Spreadsheet Name: " + spreadsheet.Title.Text); metaData.Add("Last Updated: " + spreadsheet.Updated.ToString()); metaData.Add("Worksheets: " + worksheetList(spreadsheet.Worksheets)); //find the specified worksheet, or first one if none specified WorksheetEntry worksheetEntry = null; worksheetEntry = GDriveUtil.findWorksheetByName(worksheet, spreadsheet); if (worksheetEntry == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Specified worksheet not found."); return; } // Fetch the cell feed of the worksheet. CellQuery cellQuery = new CellQuery(worksheetEntry.CellFeedLink); if (rangeSpecified) { if (range.TestValid()) { cellQuery.MinimumColumn = range.startColumn(); cellQuery.MinimumRow = range.startRow(); cellQuery.MaximumColumn = range.endColumn(); cellQuery.MaximumRow = range.endRow(); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid Range Specified"); return; } } //passes null values if user wants the blank cells represented, otherwise they are omitted from output. if (includeBlankCells) { cellQuery.ReturnEmpty = ReturnEmptyCells.yes; } //set up cell feed CellFeed cellFeed = service.Query(cellQuery); foreach (CellEntry cell in cellFeed.Entries) //for all the cells in the feed { GH_Path path = new GH_Path(DA.Iteration); //set up data path for data tree uint e = (rowsColumns) ? cell.Row : cell.Column; //decide whether to structure data path by row or column path = path.AppendElement((int)e); string v = (formulasValues) ? cell.InputValue : cell.Value; //decide whether to get the cell formula or the cell value as output values.Append(new GH_String(v), path); //save the value of the cell addresses.Append(new GH_String(cell.Title.Text), path); // save the address of the cell } //set output data DA.SetDataTree(0, values); DA.SetDataTree(1, addresses); DA.SetDataList("Sheet Info", metaData); }
//this method associates addresses with every piece of data. Responds intelligently to different cases of user input private Dictionary<string, string> constructWriteMap(GH_Structure<GH_String> addresses, GH_Structure<GH_String> data, bool rowColumn, ref uint maxRow, ref uint maxCol, ref GH_Structure<GH_String> addressesOut) { Dictionary<string, string> writeMap = new Dictionary<string, string>(); bool incrementBranches = false; bool incrementItems = false; //case 1: 1 address for entire tree //increment branches + increment items = true //case 2: 1 address per list //increment branches = false + increment items = true; //case 3: 1 address per item //increment branches + increment items = false bool validDataMatch = false; if (addresses.DataCount == 1) // case 1 { incrementBranches = true; incrementItems = true; validDataMatch = true; } else if(addresses.Branches.Count==data.Branches.Count) { if (oneItemPerBranch(addresses))//one item in each address branch, case 2 { incrementItems = true; validDataMatch = true; } else if(sameBranchLengths(data,addresses)){ //otherwise leave both to false in case 3 validDataMatch = true; } } if (!validDataMatch) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Either provide one address per data item, one address per list, or one address for the whole tree. \n In the latter two cases, sequential addresses are calculated automatically."); return writeMap; //return empty write map - nothing happens } for (int i_branch = 0; i_branch < data.Branches.Count; i_branch++) { List<GH_String> dataBranch = data.Branches[i_branch]; List<GH_String> addressBranch = addresses.Branches[Math.Min(i_branch, addresses.Branches.Count - 1)]; for (int i = 0; i < dataBranch.Count; i++) { string dataItem = dataBranch[i].ToString(); string addressItem = addressBranch[Math.Min(i, addressBranch.Count - 1)].ToString(); int colOffset = 0; int rowOffset = 0; if (rowColumn) // if true, data is structured in rows - otherwise in columns { colOffset = (incrementItems) ? i : 0; rowOffset = (incrementBranches) ? i_branch : 0; } else { colOffset = (incrementBranches) ? i_branch : 0; rowOffset = (incrementItems) ? i : 0; } long colAddress = GDriveUtil.colFromAddress(addressItem) + colOffset; long rowAddress = GDriveUtil.rowFromAddress(addressItem) + rowOffset; if (colAddress > maxCol) maxCol = (uint)colAddress; if (rowAddress > maxRow) maxRow = (uint)rowAddress; addressItem = GDriveUtil.addressFromCells(colAddress, rowAddress); //list of cell addresses that corresponds to input data order addressesOut.Append(new GH_String(addressItem),data.Paths[i_branch]); //dictionary of addresses + data to write - prep for batch write operation. try { writeMap.Add(addressItem, dataItem); //will throw an error if you try to write to the same cell twice - key is already in dictionary. } catch { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "You are trying to write into the same cell twice. Some data is being lost"); } } } return writeMap; }