示例#1
0
        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);
        }
        public override bool CastFrom(object source)
        {
            if (source is Rhino.Display.ColorRGBA value)
            {
                Value = value;
                return(true);
            }

            var point = Rhino.Geometry.Point3d.Origin;

            if (GH_Convert.ToPoint3d(source, ref point, GH_Conversion.Both))
            {
                var x = Rhino.RhinoMath.Clamp(point.X, -1.0, +1.0);
                var y = Rhino.RhinoMath.Clamp(point.Y, -1.0, +1.0);
                var z = Rhino.RhinoMath.Clamp(point.Z, -1.0, +1.0);

                Value = new Rhino.Display.ColorRGBA
                        (
                    (double)((x + 1.0) * 0.5),
                    (double)((y + 1.0) * 0.5),
                    (double)((z + 1.0) * 0.5),
                    1.0f
                        );
                return(true);
            }

            if (GH_Convert.ToColor(source, out var color, GH_Conversion.Both))
            {
                Value = new Rhino.Display.ColorRGBA(color);
                return(true);
            }

            return(false);
        }
示例#3
0
        public static List <Point3d> ConvertGeosToPoints(List <IGH_GeometricGoo> geos)
        {
            List <Point3d> pts = new List <Point3d>();

            for (int i = 0; i < geos.Count; i++)
            {
                if (geos[i].IsValid)
                {
                    Point3d point = new Point3d();
                    GH_Convert.ToPoint3d(geos[i], ref point, GH_Conversion.Both);
                    pts.Add(point);
                }
            }
            return(pts);
        }
示例#4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Point ghpt = new GH_Point();

            if (DA.GetData(0, ref ghpt))
            {
                Point3d pt = new Point3d();
                if (GH_Convert.ToPoint3d(ghpt, ref pt, GH_Conversion.Both))
                {
                    GH_Plane gH_Plane  = new GH_Plane();
                    Plane    localAxis = Plane.WorldXY;
                    if (DA.GetData(1, ref gH_Plane))
                    {
                        GH_Convert.ToPlane(gH_Plane, ref localAxis, GH_Conversion.Both);
                    }

                    GsaNode node = new GsaNode(pt);

                    GsaBool6 bool6 = new GsaBool6();
                    if (DA.GetData(2, ref bool6))
                    {
                        x  = bool6.X;
                        y  = bool6.Y;
                        z  = bool6.Z;
                        xx = bool6.XX;
                        yy = bool6.YY;
                        zz = bool6.ZZ;
                    }

                    GsaSpring spring = new GsaSpring();
                    if (DA.GetData(3, ref spring))
                    {
                        node.Spring = spring;
                    }

                    node.LocalAxis = localAxis;

                    node.Node.Restraint.X  = x;
                    node.Node.Restraint.Y  = y;
                    node.Node.Restraint.Z  = z;
                    node.Node.Restraint.XX = xx;
                    node.Node.Restraint.YY = yy;
                    node.Node.Restraint.ZZ = zz;

                    DA.SetData(0, new GsaNodeGoo(node.Duplicate()));
                }
            }
        }
        public override bool CastFrom(object source)
        {
            // This function is called when Grasshopper needs to convert other data
            // into GsaNode.


            if (source == null)
            {
                return(false);
            }

            //Cast from GsaNode
            if (typeof(GsaNode).IsAssignableFrom(source.GetType()))
            {
                Value = (GsaNode)source;
                return(true);
            }

            //Cast from GsaAPI Node
            if (typeof(Node).IsAssignableFrom(source.GetType()))
            {
                Value.Node = (Node)source;
                return(true);
            }

            //Cast from Point3d
            Point3d pt = new Point3d();

            if (GH_Convert.ToPoint3d(source, ref pt, GH_Conversion.Both))
            {
                GsaNode node = new GsaNode(pt);
                this.Value = node;
                return(true);
            }


            return(false);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            checked
            {
                var Points = new List <Point3d>();

                DA.GetDataList(0, Points);

                var attrition = 1.0;

                DA.GetData("Attrition", ref attrition);

                var nodeTwoList   = new Grasshopper.Kernel.Geometry.Node2List(Points);
                var delaunayFaces = Grasshopper.Kernel.Geometry.Delaunay.Solver.Solve_Faces(nodeTwoList, 1);
                var delaunayMesh  = Grasshopper.Kernel.Geometry.Delaunay.Solver.Solve_Mesh(nodeTwoList, 1, ref delaunayFaces);
                delaunayMesh.Weld(Math.PI);

                var list = new List <object>();

                var circles = new SurfaceComponents.MeshComponents.Component_MeshFaceCircles();
                var param   = circles.Params.Input[0] as Grasshopper.Kernel.GH_PersistentGeometryParam <Grasshopper.Kernel.Types.GH_Mesh>;
                param.PersistentData.ClearData();
                param.PersistentData.Append(new GH_Mesh(delaunayMesh));

                circles.ExpireSolution(true);

                //add to a dummy document so we can read outputs
                var doc = new Grasshopper.Kernel.GH_Document();
                doc.AddObject(circles, false);

                //read output circles
                circles.Params.Output[0].CollectData();
                var ratio = new double[circles.Params.Output[1].VolatileDataCount];
                for (int i = 0; i < circles.Params.Output[0].VolatileDataCount; ++i)
                {
                    //ratio[i] = circles.Params.Output[1].VolatileData.get_Branch(0)[i];
                    GH_Convert.ToDouble(circles.Params.Output[1].VolatileData.get_Branch(0)[i], out ratio[i], GH_Conversion.Both);
                    list.Add(circles.Params.Output[0].VolatileData.get_Branch(0)[i]);
                }

                var arcsList = new double[list.Count];

                var arcs      = new AnalysisComponents.Component_DeconstructArc();
                var arcParams = arcs.Params.Input[0] as Grasshopper.Kernel.GH_PersistentParam <Grasshopper.Kernel.Types.GH_Arc>;
                arcParams.PersistentData.ClearData();
                var circle = new Arc[delaunayMesh.Faces.Count];
                for (int i = 0; i < list.Count; ++i)
                {
                    GH_Convert.ToArc(list[i], ref circle[i], GH_Conversion.Both);
                    arcParams.PersistentData.Append(new GH_Arc(circle[i]));
                }

                arcs.ExpireSolution(true);
                var docOne = new Grasshopper.Kernel.GH_Document();
                docOne.AddObject(arcs, false);

                arcs.Params.Output[0].CollectData();
                for (int i = 0; i < arcs.Params.Output[1].VolatileDataCount; ++i)
                {
                    GH_Convert.ToDouble(arcs.Params.Output[1].VolatileData.get_Branch(0)[i], out arcsList[i], GH_Conversion.Both);
                    //arcsList.Add(arcs.Params.Output[1].VolatileData.get_Branch(0)[i]);
                }

                var faceMesh     = new List <object>();
                var verticesMesh = new List <object>();

                var deMesh     = new SurfaceComponents.MeshComponents.Component_DeconstructMesh();
                var meshParams = deMesh.Params.Input[0] as Grasshopper.Kernel.GH_PersistentParam <Grasshopper.Kernel.Types.GH_Mesh>;
                meshParams.PersistentData.ClearData();
                meshParams.PersistentData.Append(new GH_Mesh(delaunayMesh));

                deMesh.ExpireSolution(true);
                var docTwo = new Grasshopper.Kernel.GH_Document();
                docTwo.AddObject(deMesh, false);

                deMesh.Params.Output[0].CollectData();

                for (int i = 0; i < deMesh.Params.Output[0].VolatileDataCount; ++i)
                {
                    verticesMesh.Add(deMesh.Params.Output[0].VolatileData.get_Branch(0)[i]);
                }

                for (int i = 0; i < deMesh.Params.Output[1].VolatileDataCount; ++i)
                {
                    faceMesh.Add(deMesh.Params.Output[1].VolatileData.get_Branch(0)[i]);
                }

                var faceCullRadius = RadiusSorting(faceMesh, arcsList);

                Array.Sort(ratio);

                var splitListIndex = Convert.ToInt32((ratio[ratio.Length - 1] * faceMesh.Count) * attrition);
                //var splitListIndex = Convert.ToInt32(Attrition);

                var splitList = SplitList(faceCullRadius, splitListIndex);

                var constructMesh = new Mesh();
                var meshPoints    = new Point3d[verticesMesh.Count];
                for (int i = 0; i < verticesMesh.Count; ++i)
                {
                    GH_Convert.ToPoint3d(verticesMesh[i], ref meshPoints[i], GH_Conversion.Both);
                    constructMesh.Vertices.Add(meshPoints[i]);
                }

                var meshFaces = new Grasshopper.Kernel.Types.GH_MeshFace[splitList.Count];
                for (int i = 0; i < splitList.Count; ++i)
                {
                    GH_Convert.ToGHMeshFace(splitList[i], GH_Conversion.Both, ref meshFaces[i]);
                    constructMesh.Faces.AddFace(meshFaces[i].Value);
                }

                var ConcaveHull = constructMesh.GetNakedEdges();

                DA.SetDataList(0, ConcaveHull);
            }
        }
