예제 #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Curve baseline = new GH_Curve();
            GH_String layer = new GH_String("");
            GH_Number height = new GH_Number();
            GH_String style = new GH_String("");
            List<Parameter> param = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>();

            //DA.GetData<GH_String>("Family", ref family);
            DA.GetData<GH_String>("Layer", ref layer);
            DA.GetData<GH_String>("Style", ref style);
            DA.GetData<GH_Number>("Height", ref height);
            DA.GetData<GH_Curve>("Baseline", ref baseline);


            Wall w = new Wall(style.Value,layer.Value,param, baseline.ToGrevitCurve(),"",height.Value,true,false);

            SetGID(w);
            Rhino.Geometry.Surface srf = Rhino.Geometry.Surface.CreateExtrusion(baseline.Value, new Rhino.Geometry.Vector3d(0, 0, height.Value));
            SetPreview(w.GID, srf.ToBrep());
            DA.SetData("GrevitComponent",w);
        }
예제 #2
0
        public void SetInputs(List <DataTree <ResthopperObject> > values)
        {
            foreach (var tree in values)
            {
                if (!_input.TryGetValue(tree.ParamName, out var inputGroup))
                {
                    continue;
                }

                if (inputGroup.AlreadySet(tree))
                {
                    LogDebug("Skipping input tree... same input");
                    continue;
                }

                inputGroup.CacheTree(tree);

                IGH_ContextualParameter contextualParameter = inputGroup.Param as IGH_ContextualParameter;
                if (contextualParameter != null)
                {
                    switch (ParamTypeName(inputGroup.Param))
                    {
                    case "Number":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            double[] doubles = new double[entree.Value.Count];
                            for (int i = 0; i < doubles.Length; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                doubles[i] = JsonConvert.DeserializeObject <double>(restobj.Data);
                            }
                            contextualParameter.AssignContextualData(doubles);
                            break;
                        }
                    }
                    break;

                    case "Integer":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            int[] integers = new int[entree.Value.Count];
                            for (int i = 0; i < integers.Length; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                integers[i] = JsonConvert.DeserializeObject <int>(restobj.Data);
                            }
                            contextualParameter.AssignContextualData(integers);
                            break;
                        }
                    }
                    break;

                    case "Point":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            Point3d[] points = new Point3d[entree.Value.Count];
                            for (int i = 0; i < entree.Value.Count; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                points[i] = JsonConvert.DeserializeObject <Rhino.Geometry.Point3d>(restobj.Data);
                            }
                            contextualParameter.AssignContextualData(points);
                            break;
                        }
                    }
                    break;

                    case "Line":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            Line[] lines = new Line[entree.Value.Count];
                            for (int i = 0; i < entree.Value.Count; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                lines[i] = JsonConvert.DeserializeObject <Rhino.Geometry.Line>(restobj.Data);
                            }
                            contextualParameter.AssignContextualData(lines);
                            break;
                        }
                    }
                    break;

                    case "Text":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            string[] strings = new string[entree.Value.Count];
                            for (int i = 0; i < entree.Value.Count; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                strings[i] = restobj.Data.Trim(new char[] { '"' });
                            }
                            contextualParameter.AssignContextualData(strings);
                            break;
                        }
                    }
                    break;

                    case "Geometry":
                    {
                        foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                        {
                            GeometryBase[] geometries = new GeometryBase[entree.Value.Count];
                            for (int i = 0; i < entree.Value.Count; i++)
                            {
                                ResthopperObject restobj = entree.Value[i];
                                var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(restobj.Data);
                                geometries[i] = Rhino.Runtime.CommonObject.FromJSON(dict) as GeometryBase;
                            }
                            contextualParameter.AssignContextualData(geometries);
                            break;
                        }
                    }
                    break;
                    }
                    continue;
                }

                inputGroup.Param.VolatileData.Clear();
                inputGroup.Param.ExpireSolution(false); // mark param as expired but don't recompute just yet!

                if (inputGroup.Param is Param_Point)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject       restobj = entree.Value[i];
                            Rhino.Geometry.Point3d rPt     = JsonConvert.DeserializeObject <Rhino.Geometry.Point3d>(restobj.Data);
                            GH_Point data = new GH_Point(rPt);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Vector)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject        restobj  = entree.Value[i];
                            Rhino.Geometry.Vector3d rhVector = JsonConvert.DeserializeObject <Rhino.Geometry.Vector3d>(restobj.Data);
                            GH_Vector data = new GH_Vector(rhVector);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Integer)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            int        rhinoInt      = JsonConvert.DeserializeObject <int>(restobj.Data);
                            GH_Integer data          = new GH_Integer(rhinoInt);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Number)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                            GH_Number        data     = new GH_Number(rhNumber);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_String)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            string           rhString = restobj.Data;
                            GH_String        data     = new GH_String(rhString);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Line)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Line rhLine  = JsonConvert.DeserializeObject <Rhino.Geometry.Line>(restobj.Data);
                            GH_Line             data    = new GH_Line(rhLine);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Curve)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            GH_Curve         ghCurve;
                            try
                            {
                                Rhino.Geometry.Polyline data = JsonConvert.DeserializeObject <Rhino.Geometry.Polyline>(restobj.Data);
                                Rhino.Geometry.Curve    c    = new Rhino.Geometry.PolylineCurve(data);
                                ghCurve = new GH_Curve(c);
                            }
                            catch
                            {
                                var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(restobj.Data);
                                var c    = (Rhino.Geometry.Curve)Rhino.Runtime.CommonObject.FromJSON(dict);
                                ghCurve = new GH_Curve(c);
                            }
                            inputGroup.Param.AddVolatileData(path, i, ghCurve);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Circle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject      restobj  = entree.Value[i];
                            Rhino.Geometry.Circle rhCircle = JsonConvert.DeserializeObject <Rhino.Geometry.Circle>(restobj.Data);
                            GH_Circle             data     = new GH_Circle(rhCircle);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Plane)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject     restobj = entree.Value[i];
                            Rhino.Geometry.Plane rhPlane = JsonConvert.DeserializeObject <Rhino.Geometry.Plane>(restobj.Data);
                            GH_Plane             data    = new GH_Plane(rhPlane);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Rectangle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject           restobj     = entree.Value[i];
                            Rhino.Geometry.Rectangle3d rhRectangle = JsonConvert.DeserializeObject <Rhino.Geometry.Rectangle3d>(restobj.Data);
                            GH_Rectangle data = new GH_Rectangle(rhRectangle);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Box)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject   restobj = entree.Value[i];
                            Rhino.Geometry.Box rhBox   = JsonConvert.DeserializeObject <Rhino.Geometry.Box>(restobj.Data);
                            GH_Box             data    = new GH_Box(rhBox);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Surface)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject       restobj   = entree.Value[i];
                            Rhino.Geometry.Surface rhSurface = JsonConvert.DeserializeObject <Rhino.Geometry.Surface>(restobj.Data);
                            GH_Surface             data      = new GH_Surface(rhSurface);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Brep)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Brep rhBrep  = JsonConvert.DeserializeObject <Rhino.Geometry.Brep>(restobj.Data);
                            GH_Brep             data    = new GH_Brep(rhBrep);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Mesh)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Mesh rhMesh  = JsonConvert.DeserializeObject <Rhino.Geometry.Mesh>(restobj.Data);
                            GH_Mesh             data    = new GH_Mesh(rhMesh);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is GH_NumberSlider)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                            GH_Number        data     = new GH_Number(rhNumber);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Boolean || inputGroup.Param is GH_BooleanToggle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            bool             boolean = JsonConvert.DeserializeObject <bool>(restobj.Data);
                            GH_Boolean       data    = new GH_Boolean(boolean);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is GH_Panel)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            string           rhString = JsonConvert.DeserializeObject <string>(restobj.Data);
                            GH_String        data     = new GH_String(rhString);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Updates the geometry for an input chromosome
        /// </summary>
        /// <param name="chromo">The chromosome used to get geometry from the gh canvas</param>
        /// <returns></returns>
        public int GetGeometry(Chromosome chromo)
        {
            // Collect the object at the current instance
            List <object> localObjs = new List <object>();

            // Thank you Dimitrie :)
            foreach (IGH_Param param in Params.Input[1].Sources)
            {
                foreach (Object myObj in param.VolatileData.AllData(true)) // AllData flattens the tree
                {
                    localObjs.Add(myObj);
                }
            }

            // Gets lists of different geometry
            List <Mesh>          meshGeometry = new List <Mesh>();
            List <PolylineCurve> polyGeometry = new List <PolylineCurve>();

            // Get only mesh geometry from the object list
            for (int i = 0; i < localObjs.Count; i++)
            {
                // Need to replace with a Switch

                if (localObjs[i] is GH_Mesh)
                {
                    GH_Mesh myGHMesh = new GH_Mesh();
                    myGHMesh = (GH_Mesh)localObjs[i];
                    Mesh myLocalMesh = new Mesh();
                    GH_Convert.ToMesh(myGHMesh, ref myLocalMesh, GH_Conversion.Primary);
                    myLocalMesh.Faces.ConvertQuadsToTriangles();

                    meshGeometry.Add(myLocalMesh);

                    //Mesh joinedMesh = new Mesh();
                    //joinedMesh.Append(myLocalMesh);
                }

                if (localObjs[i] is GH_Brep)
                {
                    GH_Brep myBrep = new GH_Brep();
                    myBrep = (GH_Brep)localObjs[i];

                    Mesh[] meshes = Mesh.CreateFromBrep(myBrep.Value, MeshingParameters.FastRenderMesh);

                    Mesh mesh = new Mesh();
                    mesh.Append(meshes);
                    mesh.Faces.ConvertQuadsToTriangles();

                    meshGeometry.Add(mesh);
                }

                if (localObjs[i] is GH_Box)
                {
                    GH_Box myBox  = new GH_Box((GH_Box)localObjs[i]);
                    Mesh[] meshes = Mesh.CreateFromBrep(myBox.Brep(), MeshingParameters.FastRenderMesh);

                    Mesh mesh = new Mesh();
                    mesh.Append(meshes);
                    mesh.Faces.ConvertQuadsToTriangles();

                    meshGeometry.Add(mesh);
                }

                if (localObjs[i] is GH_Surface)
                {
                    GH_Surface mySurface = (GH_Surface)localObjs[i];

                    Mesh[] meshes = Mesh.CreateFromBrep(mySurface.Value, MeshingParameters.FastRenderMesh);

                    Mesh mesh = new Mesh();
                    mesh.Append(meshes);
                    mesh.Faces.ConvertQuadsToTriangles();

                    meshGeometry.Add(mesh);
                }

                if (localObjs[i] is GH_Curve)
                {
                    GH_Curve      myGHCurve = (GH_Curve)localObjs[i];
                    PolylineCurve myPoly    = myGHCurve.Value.ToPolyline(0, 0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, true);
                    polyGeometry.Add(myPoly);
                }

                if (localObjs[i] is GH_Arc)
                {
                    GH_Arc        myGHArc = (GH_Arc)localObjs[i];
                    PolylineCurve myPoly  = myGHArc.Value.ToNurbsCurve().ToPolyline(0, 0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, true);
                    polyGeometry.Add(myPoly);
                }

                if (localObjs[i] is GH_Line)
                {
                    GH_Line        myGHLine = (GH_Line)localObjs[i];
                    List <Point3d> pts      = new List <Point3d> {
                        myGHLine.Value.From, myGHLine.Value.To
                    };
                    PolylineCurve myPoly = new PolylineCurve(pts);
                    polyGeometry.Add(myPoly);
                }
            }

            // Get performance data
            List <double> performas = new List <double>();
            List <string> criteria  = new List <string>();

            // Cap at eight criteria max.
            int pCount        = 0;
            int repeatCounter = 1;

            foreach (IGH_Param param in Params.Input[2].Sources)
            {
                foreach (Object myObj in param.VolatileData.AllData(true))
                {
                    if (myObj is GH_Number && pCount < 8)
                    {
                        GH_Number temp = (GH_Number)myObj;
                        performas.Add(temp.Value);

                        if (!criteria.Contains(param.NickName))
                        {
                            criteria.Add(param.NickName);
                        }

                        else
                        {
                            criteria.Add(param.NickName + " (" + repeatCounter + ")");
                            repeatCounter++;
                        }

                        pCount++;
                    }

                    else if (myObj is GH_Integer && pCount < 8)
                    {
                        GH_Integer temp = (GH_Integer)myObj;
                        performas.Add((double)temp.Value);

                        if (!criteria.Contains(param.NickName))
                        {
                            criteria.Add(param.NickName);
                        }

                        else
                        {
                            criteria.Add(param.NickName + " (" + repeatCounter + ")");
                            repeatCounter++;
                        }

                        pCount++;
                    }
                }
            }

            // Set the phenotype within the chromosome class
            chromo.SetPhenotype(meshGeometry, polyGeometry, performas, criteria);

            // Return the number of performance criteria
            return(performas.Count);
        }
