public Enum SetInput(IGH_GeometricGoo gg, bool a) { Enum res = State.OK; bool isPoint = false; GS_StructuralPoint spt = null; GS_StructuralLine sln = null; if (gg is GH_Point) { spt = new GS_StructuralPoint(); spt.Value = new Point((gg as GH_Point).Value); isPoint = true; } else if (gg is GS_StructuralPoint) { spt = gg as GS_StructuralPoint; isPoint = true; } else if (gg is GH_Curve) { sln = new GS_StructuralLine(); sln.Value = (gg as GH_Curve).Value; } else if (gg is GH_Line) { sln = new GS_StructuralLine(); sln.Value = new LineCurve((gg as GH_Line).Value); } else if (gg is GH_Arc) { sln = new GS_StructuralLine(); sln.Value = new ArcCurve((gg as GH_Arc).Value); } else if (gg is GS_StructuralLine) { sln = gg as GS_StructuralLine; } //else //throw new InvalidCastException("Input param: only (structural)points/lines allowed"); if ((spt is null) && (sln is null)) { if (a) { res = State.InvalidA; } else { res = State.InvalidB; } }
protected override void SolveInstance(IGH_DataAccess da) { var curves = da.GetDataList <Curve>(0); var identifiers = da.GetDataList <int>(1); var groups = da.GetDataList <int>(2); var sections = da.GetDataList <string>(3); var zdirs = da.GetDataList <Vector3d>(4); var fixations = da.GetDataList <string>(5); var elementType = da.GetDataList <string>(6); var elementSize = da.GetDataList <double>(7); var userText = da.GetDataList <string>(8); var gh_structural_curves = new List <GS_StructuralLine>(); for (int i = 0; i < curves.Count; ++i) { var c = curves[i]; if (!(c is null)) { var section_ids = Util.ParseSectionIdentifier(sections.GetItemOrLast(i)); var gc = new GS_StructuralLine() { Value = c, Id = identifiers.GetItemOrCountUp(i), GroupId = groups.GetItemOrLast(i), SectionIdStart = section_ids.Item1, SectionIdEnd = section_ids.Item2, DirectionLocalZ = zdirs.GetItemOrLast(i), FixLiteral = fixations.GetItemOrLast(i), ElementType = parseElementTypeString(elementType.GetItemOrLast(i)), ElementSize = elementSize.GetItemOrLast(i), UserText = userText.GetItemOrLast(i), }; gh_structural_curves.Add(gc); } } da.SetDataList(0, gh_structural_curves); }
protected override void SolveInstance(IGH_DataAccess da) { var curves = da.GetDataList <Curve>(0); var identifiers = da.GetDataList <int>(1); var groups = da.GetDataList <int>(2); var sections = da.GetDataList <IGH_Goo>(3); var zdirs = da.GetDataList <Vector3d>(4); var fixations = da.GetDataList <string>(5); var elementType = da.GetDataList <string>(6); var elementSize = da.GetDataList <double>(7); var userText = da.GetDataList <string>(8); var gh_structural_curves = new List <GS_StructuralLine>(); for (int i = 0; i < curves.Count; ++i) { var c = curves[i]; if (!(c is null)) { var section_ids = new Tuple <int, int>(0, 0); var sectionGoo = sections.GetItemOrLast(i); if (sectionGoo != null) { if (sectionGoo is GH_String) { var sectionIdString = (sectionGoo as GH_String).Value; section_ids = Util.ParseSectionIdentifier(sectionIdString); } else { var sectionId = 0; if (sectionGoo is Section.GH_Section) { sectionId = (sectionGoo as Section.GH_Section).Value.Id; } else if (sectionGoo is GH_Integer) { sectionId = (sectionGoo as GH_Integer).Value; } else if (sectionGoo is GH_Number) { sectionId = (int)(sectionGoo as GH_Number).Value; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Could not extract section id from type " + sectionGoo.TypeName); } section_ids = new Tuple <int, int>(sectionId, sectionId); } } var gc = new GS_StructuralLine() { Value = c, Id = identifiers.GetItemOrCountUp(i), GroupId = groups.GetItemOrLast(i), SectionIdStart = section_ids.Item1, SectionIdEnd = section_ids.Item2, DirectionLocalZ = zdirs.GetItemOrLast(i), FixLiteral = fixations.GetItemOrLast(i), ElementType = parseElementTypeString(elementType.GetItemOrLast(i)), ElementSize = elementSize.GetItemOrLast(i), UserText = userText.GetItemOrLast(i), }; gh_structural_curves.Add(gc); } } da.SetDataList(0, gh_structural_curves); }