示例#7
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();

            if (DA.GetData(0, ref gh_typ))
            {
                GsaNode gsaNode = new GsaNode();
                Point3d tempPt  = new Point3d();
                if (gh_typ.Value is GsaNodeGoo)
                {
                    gh_typ.CastTo(ref gsaNode);
                    if (gsaNode == null)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Node input is null");
                    }
                    if (gsaNode.Node == null)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Node input is null");
                    }
                }
                else if (GH_Convert.ToPoint3d(gh_typ.Value, ref tempPt, GH_Conversion.Both))
                {
                    gsaNode = new GsaNode(tempPt);
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert input to Node");
                    return;
                }
                GsaNode node = gsaNode.Duplicate();

                // #### inputs ####

                // 1 ID
                GH_Integer ghInt = new GH_Integer();
                if (DA.GetData(1, ref ghInt))
                {
                    if (GH_Convert.ToInt32(ghInt, out int id, GH_Conversion.Both))
                    {
                        node.ID = id;
                    }
                }

                // 2 Point
                GH_Point ghPt = new GH_Point();
                if (DA.GetData(2, ref ghPt))
                {
                    Point3d pt = new Point3d();
                    if (GH_Convert.ToPoint3d(ghPt, ref pt, GH_Conversion.Both))
                    {
                        node.Point           = pt;
                        node.Node.Position.X = pt.X;
                        node.Node.Position.Y = pt.Y;
                        node.Node.Position.Z = pt.Z;
                    }
                }

                // 3 plane
                GH_Plane ghPln = new GH_Plane();
                if (DA.GetData(3, ref ghPln))
                {
                    Plane pln = new Plane();
                    if (GH_Convert.ToPlane(ghPln, ref pln, GH_Conversion.Both))
                    {
                        pln.Origin     = node.Point;
                        node.LocalAxis = pln;
                    }
                }

                // 4 Restraint
                GsaBool6 restraint = new GsaBool6();
                if (DA.GetData(4, ref restraint))
                {
                    node.Node.Restraint.X  = restraint.X;
                    node.Node.Restraint.Y  = restraint.Y;
                    node.Node.Restraint.Z  = restraint.Z;
                    node.Node.Restraint.XX = restraint.XX;
                    node.Node.Restraint.YY = restraint.YY;
                    node.Node.Restraint.ZZ = restraint.ZZ;
                }

                // 5 Spring
                GsaSpring spring = new GsaSpring();
                if (DA.GetData(5, ref spring))
                {
                    if (spring != null)
                    {
                        node.Spring = spring;
                    }
                }

                // 6 Name
                GH_String ghStr = new GH_String();
                if (DA.GetData(6, ref ghStr))
                {
                    if (GH_Convert.ToString(ghStr, out string name, GH_Conversion.Both))
                    {
                        node.Node.Name = name;
                    }
                }

                // 7 Colour
                GH_Colour ghcol = new GH_Colour();
                if (DA.GetData(7, ref ghcol))
                {
                    if (GH_Convert.ToColor(ghcol, out System.Drawing.Color col, GH_Conversion.Both))
                    {
                        node.Colour = col;
                    }
                }

                // #### outputs ####
                DA.SetData(0, new GsaNodeGoo(node));
                DA.SetData(1, node.ID);
                DA.SetData(2, node.Point);
                DA.SetData(3, node.LocalAxis);
                GsaBool6 restraint1 = new GsaBool6
                {
                    X  = node.Node.Restraint.X,
                    Y  = node.Node.Restraint.Y,
                    Z  = node.Node.Restraint.Z,
                    XX = node.Node.Restraint.XX,
                    YY = node.Node.Restraint.YY,
                    ZZ = node.Node.Restraint.ZZ
                };
                DA.SetData(4, restraint1);
                GsaSpring spring1 = new GsaSpring();
                if (node.Spring != null)
                {
                    spring1 = node.Spring.Duplicate();
                }
                DA.SetData(5, new GsaSpringGoo(spring1));
                DA.SetData(6, node.Node.Name);
                DA.SetData(7, node.Colour);
                try { DA.SetDataList(8, node.Node.ConnectedElements); } catch (Exception) { }
                try { DA.SetDataList(9, node.Node.ConnectedMembers); } catch (Exception) { }
            }
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Brep ghbrep = new GH_Brep();

            if (DA.GetData(0, ref ghbrep))
            {
                if (ghbrep == null)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Brep input is null");
                }
                Brep brep = new Brep();
                if (GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both))
                {
                    // 1 Points
                    List <GH_ObjectWrapper> gh_types = new List <GH_ObjectWrapper>();
                    List <Point3d>          pts      = new List <Point3d>();
                    List <GsaNode>          nodes    = new List <GsaNode>();
                    if (DA.GetDataList(1, gh_types))
                    {
                        for (int i = 0; i < gh_types.Count; i++)
                        {
                            Point3d pt = new Point3d();
                            if (gh_types[i].Value is GsaNodeGoo)
                            {
                                GsaNode gsanode = new GsaNode();
                                gh_types[i].CastTo(ref gsanode);
                                nodes.Add(gsanode);
                            }
                            else if (GH_Convert.ToPoint3d(gh_types[i].Value, ref pt, GH_Conversion.Both))
                            {
                                pts.Add(pt);
                            }
                            else
                            {
                                string type = gh_types[i].Value.GetType().ToString();
                                type = type.Replace("GhSA.Parameters.", "");
                                type = type.Replace("Goo", "");
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert incl. Point/Node input parameter of type " +
                                                  type + " to point or node");
                            }
                        }
                    }

                    // 2 Curves
                    gh_types = new List <GH_ObjectWrapper>();
                    List <Curve>       crvs   = new List <Curve>();
                    List <GsaMember1d> mem1ds = new List <GsaMember1d>();
                    if (DA.GetDataList(2, gh_types))
                    {
                        for (int i = 0; i < gh_types.Count; i++)
                        {
                            Curve crv = null;
                            if (gh_types[i].Value is GsaMember1dGoo)
                            {
                                GsaMember1d gsamem1d = new GsaMember1d();
                                gh_types[i].CastTo(ref gsamem1d);
                                mem1ds.Add(gsamem1d);
                            }
                            else if (GH_Convert.ToCurve(gh_types[i].Value, ref crv, GH_Conversion.Both))
                            {
                                crvs.Add(crv);
                            }
                            else
                            {
                                string type = gh_types[i].Value.GetType().ToString();
                                type = type.Replace("GhSA.Parameters.", "");
                                type = type.Replace("Goo", "");
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert incl. Curve/Mem1D input parameter of type " +
                                                  type + " to curve or 1D Member");
                            }
                        }
                    }

                    // 4 mesh size
                    GH_Number ghmsz    = new GH_Number();
                    double    meshSize = 0;
                    if (DA.GetData(4, ref ghmsz))
                    {
                        GH_Convert.ToDouble(ghmsz, out double m_size, GH_Conversion.Both);
                        meshSize = m_size;
                    }

                    // build new element2d with brep, crv and pts
                    GsaElement2d elem2d = new GsaElement2d(brep, crvs, pts, meshSize, mem1ds, nodes);

                    // 3 section
                    GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                    GsaProp2d        prop2d = new GsaProp2d();
                    if (DA.GetData(3, ref gh_typ))
                    {
                        if (gh_typ.Value is GsaProp2dGoo)
                        {
                            gh_typ.CastTo(ref prop2d);
                        }
                        else
                        {
                            if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both))
                            {
                                prop2d.ID = idd;
                            }
                            else
                            {
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PA input to a 2D Property of reference integer");
                                return;
                            }
                        }
                    }
                    else
                    {
                        prop2d.ID = 1;
                    }
                    List <GsaProp2d> prop2Ds = new List <GsaProp2d>();
                    for (int i = 0; i < elem2d.Elements.Count; i++)
                    {
                        prop2Ds.Add(prop2d);
                    }
                    elem2d.Properties = prop2Ds;

                    DA.SetData(0, new GsaElement2dGoo(elem2d));
                }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaNode gsaNode = new GsaNode();

            if (!DA.GetData(0, ref gsaNode))
            {
                gsaNode = new GsaNode(new Point3d(0, 0, 0));
            }

            if (gsaNode != null)
            {
                // #### inputs ####

                GH_Integer ghInt = new GH_Integer();
                if (DA.GetData(1, ref ghInt))
                {
                    if (GH_Convert.ToInt32(ghInt, out int id, GH_Conversion.Both))
                    {
                        gsaNode.ID = id;
                    }
                }

                GH_String ghStr = new GH_String();
                if (DA.GetData(2, ref ghStr))
                {
                    if (GH_Convert.ToString(ghStr, out string name, GH_Conversion.Both))
                    {
                        gsaNode.Node.Name = name;
                    }
                }

                GH_Point ghPt = new GH_Point();
                if (DA.GetData(3, ref ghPt))
                {
                    Point3d pt = new Point3d();
                    if (GH_Convert.ToPoint3d(ghPt, ref pt, GH_Conversion.Both))
                    {
                        gsaNode.Point           = pt;
                        gsaNode.Node.Position.X = pt.X;
                        gsaNode.Node.Position.Y = pt.Y;
                        gsaNode.Node.Position.Z = pt.Z;
                    }
                }

                GH_Plane ghPln = new GH_Plane();
                if (DA.GetData(4, ref ghPln))
                {
                    Plane pln = new Plane();
                    if (GH_Convert.ToPlane(ghPln, ref pln, GH_Conversion.Both))
                    {
                        pln.Origin        = gsaNode.Point;
                        gsaNode.LocalAxis = pln;
                    }
                }

                GsaBool6 restraint = new GsaBool6();
                if (DA.GetData(5, ref restraint))
                {
                    restraint.X  = gsaNode.Node.Restraint.X;
                    restraint.Y  = gsaNode.Node.Restraint.Y;
                    restraint.Z  = gsaNode.Node.Restraint.Z;
                    restraint.XX = gsaNode.Node.Restraint.XX;
                    restraint.YY = gsaNode.Node.Restraint.YY;
                    restraint.ZZ = gsaNode.Node.Restraint.ZZ;
                }

                GsaSpring spring = new GsaSpring();
                if (DA.GetData(6, ref spring))
                {
                    if (gsaNode.Spring != null)
                    {
                        gsaNode.Spring = spring;
                    }
                }


                // #### outputs ####
                DA.SetData(0, new GsaNodeGoo(gsaNode));

                DA.SetData(1, gsaNode.ID);
                DA.SetData(2, gsaNode.Node.Name);

                DA.SetData(3, gsaNode.Point);

                DA.SetData(4, gsaNode.LocalAxis);

                GsaBool6 restraint1 = new GsaBool6
                {
                    X  = gsaNode.Node.Restraint.X,
                    Y  = gsaNode.Node.Restraint.Y,
                    Z  = gsaNode.Node.Restraint.Z,
                    XX = gsaNode.Node.Restraint.XX,
                    YY = gsaNode.Node.Restraint.YY,
                    ZZ = gsaNode.Node.Restraint.ZZ
                };
                DA.SetData(5, restraint1);

                GsaSpring spring1 = new GsaSpring();
                if (gsaNode.Spring != null)
                {
                    spring1 = gsaNode.Spring.Duplicate();
                }
                DA.SetData(6, new GsaSpringGoo(spring1));

                try { DA.SetDataList(7, gsaNode.Node.ConnectedElements); } catch (Exception) { }

                try { DA.SetDataList(8, gsaNode.Node.ConnectedMembers); } catch (Exception) { }
            }
        }