예제 #4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Model to work on
            GsaModel in_Model = new GsaModel();

            // Get Model
            GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();

            if (DA.GetData(0, ref gh_typ))
            {
                #region Inputs
                if (gh_typ.Value is GsaModelGoo)
                {
                    gh_typ.CastTo(ref in_Model);
                    if (gsaModel != null)
                    {
                        if (in_Model.GUID != gsaModel.GUID)
                        {
                            gsaModel   = in_Model;
                            getresults = true;
                        }
                    }
                    else
                    {
                        gsaModel = in_Model;
                    }
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Error converting input to GSA Model");
                    return;
                }

                // Get analysis case
                GH_Integer gh_aCase = new GH_Integer();
                DA.GetData(1, ref gh_aCase);
                GH_Convert.ToInt32(gh_aCase, out int tempanalCase, GH_Conversion.Both);

                // Get element filter list
                GH_String gh_elList = new GH_String();
                DA.GetData(2, ref gh_elList);
                GH_Convert.ToString(gh_elList, out string tempelemList, GH_Conversion.Both);

                // Get number of divisions
                GH_Integer gh_Div = new GH_Integer();
                DA.GetData(3, ref gh_Div);
                GH_Convert.ToInt32(gh_Div, out int temppositionsCount, GH_Conversion.Both);

                // Get colours
                List <Grasshopper.Kernel.Types.GH_Colour> gh_Colours = new List <Grasshopper.Kernel.Types.GH_Colour>();
                List <System.Drawing.Color> colors = new List <System.Drawing.Color>();
                if (DA.GetDataList(4, gh_Colours))
                {
                    for (int i = 0; i < gh_Colours.Count; i++)
                    {
                        System.Drawing.Color color = new System.Drawing.Color();
                        GH_Convert.ToColor(gh_Colours[i], out color, GH_Conversion.Both);
                        colors.Add(color);
                    }
                }
                Grasshopper.GUI.Gradient.GH_Gradient gH_Gradient = UI.Colour.Stress_Gradient(colors);

                // Get scalar
                GH_Number gh_Scale = new GH_Number();
                DA.GetData(5, ref gh_Scale);
                double scale = 1;
                GH_Convert.ToDouble(gh_Scale, out scale, GH_Conversion.Both);
                #endregion

                #region get results?
                // check if we must get results or just update display
                if (analCase == 0 || analCase != tempanalCase)
                {
                    analCase   = tempanalCase;
                    getresults = true;
                }

                if (elemList == "" || elemList != tempelemList)
                {
                    elemList   = tempelemList;
                    getresults = true;
                }

                if (positionsCount == 0 || positionsCount != temppositionsCount)
                {
                    positionsCount = temppositionsCount;
                    getresults     = true;
                }
                #endregion

                #region Create results output
                if (getresults)
                {
                    #region Get results from GSA
                    // ### Get results ###
                    //Get analysis case from model
                    AnalysisCaseResult analysisCaseResult = null;
                    gsaModel.Model.Results().TryGetValue(analCase, out analysisCaseResult);
                    if (analysisCaseResult == null)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No results exist for Analysis Case " + analCase + " in file");
                        return;
                    }
                    IReadOnlyDictionary <int, Element1DResult> globalResults = analysisCaseResult.Element1DResults(elemList, positionsCount);
                    IReadOnlyDictionary <int, Element>         elems         = gsaModel.Model.Elements(elemList);
                    IReadOnlyDictionary <int, Node>            nodes         = gsaModel.Model.Nodes();
                    #endregion


                    // ### Loop through results ###
                    // clear existing result lists
                    xyz_out      = new DataTree <Vector3d>();
                    xxyyzz_out   = new DataTree <Vector3d>();
                    segmentlines = new DataTree <Line>();

                    List <int> elemID       = new List <int>();
                    List <int> parentMember = new List <int>();

                    // maximum and minimum result values for colouring later
                    dmax_x      = 0;
                    dmax_y      = 0;
                    dmax_z      = 0;
                    dmax_xx     = 0;
                    dmax_yy     = 0;
                    dmax_zz     = 0;
                    dmax_xyz    = 0;
                    dmax_xxyyzz = 0;
                    dmin_x      = 0;
                    dmin_y      = 0;
                    dmin_z      = 0;
                    dmin_xx     = 0;
                    dmin_yy     = 0;
                    dmin_zz     = 0;
                    dmin_xyz    = 0;
                    dmin_xxyyzz = 0;

                    double unitfactorxyz    = 1;
                    double unitfactorxxyyzz = 1;

                    foreach (int key in globalResults.Keys)
                    {
                        // lists for results
                        Element1DResult elementResults;
                        globalResults.TryGetValue(key, out elementResults);
                        List <Double6>  values = new List <Double6>();
                        List <Vector3d> xyz    = new List <Vector3d>();
                        List <Vector3d> xxyyzz = new List <Vector3d>();

                        // list for element geometry and info
                        Element element = new Element();
                        elems.TryGetValue(key, out element);
                        Node start = new Node();
                        nodes.TryGetValue(element.Topology[0], out start);
                        Node end = new Node();
                        nodes.TryGetValue(element.Topology[1], out end);
                        Line ln = new Line(
                            new Point3d(start.Position.X, start.Position.Y, start.Position.Z),
                            new Point3d(end.Position.X, end.Position.Y, end.Position.Z));
                        elemID.Add(key);
                        parentMember.Add(element.ParentMember.Member);

                        // set the result type dependent on user selection in dropdown
                        switch (_mode)
                        {
                        case (FoldMode.Displacement):
                            values           = elementResults.Displacement.ToList();
                            unitfactorxyz    = 0.001;
                            unitfactorxxyyzz = 1;
                            break;

                        case (FoldMode.Force):
                            values           = elementResults.Force.ToList();
                            unitfactorxyz    = 1000;
                            unitfactorxxyyzz = 1000;
                            break;
                        }

                        // prepare the line segments
                        int         segments       = Math.Max(1, values.Count - 1); // number of segment lines is 1 less than number of points
                        int         segment        = 0;                             // counter for segments
                        List <Line> segmentedlines = new List <Line>();

                        // loop through the results
                        foreach (Double6 result in values)
                        {
                            // update max and min values
                            if (result.X / unitfactorxyz > dmax_x)
                            {
                                dmax_x = result.X / unitfactorxyz;
                            }
                            if (result.Y / unitfactorxyz > dmax_y)
                            {
                                dmax_y = result.Y / unitfactorxyz;
                            }
                            if (result.Z / unitfactorxyz > dmax_z)
                            {
                                dmax_z = result.Z / unitfactorxyz;
                            }
                            if (Math.Sqrt(Math.Pow(result.X, 2) + Math.Pow(result.Y, 2) + Math.Pow(result.Z, 2)) / unitfactorxyz > dmax_xyz)
                            {
                                dmax_xyz = Math.Sqrt(Math.Pow(result.X, 2) + Math.Pow(result.Y, 2) + Math.Pow(result.Z, 2)) / unitfactorxyz;
                            }

                            if (result.XX / unitfactorxxyyzz > dmax_xx)
                            {
                                dmax_xx = result.XX / unitfactorxxyyzz;
                            }
                            if (result.YY / unitfactorxxyyzz > dmax_yy)
                            {
                                dmax_yy = result.YY / unitfactorxxyyzz;
                            }
                            if (result.ZZ / unitfactorxxyyzz > dmax_zz)
                            {
                                dmax_zz = result.ZZ / unitfactorxxyyzz;
                            }
                            if (Math.Sqrt(Math.Pow(result.XX, 2) + Math.Pow(result.YY, 2) + Math.Pow(result.ZZ, 2)) / unitfactorxxyyzz > dmax_xxyyzz)
                            {
                                dmax_xxyyzz = Math.Sqrt(Math.Pow(result.XX, 2) + Math.Pow(result.YY, 2) + Math.Pow(result.ZZ, 2)) / unitfactorxxyyzz;
                            }

                            if (result.X / unitfactorxyz < dmin_x)
                            {
                                dmin_x = result.X / unitfactorxyz;
                            }
                            if (result.Y / unitfactorxyz < dmin_y)
                            {
                                dmin_y = result.Y / unitfactorxyz;
                            }
                            if (result.Z / unitfactorxyz < dmin_z)
                            {
                                dmin_z = result.Z / unitfactorxyz;
                            }
                            if (Math.Sqrt(Math.Pow(result.X, 2) + Math.Pow(result.Y, 2) + Math.Pow(result.Z, 2)) / unitfactorxyz < dmin_xyz)
                            {
                                dmin_xyz = Math.Sqrt(Math.Pow(result.X, 2) + Math.Pow(result.Y, 2) + Math.Pow(result.Z, 2)) / unitfactorxyz;
                            }

                            if (result.XX / unitfactorxxyyzz < dmin_xx)
                            {
                                dmin_xx = result.XX / unitfactorxxyyzz;
                            }
                            if (result.YY / unitfactorxxyyzz < dmin_yy)
                            {
                                dmin_yy = result.YY / unitfactorxxyyzz;
                            }
                            if (result.ZZ / unitfactorxxyyzz < dmin_zz)
                            {
                                dmin_zz = result.ZZ / unitfactorxxyyzz;
                            }
                            if (Math.Sqrt(Math.Pow(result.XX, 2) + Math.Pow(result.YY, 2) + Math.Pow(result.ZZ, 2)) / unitfactorxxyyzz < dmin_xxyyzz)
                            {
                                dmin_xxyyzz = Math.Sqrt(Math.Pow(result.XX, 2) + Math.Pow(result.YY, 2) + Math.Pow(result.ZZ, 2)) / unitfactorxxyyzz;
                            }

                            // add the values to the vector lists
                            xyz.Add(new Vector3d(result.X / unitfactorxyz, result.Y / unitfactorxyz, result.Z / unitfactorxyz));
                            xxyyzz.Add(new Vector3d(result.XX / unitfactorxxyyzz, result.YY / unitfactorxxyyzz, result.ZZ / unitfactorxxyyzz));

                            // create ResultLines
                            if (segment < segments)
                            {
                                Line segmentline = new Line(
                                    ln.PointAt((double)segment / segments),
                                    ln.PointAt((double)(segment + 1) / segments)
                                    );
                                segment++;
                                segmentedlines.Add(segmentline);
                            }
                        }
                        // add the vector list to the out tree
                        xyz_out.AddRange(xyz, new GH_Path(key - 1));
                        xxyyzz_out.AddRange(xxyyzz, new GH_Path(key - 1));
                        segmentlines.AddRange(segmentedlines, new GH_Path(key - 1));
                    }
                    getresults = false;
                }
                #endregion

                #region Result line values
                // ### Coloured Result Lines ###

                // round max and min to reasonable numbers
                double dmax = 0;
                double dmin = 0;
                switch (_disp)
                {
                case (DisplayValue.X):
                    dmax = dmax_x;
                    dmin = dmin_x;
                    break;

                case (DisplayValue.Y):
                    dmax = dmax_y;
                    dmin = dmin_y;
                    break;

                case (DisplayValue.Z):
                    dmax = dmax_z;
                    dmin = dmin_z;
                    break;

                case (DisplayValue.resXYZ):
                    dmax = dmax_xyz;
                    dmin = dmin_xyz;
                    break;

                case (DisplayValue.XX):
                    dmax = dmax_xx;
                    dmin = dmin_xx;
                    break;

                case (DisplayValue.YY):
                    dmax = dmax_yy;
                    dmin = dmin_yy;
                    break;

                case (DisplayValue.ZZ):
                    dmax = dmax_zz;
                    dmin = dmin_zz;
                    break;

                case (DisplayValue.resXXYYZZ):
                    dmax = dmax_xxyyzz;
                    dmin = dmin_xxyyzz;
                    break;
                }

                List <double> rounded = Util.Gsa.ResultHelper.SmartRounder(dmax, dmin);
                dmax = rounded[0];
                dmin = rounded[1];

                // Loop through segmented lines and set result colour into ResultLine format
                DataTree <ResultLine>           lines_out = new DataTree <ResultLine>();
                DataTree <System.Drawing.Color> col_out   = new DataTree <System.Drawing.Color>();


                foreach (GH_Path path in segmentlines.Paths)
                {
                    List <ResultLine>           lns = new List <ResultLine>();
                    List <System.Drawing.Color> col = new List <System.Drawing.Color>();

                    List <Line> segmentedlines = segmentlines.Branch(path);

                    for (int j = 0; j < segmentedlines.Count; j++)
                    {
                        if (!(dmin == 0 & dmax == 0))
                        {
                            Vector3d startTranslation = new Vector3d(0, 0, 0);
                            Vector3d endTranslation   = new Vector3d(0, 0, 0);

                            double t1 = 0;
                            double t2 = 0;

                            // pick the right value to display
                            switch (_disp)
                            {
                            case (DisplayValue.X):
                                t1 = xyz_out[path, j].X;
                                t2 = xyz_out[path, j + 1].X;
                                startTranslation.X = t1 * Value / 1000;
                                endTranslation.X   = t2 * Value / 1000;
                                break;

                            case (DisplayValue.Y):
                                t1 = xyz_out[path, j].Y;
                                t2 = xyz_out[path, j + 1].Y;
                                startTranslation.Y = t1 * Value / 1000;
                                endTranslation.Y   = t2 * Value / 1000;
                                break;

                            case (DisplayValue.Z):
                                t1 = xyz_out[path, j].Z;
                                t2 = xyz_out[path, j + 1].Z;
                                startTranslation.Z = t1 * Value / 1000;
                                endTranslation.Z   = t2 * Value / 1000;
                                break;

                            case (DisplayValue.resXYZ):
                                t1 = Math.Sqrt(Math.Pow(xyz_out[path, j].X, 2) + Math.Pow(xyz_out[path, j].Y, 2) + Math.Pow(xyz_out[path, j].Z, 2));
                                t2 = Math.Sqrt(Math.Pow(xyz_out[path, j + 1].X, 2) + Math.Pow(xyz_out[path, j + 1].Y, 2) + Math.Pow(xyz_out[path, j + 1].Z, 2));
                                startTranslation.X = xyz_out[path, j].X * Value / 1000;
                                endTranslation.X   = xyz_out[path, j + 1].X * Value / 1000;
                                startTranslation.Y = xyz_out[path, j].Y * Value / 1000;
                                endTranslation.Y   = xyz_out[path, j + 1].Y * Value / 1000;
                                startTranslation.Z = xyz_out[path, j].Z * Value / 1000;
                                endTranslation.Z   = xyz_out[path, j + 1].Z * Value / 1000;
                                break;

                            case (DisplayValue.XX):
                                t1 = xxyyzz_out[path, j].X;
                                t2 = xxyyzz_out[path, j + 1].X;
                                break;

                            case (DisplayValue.YY):
                                t1 = xxyyzz_out[path, j].Y;
                                t2 = xxyyzz_out[path, j + 1].Y;
                                break;

                            case (DisplayValue.ZZ):
                                t1 = xxyyzz_out[path, j].Z;
                                t2 = xxyyzz_out[path, j + 1].Z;
                                break;

                            case (DisplayValue.resXXYYZZ):
                                t1 = Math.Sqrt(Math.Pow(xxyyzz_out[path, j].X, 2) + Math.Pow(xxyyzz_out[path, j].Y, 2) + Math.Pow(xxyyzz_out[path, j].Z, 2));
                                t2 = Math.Sqrt(Math.Pow(xxyyzz_out[path, j + 1].X, 2) + Math.Pow(xxyyzz_out[path, j + 1].Y, 2) + Math.Pow(xxyyzz_out[path, j + 1].Z, 2));
                                break;
                            }
                            Point3d start = new Point3d(segmentedlines[j].PointAt(0));
                            start.Transform(Transform.Translation(startTranslation));
                            Point3d end = new Point3d(segmentedlines[j].PointAt(1));
                            end.Transform(Transform.Translation(endTranslation));
                            Line segmentline = new Line(start, end);

                            //normalised value between -1 and 1
                            double tnorm1 = 2 * (t1 - dmin) / (dmax - dmin) - 1;
                            double tnorm2 = 2 * (t2 - dmin) / (dmax - dmin) - 1;

                            // get colour for that normalised value

                            System.Drawing.Color valcol1 = double.IsNaN(tnorm1) ? System.Drawing.Color.Black : gH_Gradient.ColourAt(tnorm1);
                            System.Drawing.Color valcol2 = double.IsNaN(tnorm2) ? System.Drawing.Color.Black : gH_Gradient.ColourAt(tnorm2);

                            // set the size of the line ends for ResultLine class. Size is calculated from 0-base, so not a normalised value between extremes
                            float size1 = (t1 >= 0 && dmax != 0) ?
                                          Math.Max(2, (float)(t1 / dmax * scale)) :
                                          Math.Max(2, (float)(Math.Abs(t1) / Math.Abs(dmin) * scale));
                            if (double.IsNaN(size1))
                            {
                                size1 = 1;
                            }
                            float size2 = (t2 >= 0 && dmax != 0) ?
                                          Math.Max(2, (float)(t2 / dmax * scale)) :
                                          Math.Max(2, (float)(Math.Abs(t2) / Math.Abs(dmin) * scale));
                            if (double.IsNaN(size2))
                            {
                                size2 = 1;
                            }

                            // add our special resultline to the list of lines
                            lns.Add(new ResultLine(segmentline, t1, t2, valcol1, valcol2, size1, size2));

                            // add the colour to the colours list
                            col.Add(valcol1);
                            if (j == segmentedlines.Count - 1)
                            {
                                col.Add(valcol2);
                            }
                        }
                    }
                    lines_out.AddRange(lns, path);
                    col_out.AddRange(col, path);
                }
                #endregion

                #region Legend
                // ### Legend ###
                // loop through number of grip points in gradient to create legend

                //Find Colour and Values for legend output
                List <double> ts = new List <double>();
                List <System.Drawing.Color> cs = new List <System.Drawing.Color>();

                for (int i = 0; i < gH_Gradient.GripCount; i++)
                {
                    double t   = dmin + (dmax - dmin) / ((double)gH_Gradient.GripCount - 1) * (double)i;
                    double scl = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(t))) + 1);
                    scl = Math.Max(scl, 1);
                    t   = scl * Math.Round(t / scl, 3);
                    ts.Add(t);

                    System.Drawing.Color gradientcolour = gH_Gradient.ColourAt(2 * (double)i / ((double)gH_Gradient.GripCount - 1) - 1);
                    cs.Add(gradientcolour);
                }
                #endregion

                // set outputs
                DA.SetDataTree(0, xyz_out);
                DA.SetDataTree(1, xxyyzz_out);
                DA.SetDataTree(2, lines_out);
                DA.SetDataTree(3, col_out);
                DA.SetDataList(4, cs);
                DA.SetDataList(5, ts);
            }
        }
예제 #5
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var respawn  = new GH_Boolean();
            var newSpawn = new GH_Integer();
            var rndSpawn = new GH_Integer();

            var avgRadius = new GH_Number();
            var bounds    = new GH_Brep();
            var snapTol   = new GH_Number();
            var snapAngle = new GH_Number();
            var surface   = new GH_Surface();
            var lineCont  = new GH_Boolean();

            if (DA.GetData(0, ref respawn) && respawn == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid respawn value. Operation canceled.");
                return;
            }

            if (DA.GetData(1, ref newSpawn) && newSpawn == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid new spawn value. Operation canceled.");
                return;
            }

            if (DA.GetData(2, ref rndSpawn) && rndSpawn == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid new spawn randomizing value. Operation canceled.");
                return;
            }

            if (DA.GetData(3, ref avgRadius) && avgRadius == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid interpolation radius value. Operation canceled.");
                return;
            }

            if (DA.GetData(4, ref bounds) && bounds == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid bounding box. Operation canceled.");
                return;
            }

            if (DA.GetData(5, ref snapTol) && snapTol == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid snap tolerance. Operation canceled.");
                return;
            }

            if (DA.GetData(6, ref snapAngle) && snapAngle == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid snapping angle. Operation canceled.");
                return;
            }

            if (DA.GetData(7, ref surface) && surface == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid surface constraint. Operation canceled.");
                return;
            }

            if (DA.GetData(8, ref lineCont) && lineCont == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid line continuity value. Operation canceled.");
                return;
            }

            DynamicSettings settings = new DynamicSettings();

            settings.respawn   = respawn.Value;
            settings.newSpawn  = newSpawn.Value;
            settings.rndSpawn  = rndSpawn.Value;
            settings.avgRadius = avgRadius.Value;
            settings.bounds    = bounds;
            settings.snapTol   = snapTol.Value;
            settings.snapAngle = snapAngle.Value;
            settings.surface   = surface;
            settings.lineCont  = lineCont.Value;

            var output = new GH_ObjectWrapper(settings);

            DA.SetData(0, output);
        }