示例#10
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaGridPointLoad gridpointload = new GsaGridPointLoad();

            // 0 Load case
            int        lc    = 1;
            GH_Integer gh_lc = new GH_Integer();

            if (DA.GetData(0, ref gh_lc))
            {
                GH_Convert.ToInt32(gh_lc, out lc, GH_Conversion.Both);
            }
            gridpointload.GridPointLoad.Case = lc;

            // 1 Point
            Point3d  pt    = new Point3d();
            GH_Point gh_pt = new GH_Point();

            if (DA.GetData(1, ref gh_pt))
            {
                GH_Convert.ToPoint3d(gh_pt, ref pt, GH_Conversion.Both);
            }
            gridpointload.GridPointLoad.X = pt.X;
            gridpointload.GridPointLoad.Y = pt.Y;

            // 2 Plane
            GsaGridPlaneSurface grdplnsrf;
            Plane            pln    = Plane.WorldXY;
            GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();

            if (DA.GetData(2, ref gh_typ))
            {
                if (gh_typ.Value is GsaGridPlaneSurfaceGoo)
                {
                    GsaGridPlaneSurface temppln = new GsaGridPlaneSurface();
                    gh_typ.CastTo(ref temppln);
                    grdplnsrf = temppln.Duplicate();
                    gridpointload.GridPlaneSurface = grdplnsrf;
                }
                else if (gh_typ.Value is Plane)
                {
                    gh_typ.CastTo(ref pln);
                    grdplnsrf = new GsaGridPlaneSurface(pln);
                    gridpointload.GridPlaneSurface = grdplnsrf;
                }
                else
                {
                    int id = 0;
                    if (GH_Convert.ToInt32(gh_typ.Value, out id, GH_Conversion.Both))
                    {
                        gridpointload.GridPointLoad.GridSurface = id;
                        gridpointload.GridPlaneSurface          = null;
                    }
                    else
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error in GPS input. Accepted inputs are Grid Plane Surface or Plane. " +
                                          System.Environment.NewLine + "If no input here then the point's z-coordinate will be used for an xy-plane at that elevation");
                        return;
                    }
                }
            }
            else
            {
                pln        = Plane.WorldXY;
                pln.Origin = pt;
                grdplnsrf  = new GsaGridPlaneSurface(pln);
                gridpointload.GridPlaneSurface = grdplnsrf;
            }

            // 3 direction
            string    dir   = "Z";
            Direction direc = Direction.Z;

            GH_String gh_dir = new GH_String();

            if (DA.GetData(3, ref gh_dir))
            {
                GH_Convert.ToString(gh_dir, out dir, GH_Conversion.Both);
            }
            dir = dir.ToUpper();
            if (dir == "X")
            {
                direc = Direction.X;
            }
            if (dir == "Y")
            {
                direc = Direction.Y;
            }

            gridpointload.GridPointLoad.Direction = direc;

            // 4 Axis
            int axis = 0;

            gridpointload.GridPointLoad.AxisProperty = 0;
            GH_Integer gh_ax = new GH_Integer();

            if (DA.GetData(4, ref gh_ax))
            {
                GH_Convert.ToInt32(gh_ax, out axis, GH_Conversion.Both);
                if (axis == 0 || axis == -1)
                {
                    gridpointload.GridPointLoad.AxisProperty = axis;
                }
            }

            // 5 Name
            string    name    = "";
            GH_String gh_name = new GH_String();

            if (DA.GetData(5, ref gh_name))
            {
                if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both))
                {
                    gridpointload.GridPointLoad.Name = name;
                }
            }

            // 6 load value
            double load = 0;

            if (DA.GetData(6, ref load))
            {
                load *= -1000; //convert to kN
            }
            gridpointload.GridPointLoad.Value = load;

            // convert to goo
            GsaLoad gsaLoad = new GsaLoad(gridpointload);

            DA.SetData(0, new GsaLoadGoo(gsaLoad));
        }
示例#11
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Brep ghbrep = new GH_Brep();

            if (DA.GetData(0, ref ghbrep))
            {
                if (ghbrep == null)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Brep input is null");
                }
                Brep brep = new Brep();
                if (GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both))
                {
                    // 1 Points
                    List <Point3d>  pts   = new List <Point3d>();
                    List <GH_Point> ghpts = new List <GH_Point>();
                    if (DA.GetDataList(1, ghpts))
                    {
                        for (int i = 0; i < ghpts.Count; i++)
                        {
                            Point3d pt = new Point3d();
                            if (GH_Convert.ToPoint3d(ghpts[i], ref pt, GH_Conversion.Both))
                            {
                                pts.Add(pt);
                            }
                        }
                    }

                    // 2 Curves
                    List <Curve>    crvs   = new List <Curve>();
                    List <GH_Curve> ghcrvs = new List <GH_Curve>();
                    if (DA.GetDataList(2, ghcrvs))
                    {
                        for (int i = 0; i < ghcrvs.Count; i++)
                        {
                            Curve crv = null;
                            if (GH_Convert.ToCurve(ghcrvs[i], ref crv, GH_Conversion.Both))
                            {
                                crvs.Add(crv);
                            }
                        }
                    }

                    // build new member with brep, crv and pts
                    GsaMember2d mem = new GsaMember2d(brep, crvs, pts);

                    // 3 section
                    GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                    GsaProp2d        prop2d = new GsaProp2d();
                    if (DA.GetData(3, ref gh_typ))
                    {
                        if (gh_typ.Value is GsaProp2dGoo)
                        {
                            gh_typ.CastTo(ref prop2d);
                            mem.Property = prop2d;
                        }
                        else
                        {
                            if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both))
                            {
                                mem.Member.Property = idd;
                            }
                            else
                            {
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PA input to a 2D Property of reference integer");
                                return;
                            }
                        }
                    }

                    // 4 mesh size
                    GH_Number ghmsz = new GH_Number();
                    if (DA.GetData(4, ref ghmsz))
                    {
                        GH_Convert.ToDouble(ghmsz, out double m_size, GH_Conversion.Both);
                        mem.Member.MeshSize = m_size;
                    }

                    DA.SetData(0, new GsaMember2dGoo(mem));
                }