예제 #6
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool update = false;

            GH_String ghstr = new GH_String();

            if (DA.GetData(0, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.Force = unit;
                    update      = true;
                }
            }

            ghstr = new GH_String();
            if (DA.GetData(1, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.LengthLarge = unit;
                    update            = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(2, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.LengthSmall = unit;
                    update            = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(3, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.LengthSection = unit;
                    update = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(4, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.Mass = unit;
                    update     = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(5, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.Temperature = unit;
                    update            = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(6, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.Stress = unit;
                    update       = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(7, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.Strain = unit;
                    update       = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(8, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.Velocity = unit;
                    update         = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(9, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.Acceleration = unit;
                    update             = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(10, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.Energy = unit;
                    update       = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(11, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.Angle = unit;
                    update      = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(12, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.TimeShort = unit;
                    update          = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(13, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.TimeMedium = unit;
                    update           = true;
                }
            }
            ghstr = new GH_String();
            if (DA.GetData(14, ref ghstr))
            {
                if (GH_Convert.ToString(ghstr, out string unit, GH_Conversion.Both))
                {
                    Units.TimeLong = unit;
                    update         = true;
                }
            }
            GH_Number ghnum = new GH_Number();

            if (DA.GetData(15, ref ghnum))
            {
                if (GH_Convert.ToDouble(ghnum, out double tol, GH_Conversion.Both))
                {
                    Units.Tolerance = tol;
                    update          = true;
                }
            }
            List <string> units = new List <string>
            {
                "Force: " + Units.Force,
                "Length Large: " + Units.LengthLarge
                + ((Units.LengthLarge == Units.RhinoDocUnit) ? "" : System.Environment.NewLine + "NB: Not similar to Rhino Document units!"),
                "Length Small: " + Units.LengthSmall,
                "Length Section: " + Units.LengthSection,
                "Mass: " + Units.Mass,
                "Temperature: " + Units.Temperature,
                "Stress: " + Units.Stress,
                "Strain: " + Units.Strain,
                "Velocity: " + Units.Velocity,
                "Acceleration: " + Units.Acceleration,
                "Energy: " + Units.Energy,
                "Angle: " + Units.Angle,
                "Time - short: " + Units.TimeShort,
                "Time - medium: " + Units.TimeMedium,
                "Time - long: " + Units.TimeLong,
                "Tolerance: " + Units.Tolerance
            };

            if (update)
            {
                UpdateCanvas();
            }
            DA.SetDataList(0, units);
        }
예제 #7
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.Assembly assembly = new Types.Assembly();
            DA.GetData<Types.Assembly>("Material", ref assembly);

            GH_Number factor = new GH_Number(0);
            DA.GetData<GH_Number>("Factor", ref factor);

            DA.SetData("Result", assembly * factor.Value);
        }
예제 #8
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Surface surface = new GH_Surface();
            GH_String lvlbtm = new GH_String("");
            GH_String style = new GH_String("");
            GH_String layer = new GH_String("");
            GH_Number taperAng = new GH_Number(0);
            GH_Number height = new GH_Number();
            GH_Point stop = new GH_Point();
            GH_Point sbtm = new GH_Point();
            GH_Boolean structural = new GH_Boolean(true);

            List<Parameter> param = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>();
            DA.GetData<GH_Surface>("Surface", ref surface);

            DA.GetData<GH_String>("Layer", ref layer);
            //DA.GetData<GH_String>("Style", ref style);
            DA.GetData<GH_Number>("taperAngle", ref taperAng);
            DA.GetData<GH_Number>("height", ref height);

            Slab s = new Slab();
            s.FamilyOrStyle = style.Value;
            s.TypeOrLayer = layer.Value;
            s.levelbottom = lvlbtm.Value;
            s.structural = structural.Value;
            s.surface = new Surface();
            s.surface.outline = new List<Component>();

            foreach (Rhino.Geometry.BrepEdge be in surface.Value.Edges)
            {
                s.surface.outline.Add(be.ToNurbsCurve().ToGrevitCurve());
            }

            s.height = height.Value;
            s.parameters = param;
            //s.top = ComponentUtilities.GHPoint2Point(stop);
            //s.bottom = ComponentUtilities.GHPoint2Point(sbtm);
            s.slope = taperAng.Value;
            s.GID = this.InstanceGuid.ToString();

            //SetPreview(s.GID, surface.Value);
            DA.SetData("GrevitComponent", s);
        }
예제 #9
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)
        {
            var loadcase = new List <int>(); DA.GetDataList("load case", loadcase);

            DA.GetDataTree("nodal_displacements", out GH_Structure <GH_Number> _D); var         D = _D.Branches; var D_new = new GH_Structure <GH_Number>();
            DA.GetDataTree("reaction_force", out GH_Structure <GH_Number> _reac_f); var         reac_f = _reac_f.Branches; var reac_f_new = new GH_Structure <GH_Number>();
            DA.GetDataTree("section_force", out GH_Structure <GH_Number> _sec_f); var           sec_f = _sec_f.Branches; var sec_f_new = new GH_Structure <GH_Number>();
            DA.GetDataTree("nodal_displacements(shell)", out GH_Structure <GH_Number> _D2); var D2 = _D2.Branches; var D2_new = new GH_Structure <GH_Number>();
            DA.GetDataTree("section_force(shell)", out GH_Structure <GH_Number> _shell_f); var  shell_f = _shell_f.Branches; var shell_f_new = new GH_Structure <GH_Number>();
            DA.GetDataTree("KABE_W", out GH_Structure <GH_Number> _kabe_w); var kabe_w = _kabe_w.Branches; var kabe_w_new = new GH_Structure <GH_Number>();
            var shear_w = new List <double>(); DA.GetDataList("shear_w", shear_w); var shear_w_new = new List <double>();

            DA.GetDataTree("spring_force", out GH_Structure <GH_Number> _spring_f); var spring_f = _spring_f.Branches; var spring_f_new = new GH_Structure <GH_Number>();
            if (D2[0][0].Value != -9999)
            {
                for (int e = 0; e < D2.Count; e++)
                {
                    var d = new List <GH_Number> {
                        new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0)
                    };
                    for (int i = 0; i < loadcase.Count; i++)
                    {
                        var k = loadcase[i];
                        for (int j = 0; j < 24; j++)
                        {
                            d[j] = new GH_Number(d[j].Value + D2[e][j + 24 * (k - 1)].Value);
                        }
                    }
                    D2_new.AppendRange(d, new GH_Path(e));
                }
                DA.SetDataTree(3, D2_new);
            }
            if (shell_f[0][0].Value != -9999)
            {
                for (int e = 0; e < shell_f.Count; e++)
                {
                    var f = new List <GH_Number> {
                        new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0)
                    };
                    for (int i = 0; i < loadcase.Count; i++)
                    {
                        var k = loadcase[i];
                        for (int j = 0; j < 24; j++)
                        {
                            f[j] = new GH_Number(f[j].Value + shell_f[e][j + 24 * (k - 1)].Value);
                        }
                    }
                    shell_f_new.AppendRange(f, new GH_Path(e));
                }
                DA.SetDataTree(4, shell_f_new);
            }
            if (D[0][0].Value != -9999 && sec_f[0][0].Value != -9999)
            {
                for (int e = 0; e < D.Count; e++)
                {
                    var d = new List <GH_Number> {
                        new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0)
                    };
                    var f = new List <GH_Number> {
                        new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0)
                    };
                    for (int i = 0; i < loadcase.Count; i++)
                    {
                        var k = loadcase[i];
                        for (int j = 0; j < 12; j++)
                        {
                            d[j] = new GH_Number(d[j].Value + D[e][j + 12 * (k - 1)].Value);
                        }
                        for (int j = 0; j < 18; j++)
                        {
                            f[j] = new GH_Number(f[j].Value + sec_f[e][j + 18 * (k - 1)].Value);
                        }
                    }
                    D_new.AppendRange(d, new GH_Path(e)); sec_f_new.AppendRange(f, new GH_Path(e));
                }
                DA.SetDataTree(0, D_new); DA.SetDataTree(2, sec_f_new);
            }
            if (reac_f[0][0].Value != -9999)
            {
                for (int e = 0; e < reac_f.Count; e++)
                {
                    var f = new List <GH_Number> {
                        new GH_Number(reac_f[e][0].Value), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0)
                    };
                    for (int i = 0; i < loadcase.Count; i++)
                    {
                        var k = loadcase[i];
                        for (int j = 1; j < 7; j++)
                        {
                            f[j] = new GH_Number(f[j].Value + reac_f[e][j + 7 * (k - 1)].Value);
                        }
                    }
                    reac_f_new.AppendRange(f, new GH_Path(e));
                }
                DA.SetDataTree(1, reac_f_new);
            }
            if (kabe_w[0][0].Value != -9999 && shear_w[0] != -9999)
            {
                for (int e = 0; e < kabe_w.Count; e++)
                {
                    var kw = new List <GH_Number> {
                        new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0)
                    };
                    for (int j = 0; j < 7; j++)
                    {
                        kw[j] = new GH_Number(kabe_w[e][j].Value);
                    }
                    kabe_w_new.AppendRange(kw, new GH_Path(e));
                    var q = 0.0;
                    for (int i = 0; i < loadcase.Count; i++)
                    {
                        var k = loadcase[i];
                        q += shear_w[e + shear_w.Count / (kabe_w[0].Count / 7) * (k - 1)];
                    }
                    shear_w_new.Add(q);
                }
                DA.SetDataTree(5, kabe_w_new); DA.SetDataList(6, shear_w_new);
            }
            if (spring_f[0][0].Value != -9999)
            {
                for (int e = 0; e < spring_f.Count; e++)
                {
                    var f = new List <GH_Number> {
                        new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0), new GH_Number(0)
                    };
                    for (int i = 0; i < loadcase.Count; i++)
                    {
                        var k = loadcase[i];
                        for (int j = 0; j < 6; j++)
                        {
                            f[j] = new GH_Number(f[j].Value + spring_f[e][j + 6 * (k - 1)].Value);
                        }
                    }
                    spring_f_new.AppendRange(f, new GH_Path(e));
                }
                DA.SetDataTree(7, spring_f_new);
            }
        }
        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);
            }
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaMember1d gsaMember1d = new GsaMember1d();

            if (DA.GetData(0, ref gsaMember1d))
            {
                GsaMember1d mem = gsaMember1d.Duplicate();

                // #### inputs ####

                // 1 curve
                GH_Curve ghcrv = new GH_Curve();
                if (DA.GetData(1, ref ghcrv))
                {
                    Curve crv = null;
                    if (GH_Convert.ToCurve(ghcrv, ref crv, GH_Conversion.Both))
                    {
                        GsaMember1d tmpmem = new GsaMember1d(crv)
                        {
                            ID           = mem.ID,
                            Member       = mem.Member,
                            ReleaseEnd   = mem.ReleaseEnd,
                            ReleaseStart = mem.ReleaseStart
                        };
                        mem = tmpmem;
                    }
                }

                // 2 section
                GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                if (DA.GetData(2, ref gh_typ))
                {
                    GsaSection section = new GsaSection();
                    if (gh_typ.Value is GsaSection)
                    {
                        gh_typ.CastTo(ref section);
                    }
                    else if (gh_typ.Value is GH_Number)
                    {
                        if (GH_Convert.ToInt32((GH_Number)gh_typ.Value, out int idd, GH_Conversion.Both))
                        {
                            section.ID = idd;
                        }
                    }
                    mem.Section = section;
                }


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

                // 4 element type
                GH_Integer ghinteg = new GH_Integer();
                if (DA.GetData(4, ref ghinteg))
                {
                    if (GH_Convert.ToInt32(ghinteg, out int type, GH_Conversion.Both))
                    {
                        mem.Member.Type1D = Util.Gsa.GsaToModel.Element1dType(type);
                    }
                }

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

                // 6 start release
                GsaBool6 start = new GsaBool6();
                if (DA.GetData(6, ref start))
                {
                    mem.ReleaseStart = start;
                }

                // 7 end release
                GsaBool6 end = new GsaBool6();
                if (DA.GetData(7, ref end))
                {
                    mem.ReleaseEnd = end;
                }

                // 8 orientation angle
                GH_Number ghangle = new GH_Number();
                if (DA.GetData(8, ref ghangle))
                {
                    if (GH_Convert.ToDouble(ghangle, out double angle, GH_Conversion.Both))
                    {
                        mem.Member.OrientationAngle = angle;
                    }
                }

                // 9 orientation node
                GH_Integer ghori = new GH_Integer();
                if (DA.GetData(9, ref ghori))
                {
                    if (GH_Convert.ToInt32(ghori, out int orient, GH_Conversion.Both))
                    {
                        mem.Member.OrientationNode = orient;
                    }
                }

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

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

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

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

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

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

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

                // #### outputs ####
                DA.SetData(0, new GsaMember1dGoo(mem));
                DA.SetData(1, mem.PolyCurve);
                DA.SetData(2, mem.Section);

                DA.SetData(3, mem.Member.Type);

                DA.SetData(4, mem.Member.Type1D);

                GsaOffset gsaOffset = new GsaOffset
                {
                    X1 = mem.Member.Offset.X1,
                    X2 = mem.Member.Offset.X2,
                    Y  = mem.Member.Offset.Y,
                    Z  = mem.Member.Offset.Z
                };
                DA.SetData(5, gsaOffset);

                DA.SetData(6, mem.ReleaseStart);
                DA.SetData(7, mem.ReleaseEnd);

                DA.SetData(8, mem.Member.OrientationAngle);
                DA.SetData(9, mem.Member.OrientationNode);

                DA.SetData(10, mem.Member.MeshSize);
                //DA.SetData(11, mem.member.MeshSize); //mesh with others bool

                DA.SetData(12, mem.ID);
                DA.SetData(13, mem.Member.Name);
                DA.SetData(14, mem.Member.Group);
                DA.SetData(15, mem.Member.Colour);

                DA.SetData(16, mem.Member.IsDummy);
            }
        }
예제 #12
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Plane pln = Plane.WorldXY;

            // 0 Plane
            GH_Plane gh_pln = new GH_Plane();

            if (DA.GetData(0, ref gh_pln))
            {
                GH_Convert.ToPlane(gh_pln, ref pln, GH_Conversion.Both);
            }

            // create gsa gridplanesurface from plane
            GsaGridPlaneSurface gps = new GsaGridPlaneSurface(pln);

            // 1 Grid plane ID
            GH_Integer ghint = new GH_Integer();

            if (DA.GetData(1, ref ghint))
            {
                int id = 0;
                GH_Convert.ToInt32(ghint, out id, GH_Conversion.Both);
                gps.GridPlaneID = id;
            }

            // 2 Grid elevation
            GH_Number ghnum = new GH_Number();

            if (DA.GetData(2, ref ghnum))
            {
                double elev = 0;
                if (GH_Convert.ToDouble(ghnum, out elev, GH_Conversion.Both))
                {
                    gps.GridPlane.Elevation = elev;

                    // if elevation is set we want to move the plane in it's normal direction
                    Vector3d vec = pln.Normal;
                    vec.Unitize();
                    vec.X *= elev;
                    vec.Y *= elev;
                    vec.Z *= elev;
                    Transform xform = Transform.Translation(vec);
                    pln.Transform(xform);
                    gps.Plane = pln;
                    // note this wont move the Grid Plane Axis gps.Axis
                }
            }

            // 3 Name
            GH_String ghtxt = new GH_String();

            if (DA.GetData(3, ref ghtxt))
            {
                string name = "";
                if (GH_Convert.ToString(ghtxt, out name, GH_Conversion.Both))
                {
                    gps.GridPlane.Name = name;
                }
            }

            // set is story
            if (_mode == FoldMode.General)
            {
                gps.GridPlane.IsStoreyType = false;
            }
            else
            {
                gps.GridPlane.IsStoreyType = true;

                // 4 tolerance above
                GH_Number ghtola = new GH_Number();
                if (DA.GetData(4, ref ghtola))
                {
                    double tola = 0;
                    if (GH_Convert.ToDouble(ghtola, out tola, GH_Conversion.Both))
                    {
                        gps.GridPlane.ToleranceAbove = tola;
                    }
                }

                // 5 tolerance above
                GH_Number ghtolb = new GH_Number();
                if (DA.GetData(5, ref ghtolb))
                {
                    double tolb = 0;
                    if (GH_Convert.ToDouble(ghtolb, out tolb, GH_Conversion.Both))
                    {
                        gps.GridPlane.ToleranceBelow = tolb;
                    }
                }
            }

            DA.SetData(0, new GsaGridPlaneSurfaceGoo(gps));
        }