示例#12
0
        /// <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 <IGH_GeometricGoo> geo = new List <IGH_GeometricGoo>();

            if (!DA.GetDataList(0, geo))
            {
                return;
            }
            if (!DA.GetData(1, ref constraint_X))
            {
                return;
            }
            if (!DA.GetData(2, ref constraint_Y))
            {
                return;
            }
            if (!DA.GetData(3, ref constraint_Z))
            {
                return;
            }
            if (!DA.GetData(4, ref constraint_RX))
            {
                return;
            }
            if (!DA.GetData(5, ref constraint_RY))
            {
                return;
            }
            if (!DA.GetData(6, ref constraint_RZ))
            {
                return;
            }
            DA.GetData(7, ref scale);


            DataTree <IGH_GeometricGoo> symbols = new DataTree <IGH_GeometricGoo>();

            for (int i = 0; i < geo.Count; i++)
            {
                Point3d p = new Point3d();

                if (geo[i] is Point3d)
                {
                    if (!GH_Convert.ToPoint3d(geo[i], ref p, GH_Conversion.Both))
                    {
                        return;
                    }
                }
                else if (geo[i] is GH_Point)
                {
                    GH_Point ghP = new GH_Point();

                    if (GH_Convert.ToGHPoint(geo[i], GH_Conversion.Both, ref ghP))
                    {
                        p = ghP.Value;
                    }
                    else
                    {
                        return;
                    }
                }

                double radius = scale / 8.0;

                Sphere s1 = new Sphere(p, radius);

                double pX = radius * Math.Sin(Math.PI / 4) * Math.Cos(Math.PI / 4);
                double pY = radius * Math.Sin(Math.PI / 4) * Math.Sin(Math.PI / 4);
                double pZ = radius * Math.Cos(Math.PI / 4);

                double pX0 = radius * Math.Sin(Math.PI / 4) * Math.Cos(0);
                double pY0 = radius * Math.Sin(0) * Math.Sin(Math.PI / 4);

                Point3d p01 = new Point3d(p.X - pX0, p.Y - pY0, p.Z - pZ);
                Point3d p02 = new Point3d(p.X + pX0, p.Y - pY0, p.Z - pZ);
                Point3d p03 = new Point3d(p.X + pX0, p.Y + pY0, p.Z - pZ);
                Point3d p04 = new Point3d(p.X - pX0, p.Y + pY0, p.Z - pZ);

                Point3d p11 = new Point3d(p.X - pX, p.Y - pY, p.Z - pZ);
                Point3d p12 = new Point3d(p.X + pX, p.Y - pY, p.Z - pZ);
                Point3d p13 = new Point3d(p.X + pX, p.Y + pY, p.Z - pZ);
                Point3d p14 = new Point3d(p.X - pX, p.Y + pY, p.Z - pZ);

                Point3d p21 = new Point3d(p.X - scale / 2.0, p.Y - scale / 2.0, p.Z - scale / 2.0);
                Point3d p22 = new Point3d(p.X + scale / 2.0, p.Y - scale / 2.0, p.Z - scale / 2.0);
                Point3d p23 = new Point3d(p.X + scale / 2.0, p.Y + scale / 2.0, p.Z - scale / 2.0);
                Point3d p24 = new Point3d(p.X - scale / 2.0, p.Y + scale / 2.0, p.Z - scale / 2.0);

                Line l1 = new Line(p11, p21);
                Line l2 = new Line(p12, p22);
                Line l3 = new Line(p13, p23);
                Line l4 = new Line(p14, p24);

                Line l5 = new Line(p21, p22);
                Line l6 = new Line(p22, p23);
                Line l7 = new Line(p23, p24);
                Line l8 = new Line(p24, p21);

                Arc a1 = new Arc(p11, p01, p12);
                Arc a2 = new Arc(p12, p02, p13);
                Arc a3 = new Arc(p13, p03, p14);
                Arc a4 = new Arc(p14, p04, p11);

                List <Curve> c1 = new List <Curve>()
                {
                    l1.ToNurbsCurve(), l2.ToNurbsCurve(), l5.ToNurbsCurve(), a3.ToNurbsCurve()
                };
                List <Curve> c2 = new List <Curve>()
                {
                    l2.ToNurbsCurve(), l3.ToNurbsCurve(), l6.ToNurbsCurve(), a2.ToNurbsCurve()
                };
                List <Curve> c3 = new List <Curve>()
                {
                    l3.ToNurbsCurve(), l4.ToNurbsCurve(), l7.ToNurbsCurve(), a1.ToNurbsCurve()
                };
                List <Curve> c4 = new List <Curve>()
                {
                    l4.ToNurbsCurve(), l1.ToNurbsCurve(), l8.ToNurbsCurve(), a4.ToNurbsCurve()
                };

                Brep b1 = Brep.CreateEdgeSurface(c1);
                Brep b2 = Brep.CreateEdgeSurface(c2);
                Brep b3 = Brep.CreateEdgeSurface(c3);
                Brep b4 = Brep.CreateEdgeSurface(c4);

                symbols.Add(GH_Convert.ToGeometricGoo(s1), new GH_Path(i));

                symbols.Add(GH_Convert.ToGeometricGoo(l1), new GH_Path(i));
                symbols.Add(GH_Convert.ToGeometricGoo(l2), new GH_Path(i));
                symbols.Add(GH_Convert.ToGeometricGoo(l3), new GH_Path(i));
                symbols.Add(GH_Convert.ToGeometricGoo(l4), new GH_Path(i));

                symbols.Add(GH_Convert.ToGeometricGoo(l5), new GH_Path(i));
                symbols.Add(GH_Convert.ToGeometricGoo(l6), new GH_Path(i));
                symbols.Add(GH_Convert.ToGeometricGoo(l7), new GH_Path(i));
                symbols.Add(GH_Convert.ToGeometricGoo(l8), new GH_Path(i));

                symbols.Add(GH_Convert.ToGeometricGoo(b1), new GH_Path(i));
                symbols.Add(GH_Convert.ToGeometricGoo(b2), new GH_Path(i));
                symbols.Add(GH_Convert.ToGeometricGoo(b3), new GH_Path(i));
                symbols.Add(GH_Convert.ToGeometricGoo(b4), new GH_Path(i));
            }
            DA.SetDataTree(0, symbols);
        }
示例#13
0
        /// <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)
        {
            var curves     = new DataTree <Polyline>();
            var points     = new DataTree <Point3d>();
            var frames     = new DataTree <Plane>();
            int collisions = 0;

            var gCurves = new GH_Structure <GH_Curve>();
            var gPoints = new GH_Structure <GH_Point>();
            var gFrames = new GH_Structure <GH_Plane>();

            if (!DA.GetDataTree(0, out gPoints))
            {
                return;
            }
            if (!DA.GetDataTree(1, out gFrames))
            {
                return;
            }
            DA.GetData(2, ref collisions);
            if (!DA.GetDataTree(3, out gCurves))
            {
                return;
            }

            var tempPoint = new Point3d();

            foreach (var path in gPoints.Paths)
            {
                var branch = gPoints.get_Branch(path);

                foreach (var item in branch)
                {
                    GH_Convert.ToPoint3d(item, ref tempPoint, GH_Conversion.Both);

                    points.Add(tempPoint, path);
                }
            }

            Curve tempCurve  = null;
            var   tempPoly   = new Polyline();
            var   curvesList = new List <Curve>();

            foreach (var path in gCurves.Paths)
            {
                var branch = gCurves.get_Branch(path);

                foreach (var item in branch)
                {
                    GH_Convert.ToCurve(item, ref tempCurve, GH_Conversion.Both);
                    tempCurve.TryGetPolyline(out tempPoly);

                    curves.Add(tempPoly, path);
                }
            }

            var tempPlane = new Plane();

            foreach (var path in gFrames.Paths)
            {
                var branch = gFrames.get_Branch(path);

                foreach (var item in branch)
                {
                    GH_Convert.ToPlane(item, ref tempPlane, GH_Conversion.Both);
                    frames.Add(tempPlane, path);
                }
            }

            int             branches = curves.BranchCount;
            List <Polyline> listOut  = new List <Polyline>();

            if (branches == 1)
            {
                listOut.AddRange(curves.Branch(0));
            }

            if (branches == 2)
            {
                if (collisions != 0)
                {
                    int branchOneCount = curves.Branch(0).Count;

                    var pointComparer = points.Branch(0)[curves.Branch(0).Count - 1].Z;

                    var comparer = new List <double>();

                    var listOfCurves    = new DataTree <Polyline>();
                    var listOfCurvesOne = new List <Polyline>();
                    var listOfCurvesTwo = new List <Polyline>();

                    listOfCurves.AddRange(curves.Branch(0));

                    var listOfPlanes    = new List <Plane>();
                    var listOfPlanesOne = new List <Plane>();

                    listOfPlanes.AddRange(frames.Branch(0));

                    var pathOne = new GH_Path(1);
                    var pathTwo = new GH_Path(2);

                    for (int i = 0; i < curves.Branch(1).Count; ++i)
                    {
                        comparer.Add(points.Branch(1)[i].Z);

                        if (pointComparer >= comparer[i])
                        {
                            listOfCurves.Add(curves.Branch(1)[i], pathOne);
                        }

                        else
                        {
                            listOfCurvesOne.Add(curves.Branch(1)[i]);
                            listOfPlanesOne.Add(frames.Branch(1)[i]);
                        }
                    }

                    var listOfUnions = RegionUnion(listOfCurves, listOfPlanes);

                    listOut.AddRange(listOfUnions);
                    listOut.AddRange(listOfCurvesOne);
                }

                else
                {
                    for (int i = 0; i < branches; ++i)
                    {
                        listOut.AddRange(curves.Branch(i));
                    }
                }
            }

            if (branches == 3)
            {
                if (collisions != 0)
                {
                    int branchOneCount = curves.Branch(0).Count;

                    var pointComparer    = points.Branch(0)[curves.Branch(0).Count - 1].Z;
                    var pointComparerOne = points.Branch(1)[curves.Branch(1).Count - 1].Z;

                    var comparer = new List <double>();

                    var listOfCurves    = new DataTree <Polyline>();
                    var listOfCurvesOne = new DataTree <Polyline>();
                    var listOfCurvesTwo = new List <Polyline>();

                    listOfCurves.AddRange(curves.Branch(0));

                    var listOfPlanes    = new List <Plane>();
                    var listOfPlanesOne = new List <Plane>();

                    listOfPlanes.AddRange(frames.Branch(0));

                    var pathOne = new GH_Path(1);
                    var pathTwo = new GH_Path(2);

                    for (int i = 0; i < curves.Branch(1).Count; ++i)
                    {
                        comparer.Add(points.Branch(1)[i].Z);

                        if (pointComparer >= comparer[i])
                        {
                            listOfCurves.Add(curves.Branch(1)[i], pathOne);
                        }

                        else
                        {
                            listOfCurvesOne.Add(curves.Branch(1)[i], pathOne);
                            listOfCurvesOne.Add(curves.Branch(2)[i], pathTwo);
                            listOfPlanesOne.Add(frames.Branch(1)[i]);
                        }
                    }

                    var comparerOne = new List <double>();

                    for (int i = 0; i < curves.Branch(2).Count; ++i)
                    {
                        comparerOne.Add(points.Branch(2)[i].Z);

                        if (pointComparer >= comparerOne[i])
                        {
                            listOfCurves.Add(curves.Branch(2)[i], pathTwo);
                        }

                        if (pointComparerOne >= comparerOne[i])
                        {
                        }

                        else
                        {
                            listOfCurvesTwo.Add(curves.Branch(2)[i]);
                        }
                    }

                    List <Polyline> listOfUnionObjs    = RegionUnion(listOfCurves, listOfPlanes);
                    List <Polyline> listOfUnionObjsOne = RegionUnion(listOfCurvesOne, listOfPlanesOne);

                    listOut.AddRange(listOfUnionObjs);
                    listOut.AddRange(listOfUnionObjsOne);
                    listOut.AddRange(listOfCurvesTwo);
                }

                else
                {
                    for (int i = 0; i < branches; ++i)
                    {
                        listOut.AddRange(curves.Branch(i));
                    }
                }
            }

            DA.SetDataList(0, listOut);

            var volume       = new DataTree <Brep>();
            var polyToCurves = new DataTree <Curve>();

            for (int i = 0; i < branches; ++i)
            {
                var path = new GH_Path(i);

                for (int j = 0; j < curves.Branch(i).Count; ++j)
                {
                    polyToCurves.Add(curves.Branch(i)[j].ToNurbsCurve(), path);
                }
            }

            for (int i = 0; i < branches; ++i)
            {
                volume.Add(Brep.CreateFromLoft(polyToCurves.Branch(i), Point3d.Unset, Point3d.Unset, LoftType.Tight, false)[0].CapPlanarHoles(0.0001), new GH_Path(i));
            }

            DA.SetDataTree(1, volume);

            DA.SetData(2, branches);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaMember2d gsaMember2d = new GsaMember2d();

            if (DA.GetData(0, ref gsaMember2d))
            {
                GsaMember2d mem = gsaMember2d.Duplicate();

                // #### inputs ####

                // 1 brep
                Brep brep = mem.Brep; //existing brep

                GH_Brep ghbrep = new GH_Brep();
                if (DA.GetData(1, ref ghbrep))
                {
                    if (GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both))
                    {
                        mem.Brep = brep;
                    }
                }

                // 2 section
                GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();

                if (DA.GetData(2, ref gh_typ))
                {
                    GsaProp2d prop2d = new GsaProp2d();
                    if (gh_typ.Value is GsaProp2d)
                    {
                        gh_typ.CastTo(ref prop2d);
                    }
                    else if (gh_typ.Value is GH_Number)
                    {
                        if (GH_Convert.ToInt32((GH_Number)gh_typ.Value, out int idd, GH_Conversion.Both))
                        {
                            prop2d.ID = idd;
                        }
                    }
                    mem.Property = prop2d;
                }

                // 3 offset
                GsaOffset offset = new GsaOffset();
                if (DA.GetData(3, ref offset))
                {
                    mem.Member.Offset.Z = offset.Z;
                }

                // 4 inclusion points
                List <Point3d>  pts   = mem.InclusionPoints;
                List <GH_Point> ghpts = new List <GH_Point>();
                if (DA.GetDataList(4, ghpts))
                {
                    for (int i = 0; i < ghpts.Count; i++)
                    {
                        Point3d pt = new Point3d();
                        if (GH_Convert.ToPoint3d(ghpts[i], ref pt, GH_Conversion.Both))
                        {
                            pts.Add(pt);
                        }
                    }
                }

                // 5 inclusion lines
                CurveList       crvlist = new CurveList(mem.InclusionLines);
                List <Curve>    crvs    = crvlist.ToList();
                List <GH_Curve> ghcrvs  = new List <GH_Curve>();
                if (DA.GetDataList(5, ghcrvs))
                {
                    for (int i = 0; i < ghcrvs.Count; i++)
                    {
                        Curve crv = null;
                        if (GH_Convert.ToCurve(ghcrvs[i], ref crv, GH_Conversion.Both))
                        {
                            crvs.Add(crv);
                        }
                    }
                }

                GsaMember2d tmpmem = new GsaMember2d(brep, crvs, pts)
                {
                    ID       = mem.ID,
                    Member   = mem.Member,
                    Property = mem.Property
                };
                mem = tmpmem;

                // 6 mesh size
                GH_Number ghmsz = new GH_Number();
                if (DA.GetData(6, ref ghmsz))
                {
                    if (GH_Convert.ToDouble(ghmsz, out double msz, GH_Conversion.Both))
                    {
                        mem.Member.MeshSize = msz;
                    }
                }

                // 7 mesh with others
                GH_Boolean ghbool = new GH_Boolean();
                if (DA.GetData(7, ref ghbool))
                {
                    if (GH_Convert.ToBoolean(ghbool, out bool mbool, GH_Conversion.Both))
                    {
                        //mem.member.MeshWithOthers
                    }
                }

                // 8 type
                GH_Integer ghint = new GH_Integer();
                if (DA.GetData(8, ref ghint))
                {
                    if (GH_Convert.ToInt32(ghint, out int type, GH_Conversion.Both))
                    {
                        mem.Member.Type = Util.Gsa.GsaToModel.Member2dType(type);
                    }
                }

                // 9 element type / analysis order
                GH_Integer ghinteg = new GH_Integer();
                if (DA.GetData(9, ref ghinteg))
                {
                    if (GH_Convert.ToInt32(ghinteg, out int type, GH_Conversion.Both))
                    {
                        mem.Member.Type2D = Util.Gsa.GsaToModel.Element2dType(type);
                    }
                }

                // 10 ID
                GH_Integer ghID = new GH_Integer();
                if (DA.GetData(10, ref ghID))
                {
                    if (GH_Convert.ToInt32(ghID, out int id, GH_Conversion.Both))
                    {
                        mem.ID = id;
                    }
                }

                // 11 name
                GH_String ghnm = new GH_String();
                if (DA.GetData(11, ref ghnm))
                {
                    if (GH_Convert.ToString(ghnm, out string name, GH_Conversion.Both))
                    {
                        mem.Member.Name = name;
                    }
                }

                // 12 Group
                GH_Integer ghgrp = new GH_Integer();
                if (DA.GetData(12, ref ghgrp))
                {
                    if (GH_Convert.ToInt32(ghgrp, out int grp, GH_Conversion.Both))
                    {
                        mem.Member.Group = grp;
                    }
                }

                // 13 Colour
                GH_Colour ghcol = new GH_Colour();
                if (DA.GetData(13, ref ghcol))
                {
                    if (GH_Convert.ToColor(ghcol, out System.Drawing.Color col, GH_Conversion.Both))
                    {
                        mem.Member.Colour = col;
                    }
                }

                // 14 Dummy
                GH_Boolean ghdum = new GH_Boolean();
                if (DA.GetData(14, ref ghdum))
                {
                    if (GH_Convert.ToBoolean(ghdum, out bool dum, GH_Conversion.Both))
                    {
                        mem.Member.IsDummy = dum;
                    }
                }

                // #### outputs ####

                DA.SetData(0, new GsaMember2dGoo(mem));

                DA.SetData(1, mem.Brep);

                DA.SetData(2, mem.Property);

                GsaOffset gsaOffset = new GsaOffset
                {
                    Z = mem.Member.Offset.Z
                };
                DA.SetData(3, gsaOffset);

                DA.SetDataList(4, mem.InclusionPoints);
                DA.SetDataList(5, mem.InclusionLines);

                DA.SetData(6, mem.Member.MeshSize);
                //DA.SetData(7, mem.member.MeshWithOthers);

                DA.SetData(8, mem.Member.Type);
                DA.SetData(9, mem.Member.Type2D);

                DA.SetData(10, mem.ID);
                DA.SetData(11, mem.Member.Name);
                DA.SetData(12, mem.Member.Group);
                DA.SetData(13, mem.Member.Colour);

                DA.SetData(14, mem.Member.IsDummy);
            }
        }