예제 #13
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var steps      = new GH_Integer();
            var tolerance  = new GH_Number();
            var stop       = new GH_Boolean();
            var windAngle  = new GH_Number();
            var avgRadius  = new GH_Number();
            var bounds     = new GH_Brep();
            var snapTol    = new GH_Number();
            var snapAngle  = new GH_Number();
            var surface    = new GH_Surface();
            var tensor     = new GH_Boolean();
            var tensorDir  = new GH_Integer();
            var tensorAxes = new List <GH_Integer>();
            var lineCont   = new GH_Boolean();

            if (DA.GetData(0, ref steps) && steps == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid step count. Operation canceled.");
                return;
            }

            if (DA.GetData(1, ref tolerance) && tolerance == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid tolerance. Operation canceled.");
                return;
            }

            if (DA.GetData(2, ref stop) && stop == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid stop value. Operation canceled.");
                return;
            }

            if (DA.GetData(3, ref windAngle) && windAngle == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid tolerance. Operation canceled.");
                return;
            }

            if (DA.GetData(4, ref avgRadius) && avgRadius == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid interpolation radius value. Operation canceled.");
                return;
            }

            if (DA.GetData(5, ref bounds) && bounds == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid bounding box. Operation canceled.");
                return;
            }

            if (DA.GetData(6, ref snapTol) && snapTol == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid snap tolerance. Operation canceled.");
                return;
            }

            if (DA.GetData(7, ref snapAngle) && snapAngle == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid snapping angle. Operation canceled.");
                return;
            }

            if (DA.GetData(8, ref surface) && surface == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid surface constraint. Operation canceled.");
                return;
            }

            if (DA.GetData(9, ref tensor) && tensor == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid tensor input. Operation canceled.");
                return;
            }

            if (DA.GetData(10, ref tensorDir) && tensorDir == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid tensor direction. Operation canceled.");
                return;
            }

            if (tensorDir.Value < 0 || tensorDir.Value > 2)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid tensor direction. Valid input is 0-2. Operation canceled.");
                return;
            }

            if (DA.GetDataList(11, tensorAxes) && tensorAxes == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid tensor direction. Operation canceled.");
                return;
            }

            if (DA.GetData(12, ref lineCont) && lineCont == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid line continuity value. Operation canceled.");
                return;
            }

            StaticSettings settings = new StaticSettings();

            settings.steps     = steps.Value;
            settings.stop      = stop.Value;
            settings.windAngle = windAngle.Value;
            settings.tolerance = tolerance.Value;
            settings.avgRadius = avgRadius.Value;
            settings.bounds    = bounds;
            settings.snapTol   = snapTol.Value;
            settings.snapAngle = snapAngle.Value;
            settings.surface   = surface;
            settings.tensor    = tensor.Value;
            settings.tensorDir = tensorDir.Value;
            settings.lineCont  = lineCont.Value;

            if (tensorAxes.Count == 0)
            {
                settings.tensorAxes.Add(0);
                settings.tensorAxes.Add(1);
            }
            else
            {
                foreach (var axis in tensorAxes)
                {
                    settings.tensorAxes.Add(axis.Value);
                }
            }

            if (settings.tensor == false)
            {
                settings.tensorDir = -1;
            }

            var output = new GH_ObjectWrapper(settings);

            DA.SetData(0, output);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaProp2d prop = new GsaProp2d();

            // element type (picked in dropdown)
            prop.Prop2d.Type = Property2D_Type.UNDEF;
            if (_mode == FoldMode.PlaneStress)
            {
                prop.Prop2d.Type = Property2D_Type.PL_STRESS;
            }
            if (_mode == FoldMode.Fabric)
            {
                prop.Prop2d.Type = Property2D_Type.FABRIC;
            }
            if (_mode == FoldMode.FlatPlate)
            {
                prop.Prop2d.Type = Property2D_Type.PLATE;
            }
            if (_mode == FoldMode.Shell)
            {
                prop.Prop2d.Type = Property2D_Type.SHELL;
            }
            if (_mode == FoldMode.CurvedShell)
            {
                prop.Prop2d.Type = Property2D_Type.CURVED_SHELL;
            }
            if (_mode == FoldMode.LoadPanel)
            {
                prop.Prop2d.Type = Property2D_Type.LOAD;
            }

            //id
            GH_Integer gh_ID = new GH_Integer();

            DA.GetData(0, ref gh_ID);
            int idd = 0;

            GH_Convert.ToInt32_Primary(gh_ID, ref idd);
            prop.ID = idd;

            //name
            GH_String gh_Name = new GH_String();

            DA.GetData(1, ref gh_Name);
            string name = "";

            GH_Convert.ToString_Primary(gh_Name, ref name);
            prop.Prop2d.Name = name;

            //colour
            GH_Colour gh_Colour = new GH_Colour();

            DA.GetData(2, ref gh_Colour);
            System.Drawing.Color colour = new System.Drawing.Color();
            GH_Convert.ToColor_Primary(gh_Colour, ref colour);
            prop.Prop2d.Colour = (ValueType)colour;

            if (_mode != FoldMode.LoadPanel)
            {
                //axis
                GH_Integer gh_Axis = new GH_Integer();
                DA.GetData(3, ref gh_Axis);
                int axis = 0;
                GH_Convert.ToInt32_Primary(gh_Axis, ref axis);
                prop.Prop2d.AxisProperty = axis;


                if (_mode != FoldMode.Fabric)
                {
                    //Material type
                    GH_ObjectWrapper gh_typ  = new GH_ObjectWrapper();
                    MaterialType     matType = MaterialType.CONCRETE;
                    if (DA.GetData(4, ref gh_typ))
                    {
                        if (gh_typ.Value is MaterialType)
                        {
                            gh_typ.CastTo(ref matType);
                        }
                        if (gh_typ.Value is GH_String)
                        {
                            string typ = "CONCRETE";
                            GH_Convert.ToString_Primary(gh_typ, ref typ);
                            if (typ.ToUpper() == "STEEL")
                            {
                                matType = MaterialType.STEEL;
                            }
                            if (typ.ToUpper() == "CONCRETE")
                            {
                                matType = MaterialType.CONCRETE;
                            }
                            if (typ.ToUpper() == "FRP")
                            {
                                matType = MaterialType.FRP;
                            }
                            if (typ.ToUpper() == "ALUMINIUM")
                            {
                                matType = MaterialType.ALUMINIUM;
                            }
                            if (typ.ToUpper() == "TIMBER")
                            {
                                matType = MaterialType.TIMBER;
                            }
                            if (typ.ToUpper() == "GLASS")
                            {
                                matType = MaterialType.GLASS;
                            }
                            if (typ.ToUpper() == "FABRIC")
                            {
                                matType = MaterialType.FABRIC;
                            }
                            if (typ.ToUpper() == "GENERIC")
                            {
                                matType = MaterialType.GENERIC;
                            }
                        }
                    }
                    prop.Prop2d.MaterialType = matType;

                    //thickness
                    GH_Number gh_THK = new GH_Number();

                    double thickness = 0.2;
                    if (DA.GetData(7, ref gh_THK))
                    {
                        GH_Convert.ToDouble_Primary(gh_THK, ref thickness);
                    }
                    //prop.Prop2d.Thickness = thickness;
                }
                else
                {
                    prop.Prop2d.MaterialType = MaterialType.FABRIC;
                }

                //handle that the last two inputs are at different -1 index for fabric mode
                int fab = 0;
                if (_mode == FoldMode.Fabric)
                {
                    fab = 1;
                }

                //grade
                GH_Integer gh_grd = new GH_Integer();
                DA.GetData(5 - fab, ref gh_grd);
                int grade = 1;
                GH_Convert.ToInt32_Primary(gh_grd, ref grade);
                prop.Prop2d.MaterialGradeProperty = grade;

                //analysis
                GH_Integer gh_anal = new GH_Integer();
                DA.GetData(6 - fab, ref gh_anal);
                int analysis = 1;
                GH_Convert.ToInt32_Primary(gh_anal, ref analysis);
                prop.Prop2d.MaterialAnalysisProperty = analysis;
            }

            DA.SetData(0, new GsaProp2dGoo(prop));
        }
예제 #15
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var pl = new List <GH_Plane>();
            var h  = new GH_Number();
            var k  = new GH_Number();
            var a  = new GH_Number();
            var e  = new GH_Boolean();
            var f  = new GH_Boolean();
            var r  = new GH_Boolean();

            if (DA.GetDataList(0, pl) && pl == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid pl value. Operation canceled.");
                return;
            }

            if (pl.Count == 0)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Singularity point list must not be empty. Operation canceled.");
                return;
            }

            if (DA.GetData(1, ref h) && h == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid h value. Operation canceled.");
                return;
            }

            if (DA.GetData(2, ref k) && k == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid k value. Operation canceled.");
                return;
            }

            if (DA.GetData(3, ref a) && a == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid a value. Operation canceled.");
                return;
            }

            if (DA.GetData(4, ref e) && e == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid e value. Operation canceled.");
                return;
            }

            if (DA.GetData(5, ref f) && f == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid funnel value. Operation canceled.");
                return;
            }

            if (DA.GetData(6, ref r) && r == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid reverse value. Operation canceled.");
                return;
            }

            var dynamic = new VortexDynamic();

            dynamic.Param["Pl"] = pl;
            dynamic.Param["h"]  = h.Value;
            dynamic.Param["k"]  = k.Value;
            dynamic.Param["a"]  = a.Value;
            dynamic.Param["e"]  = e.Value;
            dynamic.Param["F"]  = f.Value;
            dynamic.Param["r"]  = r.Value;

            DA.SetData(0, new GH_ObjectWrapper(dynamic));
        }
        private string ConstructMaterial(GH_Colour inColor, GH_Number inNumber)
        {
            //json object to populate
            dynamic jason = new ExpandoObject();

            //JSON properties
            jason.uuid = Guid.NewGuid();
            jason.type = "LineBasicMaterial";
            jason.color = _Utilities.hexColor(inColor);
            jason.linewidth = inNumber.Value;
            jason.opacity = 1;

            return JsonConvert.SerializeObject(jason);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // 0 Plane
            Plane pln = Plane.Unset;
            GsaGridPlaneSurface gps;
            bool idSet = false;

            GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();

            if (DA.GetData(0, ref gh_typ))
            {
                if (gh_typ.Value is GsaGridPlaneSurfaceGoo)
                {
                    GsaGridPlaneSurface temppln = new GsaGridPlaneSurface();
                    gh_typ.CastTo(ref temppln);
                    gps = temppln.Duplicate();
                }
                else
                {
                    if (gh_typ.CastTo(ref pln))
                    {
                        gps = new GsaGridPlaneSurface(pln);
                    }
                    else
                    {
                        int id = 0;
                        if (GH_Convert.ToInt32(gh_typ.Value, out id, GH_Conversion.Both))
                        {
                            gps = new GsaGridPlaneSurface();
                            gps.GridSurface.GridPlane = id;
                            gps.GridPlane             = null;
                            idSet = true;
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Cannot convert your input to GridPlaneSurface or Plane");
                            return;
                        }
                    }
                }
            }
            else
            {
                pln = Plane.WorldXY;
                gps = new GsaGridPlaneSurface(pln);
            }

            // record if changes has been made from default type
            bool        changeGS = false;
            GridSurface gs       = new GridSurface(); // new GridSurface to make changes to, set it back to GPS in the end

            if (idSet)
            {
                gs.GridPlane = gps.GridSurface.GridPlane;
            }

            // 1 ID
            GH_Integer ghint = new GH_Integer();

            if (DA.GetData(1, ref ghint))
            {
                int id = 0;
                GH_Convert.ToInt32(ghint, out id, GH_Conversion.Both);
                gps.GridSurfaceID = id;
            }

            // 2 Elements
            GH_String ghelem = new GH_String();

            if (DA.GetData(2, ref ghelem))
            {
                string elem = "";
                if (GH_Convert.ToString(ghelem, out elem, GH_Conversion.Both))
                {
                    gs.Elements = elem;
                    changeGS    = true;
                }
            }

            // 3 Name
            GH_String ghtxt = new GH_String();

            if (DA.GetData(3, ref ghtxt))
            {
                string name = "";
                if (GH_Convert.ToString(ghtxt, out name, GH_Conversion.Both))
                {
                    gs.Name  = name;
                    changeGS = true;
                }
            }

            // 4 Tolerance
            GH_Number ghtol = new GH_Number();

            if (DA.GetData(4, ref ghtol))
            {
                double tol = 10;
                if (GH_Convert.ToDouble(ghtol, out tol, GH_Conversion.Both))
                {
                    gs.Tolerance = tol;
                    changeGS     = true;
                }
            }

            switch (_mode)
            {
            case FoldMode.One_Dimensional_One_Way:
                gs.ElementType = GridSurface.Element_Type.ONE_DIMENSIONAL;
                gs.SpanType    = GridSurface.Span_Type.ONE_WAY;

                // 5 span direction
                GH_Number ghdir = new GH_Number();
                if (DA.GetData(5, ref ghdir))
                {
                    double dir = 0;
                    if (GH_Convert.ToDouble(ghdir, out dir, GH_Conversion.Both))
                    {
                        if (dir > 180 || dir < -180)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Angle value must be between -180 and 180 degrees");     // to be updated when GsaAPI support units
                        }
                        gs.Direction = dir;
                        if (dir != 0)
                        {
                            changeGS = true;
                        }
                    }
                }
                break;

            case FoldMode.One_Dimensional_Two_Way:
                changeGS       = true;
                gs.ElementType = GridSurface.Element_Type.ONE_DIMENSIONAL;

                // 5 expansion method
                int        exp   = 0;
                GH_Integer ghexp = new GH_Integer();
                if (DA.GetData(5, ref ghexp))
                {
                    GH_Convert.ToInt32_Primary(ghexp, ref exp);
                }
                gs.ExpansionType = GridSurfaceExpansionType.PLANE_CORNER;
                if (exp == 1)
                {
                    gs.ExpansionType = GridSurfaceExpansionType.PLANE_SMOOTH;
                }
                if (exp == 2)
                {
                    gs.ExpansionType = GridSurfaceExpansionType.PLANE_ASPECT;
                }
                if (exp == 3)
                {
                    gs.ExpansionType = GridSurfaceExpansionType.LEGACY;
                }

                // 6 simplify tributary area
                bool       simple = true;
                GH_Boolean ghsim  = new GH_Boolean();
                if (DA.GetData(6, ref ghsim))
                {
                    GH_Convert.ToBoolean(ghsim, out simple, GH_Conversion.Both);
                }
                if (simple)
                {
                    gs.SpanType = GridSurface.Span_Type.TWO_WAY_SIMPLIFIED_TRIBUTARY_AREAS;
                }
                else
                {
                    gs.SpanType = GridSurface.Span_Type.TWO_WAY;
                }
                break;

            case FoldMode.Two_Dimensional:
                changeGS       = true;
                gs.ElementType = GridSurface.Element_Type.TWO_DIMENSIONAL;
                break;
            }
            if (changeGS)
            {
                gps.GridSurface = gs;
            }

            DA.SetData(0, new GsaGridPlaneSurfaceGoo(gps));
        }
예제 #18
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String name = new GH_String();
            GH_Number elevation = new GH_Number();
            GH_Boolean view = new GH_Boolean();

            DA.GetData<GH_String>("Name", ref name);
            DA.GetData<GH_Boolean>("View", ref view);
            DA.GetData<GH_Number>("Elevation", ref elevation);

            Level level = new Level(name.Value, elevation.Value, view.Value);
            level.GID = this.InstanceGuid.ToString();
            DA.SetData("GrevitComponent", level);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            int iterations = 0;
            var algorithm  = new Boa_Algorithm();
            var inputs     = new double[0];

            if (!GetInputs(DA, ref inputs))
            {
                return;
            }
            if (!DA.GetData(2, ref iterations))
            {
                return;
            }
            GetAlgorithm(DA, ref algorithm);

            if (iterations < 1)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Number of iterations must be greater than or equal to one.");
                return;
            }

            GH_Structure <GH_Number> outputDataTree = new GH_Structure <GH_Number>();
            GH_Path targetPath = DA.ParameterTargetPath(0);

            //Feedback loop
            for (int i = 0; i < iterations; i++)
            {
                double[] originalInputs = new double[inputs.Length];
                inputs.CopyTo(originalInputs, 0);

                // on the first iteration
                if (i == 0)
                {
                    if (!SolveAlgorithm(ref inputs, algorithm))
                    {
                        return;
                    }
                }
                else
                {
                    if (!SolveAlgorithm(ref inputs, algorithm, "Number of outputs is less than number of inputs. Algorithm cannot support a feedback loop."))
                    {
                        return;
                    }
                }

                GH_Number[] outputList = new GH_Number[inputs.Length];

                for (int j = 0; j < inputs.Length; j++)
                {
                    //inputs[j] = (inputs[j] * factor) + originalInputs[j];
                    inputs[j]     = inputs[j] + originalInputs[j];
                    outputList[j] = new GH_Number(inputs[j]);
                }

                outputDataTree.AppendRange(outputList, targetPath.AppendElement(i));
            }

            DA.SetDataTree(0, outputDataTree);
        }