示例#15
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaMember2d gsaMember2d = new GsaMember2d();

            if (DA.GetData(0, ref gsaMember2d))
            {
                if (gsaMember2d == null)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Member2D input is null");
                }
                GsaMember2d mem = gsaMember2d.Duplicate();

                // #### inputs ####

                // 1 ID
                GH_Integer ghID = new GH_Integer();
                if (DA.GetData(1, ref ghID))
                {
                    if (GH_Convert.ToInt32(ghID, out int id, GH_Conversion.Both))
                    {
                        mem.ID = id;
                    }
                }

                // 2/3/4 Brep, incl.pts and incl.lns
                Brep            brep    = mem.Brep; //existing brep
                GH_Brep         ghbrep  = new GH_Brep();
                CurveList       crvlist = new CurveList(mem.InclusionLines);
                List <Curve>    crvs    = crvlist.ToList();
                List <GH_Curve> ghcrvs  = new List <GH_Curve>();
                List <GH_Point> ghpts   = new List <GH_Point>();
                List <Point3d>  pts     = mem.InclusionPoints;

                if ((DA.GetData(2, ref ghbrep)) || (DA.GetDataList(3, ghpts)) || (DA.GetDataList(4, ghcrvs)))
                {
                    // 2 brep
                    if (DA.GetData(2, ref ghbrep))
                    {
                        if (GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both))
                        {
                            mem.Brep = brep;
                        }
                    }

                    // 3 inclusion points
                    if (DA.GetDataList(3, ghpts))
                    {
                        for (int i = 0; i < ghpts.Count; i++)
                        {
                            Point3d pt = new Point3d();
                            if (GH_Convert.ToPoint3d(ghpts[i], ref pt, GH_Conversion.Both))
                            {
                                pts.Add(pt);
                            }
                        }
                    }

                    // 4 inclusion lines
                    if (DA.GetDataList(4, ghcrvs))
                    {
                        for (int i = 0; i < ghcrvs.Count; i++)
                        {
                            Curve crv = null;
                            if (GH_Convert.ToCurve(ghcrvs[i], ref crv, GH_Conversion.Both))
                            {
                                crvs.Add(crv);
                            }
                        }
                    }

                    GsaMember2d tmpmem = new GsaMember2d(brep, crvs, pts);
                    mem.PolyCurve            = tmpmem.PolyCurve;
                    mem.Topology             = tmpmem.Topology;
                    mem.TopologyType         = tmpmem.TopologyType;
                    mem.VoidTopology         = tmpmem.VoidTopology;
                    mem.VoidTopologyType     = tmpmem.VoidTopologyType;
                    mem.InclusionLines       = tmpmem.InclusionLines;
                    mem.IncLinesTopology     = tmpmem.IncLinesTopology;
                    mem.IncLinesTopologyType = tmpmem.IncLinesTopologyType;
                    mem.InclusionPoints      = tmpmem.InclusionPoints;

                    mem = tmpmem;
                }

                // 5 section
                GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();

                if (DA.GetData(5, ref gh_typ))
                {
                    GsaProp2d prop2d = new GsaProp2d();
                    if (gh_typ.Value is GsaProp2dGoo)
                    {
                        gh_typ.CastTo(ref prop2d);
                        mem.Property        = prop2d;
                        mem.Member.Property = 0;
                    }
                    else
                    {
                        if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both))
                        {
                            mem.Member.Property = idd;
                            mem.Property        = null;
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PA input to a 2D Property of reference integer");
                            return;
                        }
                    }
                }
示例#16
0
        /// <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)
        {
            // First, we need to retrieve all data from the input parameters.
            List <string>           fields         = new List <string>();
            GH_Structure <IGH_Goo>  attributes     = new GH_Structure <IGH_Goo>();
            GH_Structure <GH_Point> inputPointTree = new GH_Structure <GH_Point>();

            bool   writeFile = false;
            string filePath  = "";
            string prj       = null;

            if (!DA.GetData(5, ref writeFile))
            {
                return;
            }
            if (!DA.GetData(4, ref filePath))
            {
                return;
            }
            // access the input parameter by index.
            if (!DA.GetDataTree(0, out inputPointTree))
            {
                return;
            }
            if (!DA.GetDataList(1, fields))
            {
                return;
            }
            if (!DA.GetDataTree(2, out attributes))
            {
                return;
            }
            if (!DA.GetData(3, ref prj))
            {
                return;
            }


            //create new feature set to add data to
            //FeatureSet fs = new FeatureSet(FeatureType.Polygon);
            //FeatureSet fs = new FeatureSet(FeatureType.Point);
            FeatureSet fs = new FeatureSet(FeatureType.MultiPoint);


            if (prj != null)
            {
                //load projection file
                string cur_proj = System.IO.File.ReadAllText(@prj);

                ///create Projection system
                ProjectionInfo targetProjection = new ProjectionInfo();
                targetProjection.ParseEsriString(cur_proj);
                fs.Projection = targetProjection;
            }

            if (writeFile)
            {
                // Add fields to the feature sets attribute table
                foreach (string field in fields)
                {
                    //<<<dubble chack if this is properly declaring type>>>\\
                    fs.DataTable.Columns.Add(new DataColumn(field, typeof(string)));
                }
                // for every branch  (ie feature)
                foreach (GH_Path path in inputPointTree.Paths)
                {
                    //set branch
                    IList branch = inputPointTree.get_Branch(path);

                    // create a feature  geometry
                    List <Coordinate> vertices = new List <Coordinate>();

                    //add all pt coordinates to the vertices list
                    foreach (GH_Point pt in branch)
                    {
                        Point3d rhinoPoint = new Point3d();
                        GH_Convert.ToPoint3d(pt, ref rhinoPoint, 0);
                        vertices.Add(new Coordinate(rhinoPoint.X, rhinoPoint.Y));
                    }
                    //Convert Coordinates to dot spatial point or multipoint geometry
                    //DotSpatial.Topology.Point geom = new DotSpatial.Topology.Point(vertices);
                    DotSpatial.Topology.MultiPoint geom = new DotSpatial.Topology.MultiPoint(vertices);

                    //convert geom to a feature
                    IFeature feature = fs.AddFeature(geom);
                    //begin editing to add feature attributes
                    feature.DataRow.BeginEdit();
                    //get this features attributes by its path
                    IList <string> featrueAttributes = attributes.get_Branch(path) as IList <string>;
                    int            thisIndex         = 0;
                    //add each attribute for the pt's path
                    foreach (var thisAttribute in attributes.get_Branch(path))
                    {
                        //converting all fields to (((Proper Type...?)))
                        feature.DataRow[fields[thisIndex]] = thisAttribute.ToString(); //currently everything is a string....
                                                                                       //<<<!!!!!!!!!! dubble chack if this is properly converting to the type declared above !!!!!!!!!!>>>\\
                        thisIndex++;
                    }
                    //finish attribute additions
                    feature.DataRow.EndEdit();
                }//end of itterating through branches of pt tree
                fs.SaveAs(filePath, true);
            }
        }