예제 #20
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var samplePoints  = new List <Vector>();
            var sampleVectors = new List <Vector>();
            var testPoints    = new List <Vector>();
            var radius        = new GH_Number();
            var p             = new GH_Number();

            var pdt  = new GH_Structure <GH_Number>();
            var vdt  = new GH_Structure <GH_Number>();
            var tpdt = new GH_Structure <GH_Number>();

            // gather and validate inputs
            if (DA.GetDataTree(0, out pdt) && pdt == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid sample point tree. Operation canceled.");
                return;
            }

            // gather and validate inputs
            if (DA.GetDataTree(1, out vdt) && vdt == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid vector tree. Operation canceled.");
                return;
            }

            if (pdt.Branches.Count != vdt.Branches.Count)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Point and Vector trees must be parallel (same count). Operation canceled.");
                return;
            }

            // gather and validate inputs
            if (DA.GetDataTree(2, out tpdt) && tpdt == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid test point tree. Operation canceled.");
                return;
            }

            // gather and validate inputs
            if (DA.GetData(3, ref radius) && radius == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid radius value. Operation canceled.");
                return;
            }

            // gather and validate inputs
            if (DA.GetData(4, ref p) && p == null)
            {
                this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid strength value. Operation canceled.");
                return;
            }

            // collect input Vectors
            samplePoints  = GetVectorsFromTree(pdt);
            sampleVectors = GetVectorsFromTree(vdt);
            testPoints    = GetVectorsFromTree(tpdt);

            // if r is 0 calculate a sane default
            double r = radius.Value;

            if (r == 0.0d)
            {
                r = GetDefaultRadius(samplePoints);
            }

            // get interpolated vectors
            var interpolated = new List <Vector>();

            foreach (var tp in testPoints)
            {
                var withinRadius = GetAllSampleIndicesWithinRadius(tp, samplePoints, r).ToList();
                interpolated.Add(GetInterpolatedVector(tp, samplePoints, sampleVectors, withinRadius, r, p.Value));
            }

            // set interpolated vectors as output
            var outputTree = new GH_Structure <GH_Number>();

            for (int i = 0; i < interpolated.Count; i++)
            {
                var v      = interpolated[i];
                var points = new List <GH_Number>();

                for (int j = 0; j < v.Rank; j++)
                {
                    points.Add(new GH_Number(v[j]));
                }

                outputTree.AppendRange(points, new GH_Path(i));
            }

            DA.SetDataTree(0, outputTree);
        }
예제 #21
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.Assembly assembly = new Types.Assembly();
            DA.GetData<Types.Assembly>("Material", ref assembly);

            GH_Point point = new GH_Point();
            GH_Integer piles = new GH_Integer(1);
            GH_Number radius = new GH_Number(0);
            GH_Number plateThickness = new GH_Number(0);
            GH_Number plateLength = new GH_Number(0);
            GH_Number plateWidth = new GH_Number(0);
            GH_Number pileLength = new GH_Number(0);

            DA.GetData<GH_Point>("Point", ref point);
            DA.GetData<GH_Number>("Pile Radius", ref radius);
            DA.GetData<GH_Integer>("Piles", ref piles);
            DA.GetData<GH_Number>("Plate Thickness", ref plateThickness);
            DA.GetData<GH_Number>("Plate Length", ref plateLength);
            DA.GetData<GH_Number>("Plate Width", ref plateWidth);
            DA.GetData<GH_Number>("Pile Length", ref pileLength);

            drawExtrusion(point.Value, plateLength.Value, plateWidth.Value, plateThickness.Value);
            Rhino.Geometry.Circle circle = new Rhino.Geometry.Circle(point.Value, (plateWidth.Value / 2) * 0.8);

            double numberOfPiles = piles.Value;

            for (int i = 1; i <= piles.Value; i++)
            {
                double iteration = i;
                double factor = 2.0 * Math.PI * (iteration / numberOfPiles);
                Rhino.Geometry.Point3d center = (piles.Value == 1)? point.Value : circle.ToNurbsCurve().PointAt(factor);
                drawColumn(center, pileLength.Value, radius.Value);
            }

            double calculationVolume = (piles.Value * pileLength.Value * radius.Value) + (plateThickness.Value * plateLength.Value * plateWidth.Value);

            Types.Result result = new Types.Result()
            {
                GlobalWarmingPotential = new Types.UnitDouble<Types.LCA.CO2e>(assembly.GlobalWarmingPotential.Value * calculationVolume),
                Acidification = new Types.UnitDouble<Types.LCA.kgSO2>(assembly.Acidification.Value * calculationVolume),
                DepletionOfNonrenewbles = new Types.UnitDouble<Types.LCA.MJ>(assembly.DepletionOfNonrenewbles.Value * calculationVolume),
                DepletionOfOzoneLayer = new Types.UnitDouble<Types.LCA.kgCFC11>(assembly.DepletionOfOzoneLayer.Value * calculationVolume),
                Eutrophication = new Types.UnitDouble<Types.LCA.kgPhostphate>(assembly.Eutrophication.Value * calculationVolume),
                FormationTroposphericOzone = new Types.UnitDouble<Types.LCA.kgNOx>(assembly.FormationTroposphericOzone.Value * calculationVolume)
            };

            DA.SetData("LCA Result", result);
        }
        public void SetInputs(List <DataTree <ResthopperObject> > values)
        {
            foreach (var tree in values)
            {
                if (!_input.TryGetValue(tree.ParamName, out var inputGroup))
                {
                    continue;
                }

                if (inputGroup.AlreadySet(tree))
                {
                    Console.WriteLine("Skipping input tree... same input");
                    continue;
                }

                inputGroup.CacheTree(tree);
                inputGroup.Param.VolatileData.Clear();
                inputGroup.Param.ExpireSolution(true);

                if (inputGroup.Param is Param_Point)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject       restobj = entree.Value[i];
                            Rhino.Geometry.Point3d rPt     = JsonConvert.DeserializeObject <Rhino.Geometry.Point3d>(restobj.Data);
                            GH_Point data = new GH_Point(rPt);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Vector)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject        restobj  = entree.Value[i];
                            Rhino.Geometry.Vector3d rhVector = JsonConvert.DeserializeObject <Rhino.Geometry.Vector3d>(restobj.Data);
                            GH_Vector data = new GH_Vector(rhVector);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Integer)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            int        rhinoInt      = JsonConvert.DeserializeObject <int>(restobj.Data);
                            GH_Integer data          = new GH_Integer(rhinoInt);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Number)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                            GH_Number        data     = new GH_Number(rhNumber);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_String)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            string           rhString = restobj.Data;
                            GH_String        data     = new GH_String(rhString);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Line)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Line rhLine  = JsonConvert.DeserializeObject <Rhino.Geometry.Line>(restobj.Data);
                            GH_Line             data    = new GH_Line(rhLine);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Curve)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            GH_Curve         ghCurve;
                            try
                            {
                                Rhino.Geometry.Polyline data = JsonConvert.DeserializeObject <Rhino.Geometry.Polyline>(restobj.Data);
                                Rhino.Geometry.Curve    c    = new Rhino.Geometry.PolylineCurve(data);
                                ghCurve = new GH_Curve(c);
                            }
                            catch
                            {
                                var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(restobj.Data);
                                var c    = (Rhino.Geometry.Curve)Rhino.Runtime.CommonObject.FromJSON(dict);
                                ghCurve = new GH_Curve(c);
                            }
                            inputGroup.Param.AddVolatileData(path, i, ghCurve);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Circle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject      restobj  = entree.Value[i];
                            Rhino.Geometry.Circle rhCircle = JsonConvert.DeserializeObject <Rhino.Geometry.Circle>(restobj.Data);
                            GH_Circle             data     = new GH_Circle(rhCircle);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Plane)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject     restobj = entree.Value[i];
                            Rhino.Geometry.Plane rhPlane = JsonConvert.DeserializeObject <Rhino.Geometry.Plane>(restobj.Data);
                            GH_Plane             data    = new GH_Plane(rhPlane);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Rectangle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject           restobj     = entree.Value[i];
                            Rhino.Geometry.Rectangle3d rhRectangle = JsonConvert.DeserializeObject <Rhino.Geometry.Rectangle3d>(restobj.Data);
                            GH_Rectangle data = new GH_Rectangle(rhRectangle);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Box)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject   restobj = entree.Value[i];
                            Rhino.Geometry.Box rhBox   = JsonConvert.DeserializeObject <Rhino.Geometry.Box>(restobj.Data);
                            GH_Box             data    = new GH_Box(rhBox);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Surface)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject       restobj   = entree.Value[i];
                            Rhino.Geometry.Surface rhSurface = JsonConvert.DeserializeObject <Rhino.Geometry.Surface>(restobj.Data);
                            GH_Surface             data      = new GH_Surface(rhSurface);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Brep)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Brep rhBrep  = JsonConvert.DeserializeObject <Rhino.Geometry.Brep>(restobj.Data);
                            GH_Brep             data    = new GH_Brep(rhBrep);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Mesh)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject    restobj = entree.Value[i];
                            Rhino.Geometry.Mesh rhMesh  = JsonConvert.DeserializeObject <Rhino.Geometry.Mesh>(restobj.Data);
                            GH_Mesh             data    = new GH_Mesh(rhMesh);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is GH_NumberSlider)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            double           rhNumber = JsonConvert.DeserializeObject <double>(restobj.Data);
                            GH_Number        data     = new GH_Number(rhNumber);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is Param_Boolean || inputGroup.Param is GH_BooleanToggle)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj = entree.Value[i];
                            bool             boolean = JsonConvert.DeserializeObject <bool>(restobj.Data);
                            GH_Boolean       data    = new GH_Boolean(boolean);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }

                if (inputGroup.Param is GH_Panel)
                {
                    foreach (KeyValuePair <string, List <ResthopperObject> > entree in tree)
                    {
                        GH_Path path = new GH_Path(GhPath.FromString(entree.Key));
                        for (int i = 0; i < entree.Value.Count; i++)
                        {
                            ResthopperObject restobj  = entree.Value[i];
                            string           rhString = JsonConvert.DeserializeObject <string>(restobj.Data);
                            GH_String        data     = new GH_String(rhString);
                            inputGroup.Param.AddVolatileData(path, i, data);
                        }
                    }
                    continue;
                }
            }
        }
예제 #23
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.Assembly assembly = new Types.Assembly();
            DA.GetData<Types.Assembly>("Material", ref assembly);

            GH_Curve curve = new GH_Curve();
            GH_Number radius = new GH_Number(0);
            GH_Number height = new GH_Number(0);
            GH_Number width = new GH_Number(0);
            Types.Profile profile = null;

            if (!DA.GetData<GH_Number>("Radius", ref radius)) radius.Value = 0;
            if (!DA.GetData<GH_Number>("Height", ref height)) height.Value = 0;
            if (!DA.GetData<GH_Number>("Width", ref width)) width.Value = 0;
            if (!DA.GetData<Types.Profile>("Profile", ref profile)) profile = null;
            DA.GetData<GH_Curve>("Curve", ref curve);

            double calculationVolume = 0;

            if (profile != null)
            {
                calculationVolume = curve.Value.GetLength() * profile.Area;
                drawColumn(curve.Value.PointAtStart, curve.Value.PointAtEnd, profile.Area);
            }
            else
            {
                if (radius.Value > 0)
                {
                    drawColumn(curve.Value.PointAtStart, curve.Value.PointAtEnd, radius.Value);
                    calculationVolume = curve.Value.GetLength() * radius.Value * radius.Value * Math.PI;
                }
                else
                {
                    drawColumn(curve.Value.PointAtStart, curve.Value.PointAtEnd, height.Value, width.Value);
                    calculationVolume = curve.Value.GetLength() * height.Value * width.Value;
                }
            }

            Types.Result result = new Types.Result()
            {
                GlobalWarmingPotential = new Types.UnitDouble<Types.LCA.CO2e>(assembly.GlobalWarmingPotential.Value * calculationVolume),
                Acidification = new Types.UnitDouble<Types.LCA.kgSO2>(assembly.Acidification.Value * calculationVolume),
                DepletionOfNonrenewbles = new Types.UnitDouble<Types.LCA.MJ>(assembly.DepletionOfNonrenewbles.Value * calculationVolume),
                DepletionOfOzoneLayer = new Types.UnitDouble<Types.LCA.kgCFC11>(assembly.DepletionOfOzoneLayer.Value * calculationVolume),
                Eutrophication = new Types.UnitDouble<Types.LCA.kgPhostphate>(assembly.Eutrophication.Value * calculationVolume),
                FormationTroposphericOzone = new Types.UnitDouble<Types.LCA.kgNOx>(assembly.FormationTroposphericOzone.Value * calculationVolume)
            };

            DA.SetData("LCA Result", result);
        }
        /// <summary>
        /// Determines object type and calls the appropriate conversion call.
        /// </summary>
        /// <param name="o">Object to convert.</param>
        /// <param name="getEncoded">If set to true, will return a base64 encoded value of more complex objects (ie, breps).</param>
        /// <returns></returns>
        private static SpeckleObject fromGhRhObject(object o, bool getEncoded = false, bool getAbstract = true)
        {
            GH_Interval int1d = o as GH_Interval;

            if (int1d != null)
            {
                return(GhRhConveter.fromInterval(int1d.Value));
            }
            if (o is Interval)
            {
                return(GhRhConveter.fromInterval((Interval)o));
            }

            GH_Interval2D int2d = o as GH_Interval2D;

            if (int2d != null)
            {
                return(GhRhConveter.fromInterval2d(int2d.Value));
            }
            if (o is UVInterval)
            {
                return(GhRhConveter.fromInterval2d((UVInterval)o));
            }

            // basic stuff
            GH_Number num = o as GH_Number;

            if (num != null)
            {
                return(SpeckleConverter.fromNumber(num.Value));
            }
            if (o is double || o is int)
            {
                return(SpeckleConverter.fromNumber((double)o));
            }

            GH_Boolean bul = o as GH_Boolean;

            if (bul != null)
            {
                return(SpeckleConverter.fromBoolean(bul.Value));
            }
            if (o is Boolean)
            {
                return(GhRhConveter.fromBoolean((bool)o));
            }

            GH_String str = o as GH_String;

            if (str != null)
            {
                return(SpeckleConverter.fromString(str.Value));
            }
            if (o is string)
            {
                return(SpeckleConverter.fromString((string)o));
            }

            // simple geometry
            GH_Point point = o as GH_Point;

            if (point != null)
            {
                return(GhRhConveter.fromPoint(point.Value));
            }
            if (o is Point3d)
            {
                return(GhRhConveter.fromPoint((Point3d)o));
            }
            // added because when we assign user data to points they get converted to points.
            // the above comment does makes sense. check the sdk.
            if (o is Rhino.Geometry.Point)
            {
                return(GhRhConveter.fromPoint(((Rhino.Geometry.Point)o).Location));
            }

            GH_Vector vector = o as GH_Vector;

            if (vector != null)
            {
                return(GhRhConveter.fromVector(vector.Value));
            }
            if (o is Vector3d)
            {
                return(GhRhConveter.fromVector((Vector3d)o));
            }

            GH_Plane plane = o as GH_Plane;

            if (plane != null)
            {
                return(GhRhConveter.fromPlane(plane.Value));
            }
            if (o is Plane)
            {
                return(GhRhConveter.fromPlane((Plane)o));
            }

            GH_Line line = o as GH_Line;

            if (line != null)
            {
                return(GhRhConveter.fromLine(line.Value));
            }
            if (o is Line)
            {
                return(GhRhConveter.fromLine((Line)o));
            }

            GH_Arc arc = o as GH_Arc;

            if (arc != null)
            {
                return(GhRhConveter.fromArc(arc.Value));
            }
            if (o is Arc)
            {
                return(GhRhConveter.fromArc((Arc)o));
            }

            GH_Circle circle = o as GH_Circle;

            if (circle != null)
            {
                return(GhRhConveter.fromCircle(circle.Value));
            }
            if (o is Circle)
            {
                return(GhRhConveter.fromCircle((Circle)o));
            }

            GH_Rectangle rectangle = o as GH_Rectangle;

            if (rectangle != null)
            {
                return(GhRhConveter.fromRectangle(rectangle.Value));
            }
            if (o is Rectangle3d)
            {
                return(GhRhConveter.fromRectangle((Rectangle3d)o));
            }

            GH_Box box = o as GH_Box;

            if (box != null)
            {
                return(GhRhConveter.fromBox(box.Value));
            }
            if (o is Box)
            {
                return(GhRhConveter.fromBox((Box)o));
            }

            // getting complex
            GH_Curve curve = o as GH_Curve;

            if (curve != null)
            {
                Polyline poly;
                if (curve.Value.TryGetPolyline(out poly))
                {
                    return(GhRhConveter.fromPolyline(poly));
                }
                return(GhRhConveter.fromCurve(curve.Value, getEncoded, getAbstract));
            }

            if (o is Polyline)
            {
                return(GhRhConveter.fromPolyline((Polyline)o));
            }
            if (o is Curve)
            {
                return(GhRhConveter.fromCurve((Curve)o, getEncoded, getAbstract));
            }

            GH_Surface surface = o as GH_Surface;

            if (surface != null)
            {
                return(GhRhConveter.fromBrep(surface.Value, getEncoded, getAbstract));
            }

            GH_Brep brep = o as GH_Brep;

            if (brep != null)
            {
                return(GhRhConveter.fromBrep(brep.Value, getEncoded, getAbstract));
            }

            if (o is Brep)
            {
                return(GhRhConveter.fromBrep((Brep)o, getEncoded, getAbstract));
            }

            GH_Mesh mesh = o as GH_Mesh;

            if (mesh != null)
            {
                return(GhRhConveter.fromMesh(mesh.Value));
            }
            if (o is Mesh)
            {
                return(GhRhConveter.fromMesh((Mesh)o));
            }

            return(new SpeckleObject()
            {
                hash = "404", value = "Type not supported", type = "404"
            });
        }