示例#17
0
        /// <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)
        {
            // First, we need to retrieve all data from the input parameters.
            List <string>           fields         = new List <string>();
            GH_Structure <IGH_Goo>  attributes     = new GH_Structure <IGH_Goo>();
            GH_Structure <GH_Point> inputPointTree = new GH_Structure <GH_Point>();

            bool   writeFile = false;
            string filePath  = "";
            int    epsg      = -1;

            if (!DA.GetData(5, ref writeFile))
            {
                return;
            }
            if (!DA.GetData(4, ref filePath))
            {
                return;
            }
            // access the input parameter by index.
            if (!DA.GetDataTree(0, out inputPointTree))
            {
                return;
            }
            if (!DA.GetDataList(1, fields))
            {
                return;
            }
            if (!DA.GetDataTree(2, out attributes))
            {
                return;
            }
            if (!DA.GetData(3, ref epsg))
            {
                return;
            }
            // We should now validate the data and warn the user if invalid data is supplied.
            //if (radius0 < 0.0){
            //    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Inner radius must be bigger than or equal to zero");
            //    return;}

            //Create geojson dic
            Dictionary <string, Object> geoDict = new Dictionary <string, Object>();

            // We're set to create the geojson now. To keep the size of the SolveInstance() method small,
            // The actual functionality will be in a different method:
            //Curve spiral = CreateSpiral(plane, radius0, radius1, turns);


            //Basic esriJSON headder info
            geoDict.Add("displayFieldName", " ");

            Dictionary <string, string> fieldAliasDic = new Dictionary <string, string>();

            foreach (string field in fields)
            {
                fieldAliasDic.Add(field, field);
            }
            geoDict.Add("fieldAliases", fieldAliasDic);

            geoDict.Add("geometryType", "esriGeometryPoint");
            Dictionary <string, int> sr = new Dictionary <string, int>()
            {
                { "wkid", epsg }, { "latestWkid", -1 }
            };

            geoDict.Add("spatialReference", sr);

            // package the below in a function
            List <Dictionary <string, string> > fieldsList = new List <Dictionary <string, string> >();

            foreach (var item in fields.Select((Value, Index) => new { Value, Index }))
            {
                Dictionary <string, string> fieldTypeDict = new Dictionary <string, string>();


                fieldTypeDict.Add("name", item.Value.ToString());

                var typeItem = attributes.get_Branch(attributes.Paths[0])[item.Index];

                if (typeItem is Grasshopper.Kernel.Types.GH_Integer)
                {
                    fieldTypeDict.Add("type", "esriFieldTypeInteger");
                }

                else if (typeItem is Grasshopper.Kernel.Types.GH_Number) // else if (typeItem is long //|| typeItem is ulong //|| typeItem is float //|| typeItem is double //|| typeItem is decimal)
                {
                    fieldTypeDict.Add("type", "esriFieldTypeDouble");
                }

                else if (typeItem is Grasshopper.Kernel.Types.GH_String)
                {
                    fieldTypeDict.Add("type", "esriFieldTypeString");
                }

                else if (typeItem is Grasshopper.Kernel.Types.GH_Time)
                {
                    fieldTypeDict.Add("type", "esriFieldTypeDate");
                }

                else
                {
                    fieldTypeDict.Add("type", "esriFieldTypeString");
                    fieldTypeDict.Add("GH_Type", typeItem.GetType().ToString());
                }
                if (item.Value.ToString().Length > 7)
                {
                    fieldTypeDict.Add("alias", item.Value.ToString().Substring(0, 7));
                }
                else
                {
                    fieldTypeDict.Add("alias", item.Value.ToString());
                }

                fieldsList.Add(fieldTypeDict);
            }//end for each fields
            geoDict.Add("fields", fieldsList);

            // package the above in a function ^^^
            //features: [
            //    {
            //        geometry:{Paths:[ [-[x,y],[x1,y1]-], [-[x,y],[x1,y1]-]  ]
            //        attributes:{ field:value, field1:value1}
            //    },
            //    {
            //        geometry:{Paths:[ [-[x,y],[x1,y1]-], [-[x,y],[x1,y1]-]  ]
            //        attributes:{ field:value, field1:value1}
            //    }
            //]

            // Start of  feature construction----------------------------------------------------
            // create feature list
            List <Object> featuresList = new List <Object>();

            // for every branch  (ie feature)
            foreach (GH_Path path in inputPointTree.Paths)
            {
                //set branch
                IList branch = inputPointTree.get_Branch(path);

                //create geometry key
                Dictionary <string, object> thisGeometry = new Dictionary <string, object>();

                //for multipart create list to hold coordinate lists
                //List<object> thisPointList = new List<object>();

                // for every point  in branch
                foreach (GH_Point thisGhPoint in branch)
                {
                    Rhino.Geometry.Point3d thisRhinoPoint = new Point3d();
                    GH_Convert.ToPoint3d(thisGhPoint, ref thisRhinoPoint, 0);

                    //Non-multipoint
                    thisGeometry.Add("x", thisRhinoPoint.X);
                    thisGeometry.Add("y", thisRhinoPoint.Y);

                    //create coordinate list and add to path list
                    //List<double> thisCoordinate = new List<double>();

                    //add coordinates
                    //thisCoordinate.Add(thisRhinoPoint.X);
                    //thisCoordinate.Add(thisRhinoPoint.Y);

                    //add to feature list
                    //thisPointList.Add(thisCoordinate);
                }//end of each point in branch

                //thisGeometry.Add("Points", thisPointList);
                //above would be used for multipart

                //creat attriabtrues key
                Dictionary <string, object> thisAttribtues = new Dictionary <string, object>();
                IList attributesBranch = attributes.get_Branch(path);

                //foreach (var item in attributesBranch.Select((Value, Index) => new { Value, Index })) //this needs list not IList
                foreach (var item in attributesBranch)
                //for (int i = 0; i < attributesBranch.Count; i++)
                {
                    string thisField = fields[attributesBranch.IndexOf(item)]; //fields are string

                    // ---------------------this is in order add the riight type?

                    if (item is Grasshopper.Kernel.Types.GH_Integer)
                    {
                        string thisAttribute = item.ToString();
                        Convert.ChangeType(thisAttribute, typeof(int));
                        thisAttribtues.Add(thisField, thisAttribute);
                    }

                    else if (item is Grasshopper.Kernel.Types.GH_Number) // else if (typeItem is long //|| typeItem is ulong //|| typeItem is float //|| typeItem is double //|| typeItem is decimal)
                    {
                        string thisAttribute = item.ToString();
                        Convert.ChangeType(thisAttribute, typeof(double));
                        thisAttribtues.Add(thisField, thisAttribute);
                    }

                    else if (item is Grasshopper.Kernel.Types.GH_String)
                    {
                        string thisAttribute = item.ToString();
                        thisAttribtues.Add(thisField, thisAttribute);
                    }

                    else if (item is Grasshopper.Kernel.Types.GH_Time)
                    {
                        string thisAttribute = item.ToString();
                        Convert.ChangeType(thisAttribute, typeof(DateTime));
                        thisAttribtues.Add(thisField, thisAttribute);
                    }

                    else
                    {
                        string thisAttribute = "wasent a type"; item.ToString();
                        thisAttribtues.Add(thisField, thisAttribute);
                    }

                    // ------------------------how to add value of igh_goo verbatum....
                    //thisAttribtues.Add(thisField, thisAttribute);
                }


                //wrap up into feature and add to feature list;
                Dictionary <string, Object> thisFeature = new Dictionary <string, Object>();

                thisFeature.Add("geometry", thisGeometry);
                thisFeature.Add("attributes", thisAttribtues);
                featuresList.Add(thisFeature);
            }//end of each branch path

            // end of  feature construction

            // finaly add features list to master object
            geoDict.Add("features", featuresList);


            //Produces convert dictionary to json text

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(geoDict, Newtonsoft.Json.Formatting.Indented);

            // Finally assign the retults to the output parameter.
            //DA.SetData(0, spiral);

            //write string to file
            if (writeFile == true)
            {
                //@"D:\path.txt"
                System.IO.File.WriteAllText(@filePath, json);
            }
            DA.SetData(0, json);
        }
示例#18
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Brep ghbrep = new GH_Brep();

            if (DA.GetData(0, ref ghbrep))
            {
                Brep brep = new Brep();
                if (GH_Convert.ToBrep(ghbrep, ref brep, GH_Conversion.Both))
                {
                    // first import points and curves for inclusion before building member

                    // 2 Points
                    List <Point3d>  pts   = new List <Point3d>();
                    List <GH_Point> ghpts = new List <GH_Point>();
                    if (DA.GetDataList(2, ghpts))
                    {
                        for (int i = 0; i < ghpts.Count; i++)
                        {
                            Point3d pt = new Point3d();
                            if (GH_Convert.ToPoint3d(ghpts[i], ref pt, GH_Conversion.Both))
                            {
                                pts.Add(pt);
                            }
                        }
                    }

                    // 3 Curves
                    List <Curve>    crvs   = new List <Curve>();
                    List <GH_Curve> ghcrvs = new List <GH_Curve>();
                    if (DA.GetDataList(3, ghcrvs))
                    {
                        for (int i = 0; i < ghcrvs.Count; i++)
                        {
                            Curve crv = null;
                            if (GH_Convert.ToCurve(ghcrvs[i], ref crv, GH_Conversion.Both))
                            {
                                crvs.Add(crv);
                            }
                        }
                    }

                    // now build new member with brep, crv and pts
                    GsaMember2d mem = new GsaMember2d(brep, crvs, pts);

                    // add the rest
                    // 1 section
                    GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                    GsaProp2d        prop2d = new GsaProp2d();
                    if (DA.GetData(1, ref gh_typ))
                    {
                        if (gh_typ.Value is GsaProp2d)
                        {
                            gh_typ.CastTo(ref prop2d);
                        }
                        else if (gh_typ.Value is GH_Number)
                        {
                            if (GH_Convert.ToInt32((GH_Number)gh_typ.Value, out int idd, GH_Conversion.Both))
                            {
                                prop2d.ID = idd;
                            }
                        }
                    }
                    else
                    {
                        prop2d.ID = 1;
                    }
                    mem.Property = prop2d;

                    // 4 mesh size
                    GH_Number ghmsz = new GH_Number();
                    if (DA.GetData(4, ref ghmsz))
                    {
                        GH_Convert.ToDouble(ghmsz, out double m_size, GH_Conversion.Both);
                        mem.Member.MeshSize = m_size;
                    }

                    DA.SetData(0, new GsaMember2dGoo(mem));
                }
            }
        }