예제 #25
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.Assembly assembly = new Types.Assembly();
            DA.GetData<Types.Assembly>("Material", ref assembly);

            GH_Number area = new GH_Number(0);
            GH_Surface surface = new GH_Surface();

            if (!DA.GetData<GH_Number>("Area", ref area)) area = new GH_Number(0);
            if (!DA.GetData<GH_Surface>("Surface", ref surface)) surface = new GH_Surface();

            double calculationArea = area.Value;
            if (surface.Value != null) calculationArea += surface.Value.GetArea();

            Types.Result result = new Types.Result()
            {
                GlobalWarmingPotential = new Types.UnitDouble<Types.LCA.CO2e>(assembly.GlobalWarmingPotential.Value * calculationArea),
                Acidification = new Types.UnitDouble<Types.LCA.kgSO2>(assembly.Acidification.Value * calculationArea),
                DepletionOfNonrenewbles = new Types.UnitDouble<Types.LCA.MJ>(assembly.DepletionOfNonrenewbles.Value * calculationArea),
                DepletionOfOzoneLayer = new Types.UnitDouble<Types.LCA.kgCFC11>(assembly.DepletionOfOzoneLayer.Value * calculationArea),
                Eutrophication = new Types.UnitDouble<Types.LCA.kgPhostphate>(assembly.Eutrophication.Value * calculationArea),
                FormationTroposphericOzone = new Types.UnitDouble<Types.LCA.kgNOx>(assembly.FormationTroposphericOzone.Value * calculationArea)
            };

            DA.SetData("LCA Result", result);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaProfile profile = new GsaProfile();

            #region catalogue
            if (_mode == FoldMode.Catalogue)
            {
                profile.profileType = GsaProfile.ProfileTypes.Catalogue;

                // need to implement the lists of cross sections
                profile.catalogueIndex        = catalogueIndex;
                profile.catalogueProfileIndex = catalogueProfileIndex;
                profile.catalogueTypeIndex    = catalogueTypeIndex;
            }
            #endregion
            #region geometric
            if (_mode == FoldMode.Geometric)
            {
                profile.profileType = GsaProfile.ProfileTypes.Geometric;
                GH_Brep gh_Brep = new GH_Brep();
                if (DA.GetData(0, ref gh_Brep))
                {
                    Brep brep = new Brep();
                    if (GH_Convert.ToBrep(gh_Brep, ref brep, GH_Conversion.Both))
                    {
                        // get edge curves from Brep
                        Curve[] edgeSegments = brep.DuplicateEdgeCurves();
                        Curve[] edges        = Curve.JoinCurves(edgeSegments);

                        // find the best fit plane
                        List <Point3d> ctrl_pts = new List <Point3d>();
                        if (edges[0].TryGetPolyline(out Polyline tempCrv))
                        {
                            ctrl_pts = tempCrv.ToList();
                        }
                        else
                        {
                            this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Cannot convert edge to Polyline");
                        }
                        Plane.FitPlaneToPoints(ctrl_pts, out Plane plane);
                        Rhino.Geometry.Transform xform = Rhino.Geometry.Transform.ChangeBasis(Plane.WorldXY, plane);

                        profile.geoType = GsaProfile.GeoTypes.Perim;

                        List <Point2d> pts = new List <Point2d>();
                        foreach (Point3d pt3d in ctrl_pts)
                        {
                            pt3d.Transform(xform);
                            Point2d pt2d = new Point2d(pt3d);
                            pts.Add(pt2d);
                        }
                        profile.perimeterPoints = pts;

                        if (edges.Length > 1)
                        {
                            List <List <Point2d> > voidPoints = new List <List <Point2d> >();
                            for (int i = 1; i < edges.Length; i++)
                            {
                                ctrl_pts.Clear();
                                if (!edges[i].IsPlanar())
                                {
                                    for (int j = 0; j < edges.Length; j++)
                                    {
                                        edges[j] = Curve.ProjectToPlane(edges[j], plane);
                                    }
                                }
                                if (edges[i].TryGetPolyline(out tempCrv))
                                {
                                    ctrl_pts = tempCrv.ToList();
                                    pts      = new List <Point2d>();
                                    foreach (Point3d pt3d in ctrl_pts)
                                    {
                                        pt3d.Transform(xform);
                                        Point2d pt2d = new Point2d(pt3d);
                                        pts.Add(pt2d);
                                    }
                                    voidPoints.Add(pts);
                                }
                                else
                                {
                                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Cannot convert internal edge  to Polyline");
                                }
                            }
                            profile.voidPoints = voidPoints;
                        }
                    }
                }
            }
            #endregion
            #region standard section
            if (_mode != FoldMode.Geometric & _mode != FoldMode.Catalogue)
            {
                profile.profileType = GsaProfile.ProfileTypes.Standard;
                GH_Number gh_d   = new GH_Number();
                GH_Number gh_b1  = new GH_Number();
                GH_Number gh_b2  = new GH_Number();
                GH_Number gh_tw1 = new GH_Number();
                GH_Number gh_tw2 = new GH_Number();
                GH_Number gh_tf1 = new GH_Number();
                GH_Number gh_tf2 = new GH_Number();
                switch (selections[1])
                {
                case "Rectangle":
                    profile.stdShape = GsaProfile.StdShapeOptions.Rectangle;

                    // 0 d
                    DA.GetData(0, ref gh_d);

                    // 1 b1
                    DA.GetData(1, ref gh_b1);

                    if (isTapered)
                    {
                        // 2 b2
                        DA.GetData(2, ref gh_b2);
                    }
                    else
                    {
                        if (isHollow)
                        {
                            // 2 tw
                            DA.GetData(2, ref gh_tw1);

                            // 3 tw
                            DA.GetData(3, ref gh_tf1);
                        }
                    }
                    break;

                case "Circle":
                    profile.stdShape = GsaProfile.StdShapeOptions.Circle;

                    // 0 d
                    DA.GetData(0, ref gh_d);

                    if (isHollow)
                    {
                        if (isElliptical)
                        {
                            // 1 b1
                            DA.GetData(1, ref gh_b1);

                            // 2 tw
                            DA.GetData(2, ref gh_tw1);
                        }
                        else
                        {
                            // 1 tw
                            DA.GetData(1, ref gh_tw1);
                        }
                    }
                    else
                    {
                        if (isElliptical)
                        {
                            // 1 b1
                            DA.GetData(1, ref gh_b1);
                        }
                    }

                    break;

                case "I section":
                    profile.stdShape = GsaProfile.StdShapeOptions.I_section;

                    // 0 d
                    DA.GetData(0, ref gh_d);

                    // 1 b1
                    DA.GetData(1, ref gh_b1);

                    // 2 tw1
                    DA.GetData(2, ref gh_tw1);

                    // 3 tf1
                    DA.GetData(3, ref gh_tf1);

                    if (isGeneral)
                    {
                        if (isTapered)
                        {
                            // 4 b2
                            DA.GetData(4, ref gh_b2);

                            // 5 tw2
                            DA.GetData(5, ref gh_tw2);

                            // 6 tf2
                            DA.GetData(6, ref gh_tf2);
                        }
                        else
                        {
                            // 4 b2
                            DA.GetData(4, ref gh_b2);

                            // 5 tf2
                            DA.GetData(5, ref gh_tf2);
                        }
                    }
                    break;

                case "Tee":
                    profile.stdShape = GsaProfile.StdShapeOptions.Tee;
                    // 0 d
                    DA.GetData(0, ref gh_d);

                    // 1 b1
                    DA.GetData(1, ref gh_b1);

                    // 2 tf1
                    DA.GetData(2, ref gh_tf1);

                    // 3 tw1
                    DA.GetData(3, ref gh_tw1);

                    if (isTapered)
                    {
                        // 4 tw2
                        DA.GetData(4, ref gh_tw2);
                    }
                    break;

                case "Channel":
                    profile.stdShape = GsaProfile.StdShapeOptions.Channel;
                    // 0 d
                    DA.GetData(0, ref gh_d);

                    // 1 b1
                    DA.GetData(1, ref gh_b1);

                    // 2 tf1
                    DA.GetData(2, ref gh_tf1);

                    // 3 tw1
                    DA.GetData(3, ref gh_tw1);
                    break;

                case "Angle":
                    profile.stdShape = GsaProfile.StdShapeOptions.Angle;
                    // 0 d
                    DA.GetData(0, ref gh_d);

                    // 1 b1
                    DA.GetData(1, ref gh_b1);

                    // 2 tf1
                    DA.GetData(2, ref gh_tf1);

                    // 3 tw1
                    DA.GetData(3, ref gh_tw1);
                    break;
                }

                if (gh_d != null)
                {
                    if (GH_Convert.ToDouble(gh_d, out double d, GH_Conversion.Both))
                    {
                        profile.d = d;
                    }
                }
                if (gh_b1 != null)
                {
                    if (GH_Convert.ToDouble(gh_b1, out double b1, GH_Conversion.Both))
                    {
                        profile.b1 = b1;
                    }
                }
                if (gh_b2 != null)
                {
                    if (GH_Convert.ToDouble(gh_b2, out double b2, GH_Conversion.Both))
                    {
                        profile.b2 = b2;
                    }
                }
                if (gh_tw1 != null)
                {
                    if (GH_Convert.ToDouble(gh_tw1, out double tw1, GH_Conversion.Both))
                    {
                        profile.tw1 = tw1;
                    }
                }
                if (gh_tw2 != null)
                {
                    if (GH_Convert.ToDouble(gh_tw2, out double tw2, GH_Conversion.Both))
                    {
                        profile.tw2 = tw2;
                    }
                }
                if (gh_tf1 != null)
                {
                    if (GH_Convert.ToDouble(gh_tf1, out double tf1, GH_Conversion.Both))
                    {
                        profile.tf1 = tf1;
                    }
                }
                if (gh_tf2 != null)
                {
                    if (GH_Convert.ToDouble(gh_tf2, out double tf2, GH_Conversion.Both))
                    {
                        profile.tf2 = tf2;
                    }
                }
                profile.isB2B        = isB2B;
                profile.isElliptical = isElliptical;
                profile.isGeneral    = isGeneral;
                profile.isHollow     = isHollow;
                profile.isTapered    = isTapered;
            }
            #endregion
            #region units
            switch (Util.Unit.LengthSection)
            {
            case "mm":
                profile.sectUnit = GsaProfile.SectUnitOptions.u_mm;
                break;

            case "cm":
                profile.sectUnit = GsaProfile.SectUnitOptions.u_cm;
                break;

            case "m":
                profile.sectUnit = GsaProfile.SectUnitOptions.u_m;
                break;

            case "in":
                profile.sectUnit = GsaProfile.SectUnitOptions.u_in;
                break;

            case "ft":
                profile.sectUnit = GsaProfile.SectUnitOptions.u_ft;
                break;
            }
            #endregion

            // build string and output
            DA.SetData(0, ConvertSection.ProfileConversion(profile));
        }
예제 #27
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.Assembly assembly = new Types.Assembly();
            DA.GetData<Types.Assembly>("Material", ref assembly);

            GH_Brep brep = new GH_Brep();
            GH_Number volume = new GH_Number(0);

            if (!DA.GetData<GH_Number>("Volume", ref volume)) volume = new GH_Number(0);
            if (!DA.GetData<GH_Brep>("Brep", ref brep)) brep = new GH_Brep();

            double calculationVolume = volume.Value;
            if (brep.Value != null) calculationVolume += brep.Value.GetVolume();

            Types.Result result = new Types.Result()
            {
                GlobalWarmingPotential = new Types.UnitDouble<Types.LCA.CO2e>(assembly.GlobalWarmingPotential.Value * calculationVolume),
                Acidification = new Types.UnitDouble<Types.LCA.kgSO2>(assembly.Acidification.Value * calculationVolume),
                DepletionOfNonrenewbles = new Types.UnitDouble<Types.LCA.MJ>(assembly.DepletionOfNonrenewbles.Value * calculationVolume),
                DepletionOfOzoneLayer = new Types.UnitDouble<Types.LCA.kgCFC11>(assembly.DepletionOfOzoneLayer.Value * calculationVolume),
                Eutrophication = new Types.UnitDouble<Types.LCA.kgPhostphate>(assembly.Eutrophication.Value * calculationVolume),
                FormationTroposphericOzone = new Types.UnitDouble<Types.LCA.kgNOx>(assembly.FormationTroposphericOzone.Value * calculationVolume)
            };

            DA.SetData("LCA Result", result);
        }
예제 #28
0
        /// <summary>
        /// Updates the GH_Structure component out values ready to go
        /// </summary>
        /// <param name="pop"></param>
        /// <param name="BioBranches"></param>
        /// <param name="performanceCount"></param>
        /// <param name="bioBranchID"></param>
        public void SetComponentOut(Population pop, List <BioBranch> BioBranches, int performanceCount, int bioBranchID)
        {
            popCount = pop.chromosomes.Length;

            // Historic pop
            historicNumbers = new GH_Structure <GH_Number>();

            for (int i = 0; i < BioBranches.Count; i++)
            {
                for (int j = 0; j < BioBranches[i].PopTwigs.Count; j++)
                {
                    for (int k = 0; k < BioBranches[i].PopTwigs[j].chromosomes.Length; k++)
                    {
                        List <GH_Number> myList = new List <GH_Number>();
                        for (int c = 0; c < pop.chromosomes[k].GetGenes().Length; c++)
                        {
                            GH_Number myGHNumber = new GH_Number(BioBranches[i].PopTwigs[j].chromosomes[k].GetGenes()[c]);
                            myList.Add(myGHNumber);
                        }

                        GH_Path myPath = new GH_Path(i, j, k);
                        historicNumbers.AppendRange(myList, myPath);
                    }
                }
            }

            // Find the current number of population twigs in the latest biobranch
            int lastBranchTwigCount = BioBranches[bioBranchID].PopTwigs.Count;

            // Now add the current population to the output, using the latest biobranch ID.
            // This is going to be really hard to understand in a month's time.
            for (int k = 0; k < pop.chromosomes.Length; k++)
            {
                List <GH_Number> myList = new List <GH_Number>();
                for (int c = 0; c < pop.chromosomes[k].GetGenes().Length; c++)
                {
                    GH_Number myGHNumber = new GH_Number(pop.chromosomes[k].GetGenes()[c]);
                    myList.Add(myGHNumber);
                }

                GH_Path myPath = new GH_Path(bioBranchID, lastBranchTwigCount, k);
                historicNumbers.AppendRange(myList, myPath);
            }

            // Get the Guids for the sliders and genepools to pass on
            genoGuids = new GH_Structure <GH_Guid>();

            List <GH_Guid> mySliderList   = new List <GH_Guid>();
            List <GH_Guid> myGenepoolList = new List <GH_Guid>();

            // Add the sliders
            for (int i = 0; i < cSliders.Count; i++)
            {
                GH_Guid myGuid = new GH_Guid(cSliders[i].InstanceGuid);
                mySliderList.Add(myGuid);
            }

            // Add the genepools
            for (int i = 0; i < cGenePools.Count; i++)
            {
                GH_Guid myGuid = new GH_Guid(cGenePools[i].InstanceGuid);
                myGenepoolList.Add(myGuid);
            }

            // Add to the GH_Structure
            genoGuids.AppendRange(mySliderList, new GH_Path(0));
            genoGuids.AppendRange(myGenepoolList, new GH_Path(1));


            this.ExpireSolution(true);
        }