示例#19
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Input Holders
            List <double>           Flow     = new List <double>();
            List <double>           Speed    = new List <double>();
            List <GH_ObjectWrapper> Movement = new List <GH_ObjectWrapper>();
            GH_ObjectWrapper        dObject  = new GH_ObjectWrapper();

            List <SilkwormLine> sMovement = new List <SilkwormLine>();


            //Input
            if (!DA.GetData(3, ref dObject))
            {
            }

            if (!DA.GetDataList(1, Speed))
            {
            }

            if (!DA.GetDataList(2, Flow))
            {
            }

            if (!DA.GetDataList(0, Movement))
            {
                return;
            }


            //Fill Input with placeholders if empty
            if (Speed.Count < 1)
            {
                for (int j = 0; j < Movement.Count; j++)
                {
                    Speed.Add(-1);
                }
            }
            if (Speed.Count == 1)
            {
                if (Movement.Count > 1)
                {
                    for (int j = 0; j < Movement.Count; j++)
                    {
                        Speed.Add(Speed[0]);
                    }
                }
            }
            if (Flow.Count < 1)
            {
                for (int k = 0; k < Movement.Count; k++)
                {
                    Flow.Add(-1);
                }
            }
            if (Flow.Count == 1)
            {
                if (Movement.Count > 1)
                {
                    for (int k = 0; k < Movement.Count; k++)
                    {
                        Flow.Add(Flow[0]);
                    }
                }
            }


            #region Sort Geometric Input
            List <Curve>   curves = new List <Curve>();
            List <Line>    lines  = new List <Line>();
            List <Point3d> points = new List <Point3d>();

            foreach (GH_ObjectWrapper Goo in Movement)
            {
                if (Goo.Value is GH_Curve)
                {
                    Curve curve = null;
                    GH_Convert.ToCurve(Goo.Value, ref curve, GH_Conversion.Both);
                    curves.Add(curve);
                    continue;
                }
                if (Goo.Value is GH_Line)
                {
                    Line line = new Line();
                    GH_Convert.ToLine(Goo.Value, ref line, GH_Conversion.Both);
                    lines.Add(line);
                    continue;
                }

                if (Goo.Value is GH_Point)
                {
                    Point3d point = new Point3d();
                    GH_Convert.ToPoint3d(Goo.Value, ref point, GH_Conversion.Both);
                    points.Add(point);
                    continue;
                }
            }
            #endregion

            #region Sort Numerical Input
            #endregion

            //Output Holder
            SilkwormMovement sModel = new SilkwormMovement();

            //Convert Different Geometry types to Movements based on input parameters
            #region Catch Exceptions
            if (points.Count > 1 || curves.Count > 1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Only one curve or point per movement");
            }
            if (points.Count == 1 || curves.Count == 1)
            {
                if (Flow.Count > 1 || Speed.Count > 1)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Flow or Speed Values do not match length of Input");
                }
            }
            #endregion

            #region if curve
            ////Make Silkworm Lines
            if (curves.Count > 0 && curves.Count < 2)
            {
                List <Line>     sLines    = new List <Line>();
                Curve           newcurve  = curves[0];
                SilkwormSegment segmented = new SilkwormSegment(newcurve);

                //Make lines from curves
                foreach (Curve curve in segmented.Segments)
                {
                    Line line = new Line(curve.PointAtStart, curve.PointAtEnd);
                    sLines.Add(line);
                }

                //Create Silkworm Line from each line and a single flow or speed value
                for (int i = 0; i < sLines.Count; i++)
                {
                    SilkwormLine sLine = new SilkwormLine(Flow[0], Speed[0], sLines[i]);
                    sMovement.Add(sLine);
                }

                //Add Custom Delimiter or Default Delimiter (depending if input is provided)
                if (dObject.Value is Delimiter)
                {
                    Delimiter delimiter = (Delimiter)dObject.Value;

                    sModel = new SilkwormMovement(sMovement, delimiter);
                }
                else
                {
                    sModel = new SilkwormMovement(sMovement, new Delimiter());
                }
            }
            #endregion

            #region if lines
            //Make Silkworm Lines
            if (lines.Count > 0)
            {
                #region More Error Catching
                if (Flow.Count > 1 && Flow.Count != lines.Count)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Flow Values do not match length of Line List");
                }
                if (Speed.Count > 1 && Speed.Count != lines.Count)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Speed Values do not match length of Line List");
                }
                #endregion

                //Create Silkworm Line from each line and a corresponding flow or speed value
                //(will create an incomplete movement if none are provided)
                if (Flow.Count == lines.Count && Speed.Count == lines.Count)
                {
                    for (int i = 0; i < lines.Count; i++)
                    {
                        SilkwormLine sLine = new SilkwormLine(Flow[i], Speed[i], lines[i]);
                        sMovement.Add(sLine);
                    }
                }


                //Add Custom Delimiter or Default Delimiter (depending if input is provided)
                if (dObject.Value is Delimiter)
                {
                    Delimiter delimiter = (Delimiter)dObject.Value;

                    sModel = new SilkwormMovement(sMovement, delimiter);
                }
                else
                {
                    sModel = new SilkwormMovement(sMovement, new Delimiter());
                }
            }
            #endregion

            #region if point
            if (points.Count < 2 && points.Count > 0)
            {
                if (dObject.Value is Delimiter)
                {
                    Delimiter delimiter = (Delimiter)dObject.Value;

                    sModel = new SilkwormMovement(points[0], delimiter);
                }
                else
                {
                    sModel = new SilkwormMovement(points[0], new Delimiter());
                }
            }
            #endregion

            //Output
            DA.SetData(0, sModel);
        }
示例#20
0
        /// <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 <GH_Point> iProbes;

            DA.GetDataTree(0, out iProbes);


            DataTree <Point3d> convertedProbesTree = new DataTree <Point3d>();

            int     x = 0;
            Point3d convertedPoint = new Point3d();

            foreach (GH_Path path in iProbes.Paths)
            {
                foreach (var pt in iProbes.get_Branch(path))
                {
                    GH_Convert.ToPoint3d(pt, ref convertedPoint, 0);
                    convertedProbesTree.Add(convertedPoint, new GH_Path(x));
                    convertedPoint = new Point3d();
                }
                x += 1;
            }


            List <TextFile> windProbesFiles = new List <TextFile>();

            foreach (var path in convertedProbesTree.Paths)
            {
                #region shellString
                string shellString =
                    "/*--------------------------------*- C++ -*----------------------------------*\\\n" +
                    "| =========                 |                                                 |\n" +
                    "| \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |\n" +
                    "|  \\\\    /   O peration     | Website:  www.OpenFOAM.org                      |\n" +
                    "|   \\\\  /    A nd           | Version: 6                                      |\n" +
                    "|    \\\\/     M anipulation  |                                                 |\n" +
                    "\\*---------------------------------------------------------------------------*/\n" +
                    "{0}\n" +
                    "   {{\n" +

                    "       // Where to load it from\n" +
                    "       functionObjectLibs (\"libsampling.so\");\n" +

                    "       type probes;\n" +

                    "       // Name of the directory for probe data\n" +
                    "       name {1};\n" +

                    "       // Write at same frequency as fields\n" +
                    "       writeControl timeStep;\n" +
                    "       writeInterval  1;\n" +

                    "       // Fields to be probed\n" +
                    "       fields\n" +
                    "       (\n" +
                    "           p U\n" +
                    "       );\n" +

                    "       //For Spectral analysis and velo profile\n" +
                    "       probeLocations\n" +
                    "       (\n" +
                    "       {2}\n" +
                    "       );\n" +
                    "   }}";
                #endregion

                string ptCoord = "";
                foreach (var pt in convertedProbesTree.Branch(path))
                {
                    ptCoord += "(" + pt.X.ToString() + "   " + pt.Y.ToString() + "   " + pt.Z.ToString() + ")\n       ";
                }

                string name = "windProbes_" + path.ToString().Replace("{", "").Replace("}", "");

                string tempWindFile = string.Format(shellString, name, name, ptCoord);

                var oWindFile = new TextFile(tempWindFile, name);

                windProbesFiles.Add(oWindFile);
            }

            DA.SetDataList(0, windProbesFiles);
        }