예제 #29
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)
        {
            // Definition of input variables
            var north  = new Vector3d();
            var sazi   = new List <double>();
            var salt   = new List <double>();
            var shours = new List <double>();
            var pmesh  = new List <Mesh>();
            var atol   = new double();

            //Definition of output variable
            var siftazi   = new GH_Structure <GH_Number>();
            var siftalt   = new GH_Structure <GH_Number>();
            var sifthours = new GH_Structure <GH_Number>();
            var svector   = new GH_Structure <GH_Vector>();



            // Populating the list input variables
            if (!DA.GetData(0, ref north))
            {
                return;
            }
            if (!DA.GetDataList(1, sazi))
            {
                return;
            }
            if (!DA.GetDataList(2, salt))
            {
                return;
            }
            if (!DA.GetDataList(3, shours))
            {
                return;
            }
            if (!DA.GetDataList(4, pmesh))
            {
                return;
            }
            if (!DA.GetData(5, ref atol))
            {
                return;
            }


            // Evaluate if North == null
            if (north == null)
            {
                north = new Vector3d(1.0, 0.0, 0.0);
            }

            //Project north in the XY world and unitize
            if (!north.IsPerpendicularTo(new Vector3d(0.0, 0.0, 1.0)))
            {
                var xyworld      = new Plane(new Point3d(0.0, 0.0, 0.0), new Vector3d(0.0, 0.0, 1.0));
                var proj_xyworld = new Transform();
                proj_xyworld = Transform.PlanarProjection(xyworld);

                north.Transform(proj_xyworld);
                north.Unitize();
            }
            else
            {
                north.Unitize();
            }

            // Abort the component if retrieval fails or input length are zeros
            if (sazi == null)
            {
                return;
            }
            if (salt == null)
            {
                return;
            }
            if (shours == null)
            {
                return;
            }

            if (sazi.Count == 0)
            {
                return;
            }
            if (salt.Count == 0)
            {
                return;
            }
            if (shours.Count == 0)
            {
                return;
            }

            // Abort if sazi, salt and shours counts differ
            if (!(sazi.Count == salt.Count || sazi.Count == shours.Count || salt.Count == shours.Count))
            {
                return;
            }

            // start the analysis
            int scount = sazi.Count;
            int mcount = pmesh.Count;

            //for each input mesh
            for (int i = 0; i < mcount; i++)
            {
                GH_Path p1               = new GH_Path(i);
                var     current_mesh     = pmesh[i];
                var     current_centroid = new Point3d(AreaMassProperties.Compute(current_mesh).Centroid);
                current_mesh.FaceNormals.ComputeFaceNormals();
                var current_normal = current_mesh.FaceNormals[0];
                current_normal.Unitize();


                //for each input sun vector
                for (int j = 0; j < scount; j++)
                {
                    GH_Path p2 = new GH_Path(i, j);

                    //convert sun angles to radians
                    var current_sazi_r = RhinoMath.ToRadians(sazi[j]);
                    var current_salt_r = RhinoMath.ToRadians(salt[j]);

                    // convert to clockwise angle values
                    current_sazi_r = 2 * Math.PI - current_sazi_r;
                    current_salt_r = 2 * Math.PI - current_salt_r;

                    var current_sazi  = new GH_Number(RhinoMath.ToDegrees(current_sazi_r));
                    var current_salt  = new GH_Number(RhinoMath.ToDegrees(current_salt_r));
                    var current_shour = new GH_Number(shours[j]);


                    //create sun vector
                    var current_sun = new Vector3d(north.X - current_centroid.X, north.Y - current_centroid.Y, north.Z - current_centroid.Z);
                    current_sun.Unitize();
                    //current_sun.Reverse();
                    current_sun.Rotate(current_salt_r, Vector3d.CrossProduct(new Vector3d(0.0, 0.0, 1.0), north));
                    current_sun.Rotate(current_sazi_r, new Vector3d(0.0, 0.0, 1.0));
                    //current_sun.Reverse();

                    // Dot product mesh normal current_sun
                    var dsn = Vector3d.Multiply(current_normal, current_sun);


                    if (dsn > (0 + Math.Cos(Math.PI / 2 - atol)))
                    {
                        siftazi.Append(current_sazi, p1);
                        siftalt.Append(current_salt, p1);
                        sifthours.Append(current_shour, p1);
                        svector.Append(new GH_Vector(current_sun));
                    }
                }
            }

            DA.SetDataTree(0, siftazi);
            DA.SetDataTree(1, siftalt);
            DA.SetDataTree(2, sifthours);
            DA.SetDataTree(3, svector);
        }
예제 #30
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            this.Components = new List <object>();
            DA.GetDataList <object>("Components", this.Components);
            GH_Boolean update = new GH_Boolean(true);
            GH_Boolean erase  = new GH_Boolean(false);

            this.Ip      = new GH_String("127.0.0.1");
            this.Port    = new GH_Integer(8002);
            this.Timeout = new GH_Integer(10000);
            DA.GetData <GH_Boolean>("Update", ref update);
            DA.GetData <GH_String>("IP", ref this.Ip);
            DA.GetData <GH_Integer>("Port", ref this.Port);
            DA.GetData <GH_Integer>("TimeOut", ref this.Timeout);
            GH_Boolean send = new GH_Boolean();

            DA.GetData <GH_Boolean>("Send", ref send);
            DA.GetData <GH_Boolean>("Erase", ref erase);
            this.Erase  = erase.Value;
            this.Update = update.Value;
            GH_Number scale = new GH_Number(3.28084);

            DA.GetData <GH_Number>("Scale", ref scale);
            this.Scale = scale.Value;

            if (send.Value)
            {
                this.Icon = Properties.Resources.paper_airplane_red;
                this.DestroyIconCache();
                Grasshopper.Instances.RedrawAll();

                bool   retry        = true;
                string responseData = "";

                try
                {
                    while (retry)
                    {
                        using (TcpClient tcpClient = new TcpClient())
                        {
                            tcpClient.Connect(IPAddress.Parse(Ip.Value), Port.Value);
                            tcpClient.NoDelay        = true;
                            tcpClient.ReceiveTimeout = Timeout.Value;
                            tcpClient.SendTimeout    = Timeout.Value;

                            using (NetworkStream stream = tcpClient.GetStream())
                            {
                                using (StreamWriter writer = new StreamWriter(stream, new UTF8Encoding(false)))
                                {
                                    writer.AutoFlush = true;
                                    using (StreamReader reader = new StreamReader(stream))
                                    {
                                        string line = ComponentsToString(this.Components);
                                        writer.WriteLine(line);

                                        string response = reader.ReadLine();
                                        if (response == line)
                                        {
                                            retry = false;
                                        }
                                        responseData = reader.ReadLine();
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, ex.Message);
                }

                try
                {
                    if (responseData != "")
                    {
                        revitFamilyCollection = (RevitFamilyCollection)Grevit.Serialization.Utilities.Deserialize(responseData, typeof(RevitFamilyCollection));
                    }
                }
                catch (Exception ex)
                {
                }

                this.Icon = Properties.Resources.paper_airplane_green;
                this.DestroyIconCache();
                Grasshopper.Instances.RedrawAll();
            }

            DA.SetDataList("Categories", revitFamilyCollection.Categories);
        }
예제 #31
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)
        {
            if (GH_Document.IsEscapeKeyDown())
            {
                GH_Document GHDocument = OnPingDocument();
                GHDocument.RequestAbortSolution();
                return;
            }

            ikvm.runtime.Startup.addBootClassPathAssemby(Assembly.Load("culebra"));
            ikvm.runtime.Startup.addBootClassPathAssemby(Assembly.Load("IKVM.OpenJDK.Core"));

            bool           reset           = new bool();
            List <object>  init_Settings   = new List <object>();
            List <object>  move_Settings   = new List <object>();
            IGH_VisualData visual_Settings = null;

            object behavioral_Settings = null;

            if (!DA.GetDataList(0, init_Settings) || init_Settings.Count == 0 || init_Settings == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Init Settings Detected, please connect Init Settings to enable the component");
                return;
            }
            if (!DA.GetDataList(1, move_Settings) || move_Settings.Count == 0 || move_Settings == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Move Settings Detected, please connect Move Settings to enable the component");
                return;
            }
            if (!DA.GetData(3, ref visual_Settings) || visual_Settings == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Visual Settings Detected, please connect Visual Settings to enable the component");
                return;
            }
            if (!DA.GetData(4, ref reset))
            {
                return;
            }
            Random rnd = new Random();

            if (!DA.GetData(2, ref behavioral_Settings) || behavioral_Settings == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Input Object is Null");
                return;
            }
            string objtype = behavioral_Settings.GetType().Name.ToString();

            if (!(behavioral_Settings.GetType() == typeof(IGH_BehaviorData)))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "You did not input a Behavior Data Object, please ensure input is Behavior Data Object and not " + objtype);
                return;
            }
            else
            {
                #region Initialize / Data Parse
                //------------------------Init Settings--------------------------
                if (init_Settings.Count != 0)
                {
                    String init_Convert = "";
                    if (init_Settings[0].GetType() == typeof(GH_String))
                    {
                        GH_String value = (GH_String)init_Settings[0];
                        init_Convert = value.Value;
                    }
                    if (init_Convert == "Box")
                    {
                        this.spawnData = "box";
                        GH_Convert.ToBox_Primary(init_Settings[3], ref this.box);
                        GH_Convert.ToInt32(init_Settings[4], out this.spawnType, GH_Conversion.Primary);
                        GH_Convert.ToInt32(init_Settings[5], out this.pointCount, GH_Conversion.Primary);
                        GH_Convert.ToInt32(init_Settings[1], out this.dimensions, GH_Conversion.Primary);
                    }
                    else if (init_Convert == "Points")
                    {
                        this.spawnData = "Points";
                        var wrapperToGoo = GH_Convert.ToGoo(init_Settings[3]);
                        wrapperToGoo.CastTo <List <Point3d> >(out this.ptList);
                        GH_Convert.ToInt32(init_Settings[1], out this.dimensions, GH_Conversion.Primary);
                        GH_Convert.ToBox_Primary(init_Settings[4], ref this.box);
                    }
                    GH_Convert.ToInt32(init_Settings[2], out this.bounds, GH_Conversion.Primary);
                }
                //------------------------Move Settings--------------------------
                Vector3d initialVector = new Vector3d();
                if (move_Settings.Count != 0)
                {
                    if (move_Settings[0].GetType() == typeof(GH_Vector))
                    {
                        GH_Vector value = (GH_Vector)move_Settings[0];
                        initialVector = value.Value;
                    }
                    else if (move_Settings[0].GetType() == typeof(GH_Number))
                    {
                        GH_Number value = (GH_Number)move_Settings[0];
                        this.initialSpeed = value.Value;
                    }
                    GH_Convert.ToDouble(move_Settings[1], out this.maxSpeed, GH_Conversion.Primary);
                    GH_Convert.ToDouble(move_Settings[2], out this.maxForce, GH_Conversion.Primary);
                    GH_Convert.ToDouble(move_Settings[3], out this.velMultiplier, GH_Conversion.Primary);
                }
                //------------------------Visual Settings--------------------------
                TrailData td = visual_Settings.Value.trailData;
                ColorData cd = visual_Settings.Value.colorData;
                this.trail           = td.createTrail;
                this.displayMode     = visual_Settings.Value.displayMode;
                this.trailStep       = td.trailStep;
                this.maxTrailSize    = td.maxTrailSize;
                this.particleTexture = cd.particleTexture;
                this.graphicType     = cd.colorDataType;
                this.useTexture      = visual_Settings.Value.useTexture;
                if (cd.colorDataType == "Gradient")
                {
                    this.maxthick       = cd.maxThickness;
                    this.minthick       = cd.minThickness;
                    this.redValues[0]   = cd.redChannel[0];
                    this.redValues[1]   = cd.redChannel[1];
                    this.greenValues[0] = cd.greenChannel[0];
                    this.greenValues[1] = cd.greenChannel[1];
                    this.blueValues[0]  = cd.blueChannel[0];
                    this.blueValues[1]  = cd.blueChannel[1];
                }
                else if (cd.colorDataType == "GraphicPolyline")
                {
                    this.polylineColor = cd.color;
                    this.dotted        = cd.dotted;
                    this.maxthick      = cd.maxThickness;
                }
                else if (cd.colorDataType == "Disco")
                {
                    this.maxthick = cd.maxThickness;
                    this.minthick = cd.minThickness;
                }
                else if (cd.colorDataType == "Base")
                {
                    this.maxthick = 3;
                    this.minthick = 1;
                }
                //-----------------------------------------------------------------
                IGH_PreviewObject comp = (IGH_PreviewObject)this;
                if (comp.Hidden && (this.displayMode == 0))
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Component preview must be enabled to see Graphic Mode on Canvas, right click on component and set preview on");
                }
                #endregion
                #region Pre Simulation Code
                //------------------------RESET STARTS HERE--------------------------
                if (reset)
                { //We are using the reset to reinitialize all the variables and positions
                    //-----------------------------------------------------------------
                    this.bb = new BoundingBox();
                    int  loopCount = new int();
                    bool create    = new bool();
                    if (this.spawnData == "box")
                    {
                        this.bb   = this.box.BoundingBox;
                        loopCount = this.pointCount;
                        create    = true;
                    }
                    else if (this.spawnData == "Points")
                    {
                        loopCount = this.ptList.Count;
                        create    = false;
                        this.bb   = this.box.BoundingBox;
                    }
                    //-----------------------------------------------------------------
                    this.globalEngine = new Engine_Global();
                    this.cycles       = 0;

                    this.moveList       = new List <Vector3d>();
                    this.startList      = new List <Vector3d>();
                    this.creepList      = new List <CulebraObject>();
                    this.currentPosList = new List <Point3d>();
                    this.networkList    = new List <Line>();
                    flattenedTrails     = new List <Vector3d>();

                    for (int i = 0; i < loopCount; i++)
                    {
                        if (this.dimensions == 0)
                        { //If we want 2D
                            General.setViewport("Top", "Shaded");
                            if (create)
                            { //If are creating random points inside bbox
                                if (this.spawnType == 0 || this.spawnType == 2)
                                {
                                    this.startPos = new Vector3d((int)bb.Min[0], rnd.Next((int)bb.Min[1], (int)bb.Max[1]), 0); //spawn along the y axis of the bounding area
                                }
                                else if (this.spawnType == 1 || this.spawnType == 3)
                                {
                                    this.startPos = new Vector3d(rnd.Next((int)bb.Min[0], (int)bb.Max[0]), rnd.Next((int)bb.Min[1], (int)bb.Max[1]), 0); //spawn randomly inside the bounding area
                                }
                                if (initialVector.Length > 0)
                                {
                                    this.moveVec = initialVector; //move in the user specified direction
                                }
                                else
                                {
                                    this.moveVec = new Vector3d(rnd.Next(-1, 2) * initialSpeed, rnd.Next(-1, 2) * initialSpeed, 0); //move randomly in any direction 2d
                                }
                            }
                            else
                            { //If we are using user defined points
                                this.startPos = (Vector3d)this.ptList[i];
                                if (initialVector.Length > 0)
                                {
                                    this.moveVec = initialVector; //move in the user specified direction
                                }
                                else
                                {
                                    this.moveVec = new Vector3d(rnd.Next(-1, 2) * initialSpeed, rnd.Next(-1, 2) * initialSpeed, 0); //move randomly in any direction 2d
                                }
                            }
                            this.creep = new Creeper(this.startPos, this.moveVec, true, false);
                            this.creepList.Add(this.creep);
                        }
                        else
                        { //If we want 3D
                            General.setViewport("Perspective", "Shaded");
                            if (create)
                            { //If are creating random points inside bbox
                                if (this.spawnType == 0 || this.spawnType == 2)
                                {
                                    this.startPos = new Vector3d(rnd.Next((int)bb.Min[0], (int)bb.Max[0]), rnd.Next((int)bb.Min[1], (int)bb.Max[1]), (int)bb.Min[2]); //start randomly on the lowest plane of the 3d bounds
                                    if (initialVector.Length > 0)
                                    {
                                        this.moveVec = initialVector; //move in the user specified direction
                                    }
                                    else
                                    {
                                        this.moveVec = new Vector3d(rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed, 1 * initialSpeed); //move randomly in the xy axis and up in the z axis
                                    }
                                }
                                else if (this.spawnType == 1 || this.spawnType == 3)
                                {
                                    this.startPos = new Vector3d(rnd.Next((int)bb.Min[0], (int)bb.Max[0]), rnd.Next((int)bb.Min[1], (int)bb.Max[1]), rnd.Next((int)bb.Min[2], (int)bb.Max[2])); //start randomly inside the 3d bounds
                                    if (initialVector.Length > 0)
                                    {
                                        this.moveVec = initialVector; //move in the user specified direction
                                    }
                                    else
                                    {
                                        this.moveVec = new Vector3d(rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed); //move randomly in any direction 3d
                                    }
                                }
                            }
                            else
                            { //If we are using user defined points
                                this.startPos = (Vector3d)this.ptList[i];
                                if (initialVector.Length > 0)
                                {
                                    this.moveVec = initialVector; //move in the user specified direction
                                }
                                else
                                {
                                    this.moveVec = new Vector3d(rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed); //move randomly in any direction 3d
                                }
                            }
                            this.creep = new Creeper(this.startPos, this.moveVec, true, true);
                            this.creepList.Add(this.creep);
                        }
                        this.startList.Add(this.startPos); //add the initial starting positions to the list to pass once we start running
                        this.moveList.Add(this.moveVec);   //add the initial move vectors to the list to pass once we start running
                    }
                    DA.SetDataList(0, this.startList);
                }
                #endregion
                #region Simulation Code
                else
                {
                    this.particleSet.Clear();
                    this.currentPosList.Clear();
                    this.particleSet.TrimExcess();
                    this.currentPosList.TrimExcess();

                    this.trailTree.Clear();
                    this.networkTree.Clear();
                    this.trailTree.TrimExcess();
                    this.networkTree.TrimExcess();

                    if (this.moveList == null)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Please Reset the CreepyCrawlers Component"); return;
                    }
                    try
                    {
                        globalEngine.Action(this.creepList, this.dimensions, behavioral_Settings, this.displayMode, this.networkList,
                                            this.maxSpeed, this.maxForce, this.velMultiplier, this.flattenedTrails, this.particleList, this.particleSet, networkTree, trailStep, maxTrailSize, bounds, bb, currentPosList, trail, trailTree);
                    }catch (Exception e)
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message.ToString());
                        return;
                    }
                    DA.SetDataList(0, this.currentPosList);
                    DA.SetDataTree(2, networkTree);
                    if (this.displayMode == 1 && this.trail)
                    {
                        DA.SetDataTree(1, trailTree);
                    }
                    this.flattenedTrails.Clear();
                    this.flattenedTrails.TrimExcess();

                    this.cycles++;
                }
                #endregion
            }
            timer.DisplayMessage(this, "Single", this.cycles, this.myBool);
        }
        /// <summary>
        /// Updates the geometry for an input chromosome
        /// </summary>
        /// <param name="chromo">The chromosome used to get geometry from the gh canvas</param>
        /// <returns></returns>
        public int GetGeometry(Chromosome chromo)
        {
            // Collect the object at the current instance
            List <object> localObjs = new List <object>();

            // Thank you Dimitrie :)
            foreach (IGH_Param param in Params.Input[1].Sources)
            {
                foreach (Object myObj in param.VolatileData.AllData(true)) // AllData flattens the tree
                {
                    localObjs.Add(myObj);
                }
            }

            // TODO: The allGeometry should not be of type Mesh.
            List <Mesh> allGeometry = new List <Mesh>();

            // Get only mesh geometry from the object list
            for (int i = 0; i < localObjs.Count; i++)
            {
                if (localObjs[i] is GH_Mesh)
                {
                    GH_Mesh myGHMesh = new GH_Mesh();
                    myGHMesh = (GH_Mesh)localObjs[i];
                    Mesh myLocalMesh = new Mesh();
                    GH_Convert.ToMesh(myGHMesh, ref myLocalMesh, GH_Conversion.Primary);
                    myLocalMesh.Faces.ConvertQuadsToTriangles();
                    //Mesh joinedMesh = new Mesh(); yes this is commented out and no I am not a software engineer. Deal with it.
                    //joinedMesh.Append(myLocalMesh);
                    allGeometry.Add(myLocalMesh);
                }
            }

            // Get performance data
            List <double> performas = new List <double>();
            List <string> criteria  = new List <string>();

            // Cap at eight criteria max.
            int pCount = 0;

            foreach (IGH_Param param in Params.Input[2].Sources)
            {
                foreach (Object myObj in param.VolatileData.AllData(true))
                {
                    if (myObj is GH_Number && pCount < 8)
                    {
                        if (!criteria.Contains(param.NickName))
                        {
                            GH_Number temp = (GH_Number)myObj;
                            performas.Add(temp.Value);
                            criteria.Add(param.NickName);
                            pCount++;
                        }
                    }

                    else if (myObj is GH_Integer && pCount < 8)
                    {
                        if (!criteria.Contains(param.NickName))
                        {
                            GH_Integer temp = (GH_Integer)myObj;
                            performas.Add((double)temp.Value);
                            criteria.Add(param.NickName);
                            pCount++;
                        }
                    }
                }
            }

            // Set the phenotype within the chromosome class
            chromo.SetPhenotype(allGeometry, performas, criteria);

            // Return the number of performance criteria
            return(performas.Count);
        }
예제 #33
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));
                }
        /// <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)
        {
            //loacl varaibles
            GH_Colour inColor = null;
            GH_Number inNumber = new GH_Number(1.0);

            //get user data
            if (!DA.GetData(0, ref inColor))
            {
                return;
            }
            DA.GetData(1, ref inNumber);

            //spin up a JSON material from the inputs
            string outJSON = ConstructMaterial(inColor, inNumber);

            //output
            DA.SetData(0, outJSON);
        }
예제 #35
0
        /*******************************************/

        public static bool CastToGoo(object value, ref GH_Number target)
        {
            return(GH_Convert.ToGHNumber(value, GH_Conversion.Both, ref target));
        }
예제 #36
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Surface surface = new GH_Surface();
            GH_String level = new GH_String();
            GH_String family = new GH_String("");
            GH_String type = new GH_String("");

            GH_Boolean structural = new GH_Boolean(false); 
            GH_Number slope = new GH_Number(0.0);
            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();
            DA.GetData<GH_Surface>("Surface", ref surface);

            GH_Point slopeTopPoint = new GH_Point(surface.Value.Edges[0].PointAtStart);
            GH_Point slopeBottomPoint = new GH_Point(surface.Value.Edges[0].PointAtEnd);

            //DA.GetData<GH_String>("Family", ref family);
            //DA.GetData<GH_String>("Type", ref type);
            DA.GetData<GH_String>("Levelbottom", ref level);
            DA.GetData<GH_Boolean>("Structural", ref structural);
            DA.GetData<GH_Point>("SlopeTopPoint", ref slopeTopPoint);
            DA.GetData<GH_Point>("SlopeBottomPoint", ref slopeBottomPoint);
            DA.GetData<GH_Number>("Slope", ref slope);

            

            Slab slab = new Slab();
            slab.FamilyOrStyle = family.Value;
            slab.TypeOrLayer = type.Value;
            slab.levelbottom = level.Value;
            slab.structural = structural.Value;
            slab.surface = new Profile();
            slab.surface.profile = new List<Loop>();
            
            Loop loop = new Loop();
            loop.outline = new List<Component>();

            foreach (Rhino.Geometry.BrepEdge be in surface.Value.Edges)
            {
                loop.outline.Add(be.ToNurbsCurve().ToGrevitCurve());
            }

            slab.surface.profile.Add(loop);

            slab.parameters = parameters;
            slab.top = slopeTopPoint.ToGrevitPoint();
            slab.bottom = slopeBottomPoint.ToGrevitPoint();
            slab.slope = slope.Value;
            slab.GID = this.InstanceGuid.ToString();



            DA.SetData("GrevitComponent", slab);
        }
예제 #37
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));
                }
            }
        }
예제 #38
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Curve baseline = new GH_Curve();
            GH_String level = new GH_String("none");
            GH_Number height = new GH_Number();
            GH_Number offset = new GH_Number();
            GH_Boolean join = new GH_Boolean(true);
            GH_Boolean flip = new GH_Boolean(false);
            GH_String family = new GH_String("");
            GH_String type = new GH_String("none");

            List<Parameter> parameters = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", parameters)) parameters = new List<Parameter>();

            DA.GetData<GH_Boolean>("Join", ref join);
            DA.GetData<GH_String>("Type", ref type);
            DA.GetData<GH_String>("Levelbottom", ref level);
            DA.GetData<GH_Number>("Height", ref height);
            DA.GetData<GH_Curve>("Baseline", ref baseline);
            DA.GetData<GH_Boolean>("Flip", ref flip);


            Wall wall = new Wall(family.Value, type.Value, parameters, baseline.ToGrevitCurve(), level.Value,height.Value,join.Value,flip.Value );
            
            Rhino.Geometry.Surface srf = Rhino.Geometry.Surface.CreateExtrusion(baseline.Value, new Rhino.Geometry.Vector3d(0, 0, height.Value));

            SetGID(wall);
            SetPreview(wall.GID, srf.ToBrep());
            
            DA.SetData("GrevitComponent", wall);
        }
예제 #39
0
        /*
         * Get choice method to be implemented later.
         *
         * /// <summary>
         * /// Gets
         * /// </summary>
         * /// <returns></returns>
         * public List<int> GetGhoice()
         * {
         *  // Collect the object at the current instance
         *  List<int> choices = new List<int>();
         *
         *  // Thank you Dimitrie :)
         *  foreach (IGH_Param param in Params.Input[4].Sources)
         *  {
         *      foreach (Object myObj in param.VolatileData.AllData(true)) // AllData flattens the tree
         *      {
         *          if (myObj is Grasshopper.Kernel.Types.GH_Number)
         *          {
         *              GH_Number thisChoice = (GH_Number)myObj;
         *              int x = (int)thisChoice.Value;
         *              if(x>=0 && x<=11)
         *              {
         *                  choices.Add(x);
         *              }
         *          }
         *      }
         *  }
         *
         *  return choices;
         * }
         */

        /// <summary>
        /// Population cluster data for the component output. Outputs normalised genes values.
        /// </summary>
        /// <param name="pop">Uses the given population to set the cluster output data</param>
        public void SetComponentOut(Population pop, List <BioBranch> BioBranches)
        {
            // Curent pop
            populationNumbers = new GH_Structure <GH_Number>();

            for (int i = 0; i < pop.chromosomes.Length; i++)
            {
                GH_Path myPath = new GH_Path(i);

                List <GH_Number> myList = new List <GH_Number>();
                for (int k = 0; k < pop.chromosomes[i].GetGenes().Length; k++)
                {
                    GH_Number myGHNumber = new GH_Number(pop.chromosomes[i].GetGenes()[k]);
                    myList.Add(myGHNumber);
                }

                populationNumbers.AppendRange(myList, myPath);
            }


            // Cluster data
            clusterNumbers = new GH_Structure <GH_Number>();

            for (int i = 0; i < 12; i++)
            {
                GH_Path myPath       = new GH_Path(i);
                int     localCounter = 0;

                // Go through all the chromosomes. If cluster ID of it equals 'i', then stick it in the branch.
                for (int j = 0; j < pop.chromosomes.Length; j++)
                {
                    List <GH_Number> myList = new List <GH_Number>();

                    if (pop.chromosomes[j].clusterId == i)
                    {
                        for (int k = 0; k < pop.chromosomes[j].GetGenes().Length; k++)
                        {
                            GH_Number myGHNumber = new GH_Number(pop.chromosomes[j].GetGenes()[k]);
                            myList.Add(myGHNumber);
                        }

                        clusterNumbers.AppendRange(myList, myPath.AppendElement(localCounter));
                        localCounter++;
                    }
                }
            }


            // Historic pop
            historicNumbers = new GH_Structure <GH_Number>();

            for (int i = 0; i < BioBranches.Count; i++)
            {
                for (int j = 0; j < BioBranches[i].Twigs.Count; j++)
                {
                    for (int k = 0; k < BioBranches[i].Twigs[j].chromosomes.Length; k++)
                    {
                        List <GH_Number> myList = new List <GH_Number>();
                        for (int c = 0; c < pop.chromosomes[k].GetGenes().Length; c++)
                        {
                            GH_Number myGHNumber = new GH_Number(BioBranches[i].Twigs[j].chromosomes[k].GetGenes()[c]);
                            myList.Add(myGHNumber);
                        }

                        GH_Path myPath = new GH_Path(i, j, k);
                        historicNumbers.AppendRange(myList, myPath);
                    }
                }
            }



            this.ExpireSolution(true);
        }
예제 #40
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Instance i = null;
            DA.GetData<Instance>(0, ref i);

            GH_Point p = new GH_Point(new Rhino.Geometry.Point3d(i.Transformation.X, i.Transformation.Y, i.Transformation.Z));
            GH_Number scale = new GH_Number(i.Transformation.Scale);
            GH_String name = new GH_String(i.Name);
            GH_String parent = new GH_String(i.Parent.Name);

            List<GH_Brep> surfaces = new List<GH_Brep>();
            List<GH_Brep> inner = new List<GH_Brep>();

                foreach (Surface srf in i.Parent.Surfaces)
                    surfaces.Add(new GH_Brep(srf.ToRhinoGeo(i.Transformation)));

            DA.SetData(0, p);
            DA.SetData(1, name);
            DA.SetData(2, scale);
            DA.SetDataList(3, surfaces);
            DA.SetData(4, parent);
            DA.SetDataList(5, inner);
        }
예제 #41
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.Assembly assembly = new Types.Assembly();
            DA.GetData <Types.Assembly>("Material", ref assembly);

            GH_Curve  curve  = new GH_Curve();
            GH_Number radius = new GH_Number(0);
            GH_Number height = new GH_Number(0);
            GH_Number width  = new GH_Number(0);

            Types.Profile profile = null;

            if (!DA.GetData <GH_Number>("Radius", ref radius))
            {
                radius.Value = 0;
            }
            if (!DA.GetData <GH_Number>("Height", ref height))
            {
                height.Value = 0;
            }
            if (!DA.GetData <GH_Number>("Width", ref width))
            {
                width.Value = 0;
            }
            if (!DA.GetData <Types.Profile>("Profile", ref profile))
            {
                profile = null;
            }
            DA.GetData <GH_Curve>("Curve", ref curve);

            double calculationVolume = 0;


            if (profile != null)
            {
                calculationVolume = curve.Value.GetLength() * profile.Area;
                drawColumn(curve.Value.PointAtStart, curve.Value.PointAtEnd, profile.Area);
            }
            else
            {
                if (radius.Value > 0)
                {
                    drawColumn(curve.Value.PointAtStart, curve.Value.PointAtEnd, radius.Value);
                    calculationVolume = curve.Value.GetLength() * radius.Value * radius.Value * Math.PI;
                }
                else
                {
                    drawColumn(curve.Value.PointAtStart, curve.Value.PointAtEnd, height.Value, width.Value);
                    calculationVolume = curve.Value.GetLength() * height.Value * width.Value;
                }
            }



            Types.Result result = new Types.Result()
            {
                GlobalWarmingPotential     = new Types.UnitDouble <Types.LCA.CO2e>(assembly.GlobalWarmingPotential.Value * calculationVolume),
                Acidification              = new Types.UnitDouble <Types.LCA.kgSO2>(assembly.Acidification.Value * calculationVolume),
                DepletionOfNonrenewbles    = new Types.UnitDouble <Types.LCA.MJ>(assembly.DepletionOfNonrenewbles.Value * calculationVolume),
                DepletionOfOzoneLayer      = new Types.UnitDouble <Types.LCA.kgCFC11>(assembly.DepletionOfOzoneLayer.Value * calculationVolume),
                Eutrophication             = new Types.UnitDouble <Types.LCA.kgPhostphate>(assembly.Eutrophication.Value * calculationVolume),
                FormationTroposphericOzone = new Types.UnitDouble <Types.LCA.kgNOx>(assembly.FormationTroposphericOzone.Value * calculationVolume)
            };



            DA.SetData("LCA Result", result);
        }