// Convert RFEM Object into Rhino Geometry.
        // These methods are later implemented by the class GH_RFEM.
        public bool ToGH_Integer <T>(ref T target)
        {
            object obj = new GH_Integer(No);

            target = (T)obj;
            return(true);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaSection sect = new GsaSection();

            //profile
            GH_String gh_profile = new GH_String();

            if (DA.GetData(0, ref gh_profile))
            {
                if (GH_Convert.ToString(gh_profile, out string profile, GH_Conversion.Both))
                {
                    sect.Section.Profile = profile;

                    // 1 material
                    // to be implemented

                    // 2 pool
                    GH_Integer gh_pool = new GH_Integer();
                    if (DA.GetData(2, ref gh_pool))
                    {
                        if (GH_Convert.ToInt32(gh_pool, out int pool, GH_Conversion.Both))
                        {
                            sect.Section.Pool = pool;
                        }
                    }

                    // 3 ID
                    GH_Integer gh_id = new GH_Integer();
                    if (DA.GetData(3, ref gh_id))
                    {
                        if (GH_Convert.ToInt32(gh_id, out int idd, GH_Conversion.Both))
                        {
                            sect.ID = idd;
                        }
                    }

                    // 4 name
                    GH_String gh_n = new GH_String();
                    if (DA.GetData(4, ref gh_n))
                    {
                        if (GH_Convert.ToString(gh_n, out string name, GH_Conversion.Both))
                        {
                            sect.Section.Name = name;
                        }
                    }

                    // 5 colour
                    GH_Colour gh_Colour = new GH_Colour();
                    if (DA.GetData(5, ref gh_Colour))
                    {
                        if (GH_Convert.ToColor(gh_Colour, out System.Drawing.Color colour, GH_Conversion.Both))
                        {
                            sect.Section.Colour = colour;
                        }
                    }
                }
                DA.SetData(0, new GsaSectionGoo(sect));
            }
        }
Пример #3
0
        ///<summary>
        /// Verify validity of each input set with each error handled w/ separate message
        ///</summary>
        public bool FullErrorCheck(GH_Point pt, GH_Mesh msh, GH_Number tol, GH_Integer step, GH_Vector vec)
        {
            bool flag = true;

            flag = flag && MeshTolVecErrorCheck(msh, tol, vec);
            flag = flag && PointStepErrorCheck(pt, step);
            return(flag);
        }
Пример #4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaMaterial material = new GsaMaterial();

            GH_Integer gh_anal = new GH_Integer();

            if (DA.GetData(0, ref gh_anal))
            {
                int anal = 0;
                GH_Convert.ToInt32(gh_anal, out anal, GH_Conversion.Both);
                material.AnalysisProperty = anal;
            }

            GH_Integer gh_grade = new GH_Integer();

            if (DA.GetData(1, ref gh_grade))
            {
                int grade = 1;
                GH_Convert.ToInt32(gh_grade, out grade, GH_Conversion.Both);
                material.Grade = grade;
            }

            // element type (picked in dropdown)
            if (_mode == FoldMode.Generic)
            {
                material.Type = GsaMaterial.MatType.GENERIC;
            }
            if (_mode == FoldMode.Steel)
            {
                material.Type = GsaMaterial.MatType.STEEL;
            }
            if (_mode == FoldMode.Concrete)
            {
                material.Type = GsaMaterial.MatType.CONCRETE;
            }
            if (_mode == FoldMode.Timber)
            {
                material.Type = GsaMaterial.MatType.TIMBER;
            }
            if (_mode == FoldMode.Aluminium)
            {
                material.Type = GsaMaterial.MatType.ALUMINIUM;
            }
            if (_mode == FoldMode.FRP)
            {
                material.Type = GsaMaterial.MatType.FRP;
            }
            if (_mode == FoldMode.Glass)
            {
                material.Type = GsaMaterial.MatType.GLASS;
            }
            if (_mode == FoldMode.Fabric)
            {
                material.Type = GsaMaterial.MatType.FABRIC;
            }

            DA.SetData(0, new GsaMaterialGoo(material));
        }
Пример #5
0
        public override bool CastTo <Q>(ref Q target)
        {
            // This function is called when Grasshopper needs to convert this
            // instance of GsaSection into some other type Q.


            if (typeof(Q).IsAssignableFrom(typeof(GsaSection)))
            {
                if (Value == null)
                {
                    target = default;
                }
                else
                {
                    target = (Q)(object)Value;
                }
                return(true);
            }

            if (typeof(Q).IsAssignableFrom(typeof(Section)))
            {
                if (Value == null)
                {
                    target = default;
                }
                else
                {
                    target = (Q)(object)Value;
                }
                return(true);
            }

            if (typeof(Q).IsAssignableFrom(typeof(GH_Integer)))
            {
                if (Value == null)
                {
                    target = default;
                }
                else
                {
                    GH_Integer ghint = new GH_Integer();
                    if (GH_Convert.ToGHInteger(Value.ID, GH_Conversion.Both, ref ghint))
                    {
                        target = (Q)(object)ghint;
                    }
                    else
                    {
                        target = default;
                    }
                }
                return(true);
            }

            target = default;
            return(false);
        }
Пример #6
0
        /// <summary>
        /// Compute the closest point and index from the tree using our constructed index.
        /// </summary>
        private (GH_Point[], GH_Integer[]) FindClosePt(GH_Point gpt, GH_Integer gcount, GH_Integer gidx)
        {
            var cloud = pointCloudList[gidx.Value];

            KdTreeNode <double, int>[] results = cloud.GetNearestNeighbours(PtToArray(gpt), gcount.Value);
            var indexList = (from node in results select new GH_Integer(node.Value)).ToArray();
            var pointList = (from node in results select new GH_Point(PtFromArray(node.Point))).ToArray();

            return(pointList, indexList);
        }
Пример #7
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);
        }
Пример #8
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaSection sect       = new GsaSection();
            GsaSection gsaSection = new GsaSection();

            if (DA.GetData(0, ref sect))
            {
                gsaSection = sect.Clone();
            }

            if (gsaSection != null)
            {
                // #### input ####

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

                // 2 profile
                string profile = "";
                if (DA.GetData(2, ref profile))
                {
                    gsaSection.Section.Profile = profile;
                }

                // 3 Material
                GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                if (DA.GetData(3, ref gh_typ))
                {
                    GsaMaterial material = new GsaMaterial();
                    if (gh_typ.Value is GsaMaterialGoo)
                    {
                        gh_typ.CastTo(ref material);
                        gsaSection.Material = material;
                    }
                    else
                    {
                        if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both))
                        {
                            gsaSection.Section.MaterialAnalysisProperty = idd;
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer");
                            return;
                        }
                    }
                }
Пример #9
0
 public GH_Integer[] ToArray(int[][] array)
 {
     GH_Integer[] rA = new GH_Integer[array.Length * array[0].Length];
     Parallel.For(0, array.Length, i =>
     {
         for (int j = 0; j < array[i].Length; j++)
         {
             rA[i * array[i].Length + j] = new GH_Integer(array[i][j]);
         }
     });
     return(rA);
 }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaGravityLoad gravityLoad = new GsaGravityLoad();

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

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

            //element/beam list
            string    beamList = "all";
            GH_String gh_bl    = new GH_String();

            if (DA.GetData(1, ref gh_bl))
            {
                GH_Convert.ToString(gh_bl, out beamList, GH_Conversion.Both);
            }
            gravityLoad.GravityLoad.Elements = beamList;

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

            if (DA.GetData(2, ref gh_name))
            {
                if (GH_Convert.ToString(gh_name, out name, GH_Conversion.Both))
                {
                    gravityLoad.GravityLoad.Name = name;
                }
            }

            //factor
            Vector3   factor    = new Vector3();
            Vector3d  vect      = new Vector3d(0, 0, -1);
            GH_Vector gh_factor = new GH_Vector();

            if (DA.GetData(3, ref gh_factor))
            {
                GH_Convert.ToVector3d(gh_factor, ref vect, GH_Conversion.Both);
            }
            factor.X = vect.X; factor.Y = vect.Y; factor.Z = vect.Z;
            gravityLoad.GravityLoad.Factor = factor;

            GsaLoad gsaLoad = new GsaLoad(gravityLoad);

            DA.SetData(0, new GsaLoadGoo(gsaLoad));
        }
Пример #11
0
 public override bool CastTo <Q>(ref Q target)
 {
     if (typeof(Q).IsAssignableFrom(typeof(GH_Integer)))
     {
         var id = new GH_Integer(Value.Id);
         target = (Q)(object)id;
         return(true);
     }
     else
     {
         return(base.CastTo(ref target));
     }
 }
Пример #12
0
        /*******************************************/

        public static bool CastToGoo(object value, ref IGH_QuickCast target)
        {
            try
            {
                if (value is bool)
                {
                    target = new GH_Boolean((bool)value);
                }
                else if (value is Color)
                {
                    target = new GH_Colour((Color)value);
                }
                else if (value is Complex)
                {
                    target = new GH_ComplexNumber((Complex)value);
                }
                else if (value is int)
                {
                    target = new GH_Integer((int)value);
                }
                else if (value is Interval)
                {
                    target = new GH_Interval((Interval)value);
                }
                else if (value is Matrix)
                {
                    target = new GH_Matrix((Matrix)value);
                }
                else if (value is double || value is float)
                {
                    target = new GH_Number((double)value);
                }
                else if (value is Point3d)
                {
                    target = new GH_Point((Point3d)value);
                }
                else if (value is string)
                {
                    target = new GH_String(value.ToString());
                }
                else if (value is Vector3d)
                {
                    target = new GH_Vector((Vector3d)value);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and 
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Box box = null;
            if (!DA.GetData(0, ref box)) return;

            GH_Integer nx = null;
            if (!DA.GetData(1, ref nx)) return;

            GH_Integer ny = null;
            if (!DA.GetData(2, ref ny)) return;

            GH_Integer nz = null;
            DA.GetData(3, ref nz);

            List<GH_Number> vals = new List<GH_Number>();
            DA.GetDataList(4, vals);

            if (nz == null)
            {
                var d = box.Value.BoundingBox.ToInterval2d();
                var f = new GridScalarField2d(d, nx.Value, ny.Value, _wrapX, _wrapY, _sample);

                // set values
                if (vals != null)
                {
                    if (vals.Count == 1)
                        f.Set(vals[0].Value);
                    else
                        f.Set(vals.Select(x => x.Value));
                }

                DA.SetData(0, new GH_ObjectWrapper(f));
            }
            else
            {
                var d = box.Value.BoundingBox.ToInterval3d();
                var f = new GridScalarField3d(d, nx.Value, ny.Value, nz.Value, _wrapX, _wrapY, _wrapZ, _sample);

                // set values
                if (vals != null)
                {
                    if (vals.Count == 1)
                        f.Set(vals[0].Value);
                    else
                        f.Set(vals.Select(x => x.Value));
                }

                DA.SetData(0, new GH_ObjectWrapper(f));
            }
        }
Пример #14
0
        public override Boolean Equals(Object that)
        {
            if (that == null)
            {
                return(false);
            }
            if (that.GetType() != this.GetType())
            {
                return(false);
            }

            //FIXME: use a reflection to get the Value property of the GH_Goo
            //if a value property is missing, it seems that we could not compare Goos (or different method should be used)

            // GH_Goo.Equals(GH_Goo) compare the GUIDs which are different in the common case
            // that's why we need to compare GH_Goo inner values
            // unfortunately the Value property is not generic for GH_Goo
            // only some GH_Goo have value assigned
            GH_CellState thatState = (GH_CellState)that;

            if (value.GetType() == GH_TypeLib.t_gh_colour)
            {
                GH_Colour thisGH_Colour = (GH_Colour)value;
                GH_Colour thatGH_Colour = (GH_Colour)thatState.value;

                return(thisGH_Colour.Value.Equals(thatGH_Colour.Value));
            }
            else if (value.GetType() == GH_TypeLib.t_gh_bool)
            {
                GH_Boolean thisGH_Boolean = (GH_Boolean)this.value;
                GH_Boolean thatGH_Boolean = (GH_Boolean)thatState.value;
                return(thisGH_Boolean.Value.Equals(thatGH_Boolean.Value));
            }
            else if (value.GetType() == GH_TypeLib.t_gh_int)
            {
                GH_Integer thisGH_Integer = (GH_Integer)this.value;
                GH_Integer thatGH_Integer = (GH_Integer)thatState.value;
                return(thisGH_Integer.Value.Equals(thatGH_Integer.Value));
            }
            else if (value.GetType() == GH_TypeLib.t_gh_string)
            {
                GH_String thisGH_String = (GH_String)this.value;
                GH_String thatGH_String = (GH_String)thatState.value;
                return(thisGH_String.Value.Equals(thatGH_String.Value));
            }

            throw new NotSupportedException("Could not compare GH_Goo type: " + value.GetType());
        }
Пример #15
0
        public override bool CastTo <Q>(ref Q target)
        {
            if (typeof(Q).IsAssignableFrom(typeof(int)))
            {
                object _Index = this.Value.Index;
                target = (Q)_Index;
                return(true);
            }

            if (typeof(Q).IsAssignableFrom(typeof(GH_Integer)))
            {
                object _Index = new GH_Integer(this.Value.Index);
                target = (Q)_Index;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(Guid)))
            {
                object _Id = this.Value.Id;
                target = (Q)_Id;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(GH_Guid)))
            {
                object _Id = new GH_Guid(this.Value.Id);
                target = (Q)_Id;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(GH_String)))
            {
                object _Path = new GH_String(this.Value.FullPath);
                target = (Q)_Path;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(string)))
            {
                object _Path = this.Value.FullPath;
                target = (Q)_Path;
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(Layer)))
            {
                LayerTable LT     = Rhino.RhinoDoc.ActiveDoc.Layers;
                object     _layer = LT.FindIndex(this.Value.Index);
                target = (Q)_layer;
                return(true);
            }
            return(false);
        }
Пример #16
0
        private bool PointStepErrorCheck(GH_Point pt, GH_Integer step)
        {
            bool flag = true;

            if (pt == null || step == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Null Input! Skipping branch.");
                return(false);
            }
            if (step.Value < 2)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Too few steps! Skipping branch.");
                flag = false;
            }
            return(flag);
        }
Пример #17
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Integer i1 = new GH_Integer();                    /// layerWidth
            GH_Integer i2 = new GH_Integer();                    /// layerHeight

            if (!DA.GetData(0, ref i1))
            {
                return;
            }
            if (!DA.GetData(1, ref i2))
            {
                return;
            }
            if (!DA.GetData(2, ref isCircularRows))
            {
                return;
            }
            if (!DA.GetData(3, ref isCircularColumns))
            {
                return;
            }
            if (!DA.GetData(4, ref latticeTopology))
            {
                return;
            }
            if (!DA.GetData(5, ref neighborhood))
            {
                return;
            }
            if (!DA.GetData(6, ref neighborDistance))
            {
                return;
            }
            if (!DA.GetData(7, ref learningRate))
            {
                return;
            }


            i1.CastTo <int>(out layerWidth);
            i2.CastTo <int>(out layerHeight);

            CrowNetSOM2DUP NetUP = new CrowNetSOM2DUP("som", layerWidth, layerHeight, isCircularRows, isCircularColumns, latticeTopology, neighborhood, neighborDistance, learningRate);

            DA.SetData(0, NetUP);
        }
Пример #18
0
 //
 // Compare two structures for equality.
 //
 internal bool isStructureTheSame(IGH_Structure struct1, IGH_Structure struct2)
 {
     // m_owner.attr.Panel.Message(m_owner.NickName + ": Compare:");
     if (struct1 == null ^ struct2 == null)
     {
         //m_owner.attr.Panel.Message("    One of the structures is null");
         return(false);
     }
     if (struct1.IsEmpty ^ struct2.IsEmpty)
     {
         //m_owner.attr.Panel.Message("    One of the structures is empty");
         return(false);
     }
     if (struct1 != null && struct2 != null)
     {
         int pc = Math.Min(struct1.Paths.Count, struct2.Paths.Count);
         for (int i = 0; i < pc; i++)
         {
             IList b1 = struct1.get_Branch(struct1.Paths[i]);
             IList b2 = struct2.get_Branch(struct2.Paths[i]);
             int   bc = Math.Min(b1.Count, b2.Count);
             for (int j = 0; j < bc; j++)
             {
                 if (b1[j] is GH_Integer && b2[j] is GH_Integer)
                 {
                     GH_Integer n1 = (GH_Integer)b1[j];
                     GH_Integer n2 = (GH_Integer)b2[j];
                     if (n1.Value != n2.Value)
                     {
                         return(false);
                     }
                 }
                 else if (b1[j] is GH_Number && b2[j] is GH_Number)
                 {
                     GH_Number n1 = (GH_Number)b1[j];
                     GH_Number n2 = (GH_Number)b2[j];
                     if (Math.Round(n1.Value, 8) != Math.Round(n2.Value, 8))
                     {
                         return(false);
                     }
                 }
             }
         }
     }
     return(true);
 }
Пример #19
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaProp2d gsaProp2d = new GsaProp2d();
            GsaProp2d prop      = new GsaProp2d();

            if (DA.GetData(0, ref gsaProp2d))
            {
                prop = gsaProp2d.Clone();
            }

            // #### inputs ####
            // 1 ID
            GH_Integer ghID = new GH_Integer();

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

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

            if (DA.GetData(2, ref gh_typ))
            {
                GsaMaterial material = new GsaMaterial();
                if (gh_typ.Value is GsaMaterialGoo)
                {
                    gh_typ.CastTo(ref material);
                    prop.Material = material;
                }
                else
                {
                    if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both))
                    {
                        prop.Prop2d.MaterialAnalysisProperty = idd;
                    }
                    else
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer");
                        return;
                    }
                }
Пример #20
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            int n = 0;

            if (!DA.GetData(0, ref n))
            {
                return;
            }

            GH_Integer[] indexes = new GH_Integer[n];

            for (int j = 0; j < n; j++)
            {
                indexes[j] = new GH_Integer(j);
            }

            DA.SetDataList(0, indexes);
        }
Пример #21
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <IGH_Goo> data = new List <IGH_Goo>();

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

            GH_Integer[] indexes = new GH_Integer[data.Count];

            for (int j = 0; j < data.Count; j++)
            {
                indexes[j] = new GH_Integer(j);
            }

            DA.SetDataList(0, indexes);
        }
Пример #22
0
 public bool CastTo <T>(out T target)
 {
     if (typeof(T) == typeof(int))
     {
         target = (T)Convert.ChangeType(Index, typeof(int));
         return(true);
     }
     if (typeof(T) == typeof(double))
     {
         target = (T)Convert.ChangeType(Index, typeof(double));
         return(true);
     }
     if (typeof(T) == typeof(string))
     {
         var s = Index.ToString();
         target = (T)s.Clone();
         return(true);
     }
     if (typeof(T) == typeof(GH_Integer))
     {
         var index   = (int)Index;
         var gHIndex = new GH_Integer(index);
         target = (T)gHIndex.Duplicate();
         return(true);
     }
     if (typeof(T) == typeof(GH_Number))
     {
         var index   = (double)Index;
         var gHIndex = new GH_Number(index);
         target = (T)gHIndex.Duplicate();
         return(true);
     }
     if (typeof(T) == typeof(GH_String))
     {
         var s        = Index.ToString();
         var ghString = new GH_String(s);
         target = (T)ghString.Duplicate();
         return(true);
     }
     target = default;
     return(false);
 }
Пример #23
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Integer id = new GH_Integer();

            DA.GetData<GH_Integer>("ID", ref id);

            ElementID emid = new ElementID();
            emid.ID = id.Value;


            DA.SetData("ElementID", emid);
        }
Пример #24
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool hasTarget   = Params.Input.Any(x => x.Name == "Target");
            bool hasJoints   = Params.Input.Any(x => x.Name == "Joints");
            bool hasPlane    = Params.Input.Any(x => x.Name == "Plane");
            bool hasConfig   = Params.Input.Any(x => x.Name == "RobConf");
            bool hasMotion   = Params.Input.Any(x => x.Name == "Motion");
            bool hasTool     = Params.Input.Any(x => x.Name == "Tool");
            bool hasSpeed    = Params.Input.Any(x => x.Name == "Speed");
            bool hasZone     = Params.Input.Any(x => x.Name == "Zone");
            bool hasCommand  = Params.Input.Any(x => x.Name == "Command");
            bool hasFrame    = Params.Input.Any(x => x.Name == "Frame");
            bool hasExternal = Params.Input.Any(x => x.Name == "External");

            GH_Target sourceTarget = null;

            if (hasTarget)
            {
                if (!DA.GetData("Target", ref sourceTarget))
                {
                    return;
                }
            }

            double[] joints = null;
            var      plane  = new Plane();

            Target.RobotConfigurations?configuration = null;
            Target.Motions             motion        = Target.Motions.Joint;
            Tool    tool    = null;
            Speed   speed   = null;
            Zone    zone    = null;
            Command command = null;
            Frame   frame   = null;

            double[] external = null;

            if (hasJoints)
            {
                GH_String jointsGH = null;
                if (!DA.GetData("Joints", ref jointsGH))
                {
                    return;
                }

                string[] jointsText = jointsGH.Value.Split(',');
                if (jointsText.Length != 6)
                {
                    return;
                }

                joints = new double[6];

                for (int i = 0; i < 6; i++)
                {
                    if (!GH_Convert.ToDouble_Secondary(jointsText[i], ref joints[i]))
                    {
                        return;
                    }
                }
            }
            else if (sourceTarget != null)
            {
                if (sourceTarget.Value is JointTarget)
                {
                    joints = (sourceTarget.Value as JointTarget).Joints;
                }
            }

            if (hasPlane)
            {
                GH_Plane planeGH = null;
                if (hasPlane)
                {
                    if (!DA.GetData("Plane", ref planeGH))
                    {
                        return;
                    }
                }
                plane = planeGH.Value;
            }
            else if (sourceTarget != null)
            {
                if (sourceTarget.Value is CartesianTarget)
                {
                    plane = (sourceTarget.Value as CartesianTarget).Plane;
                }
            }

            if (hasConfig)
            {
                GH_Integer configGH = null;
                if (hasConfig)
                {
                    DA.GetData("RobConf", ref configGH);
                }
                configuration = (configGH == null) ? null : (Target.RobotConfigurations?)configGH.Value;
            }
            else if (sourceTarget != null)
            {
                if (sourceTarget.Value is CartesianTarget)
                {
                    configuration = (sourceTarget.Value as CartesianTarget).Configuration;
                }
            }

            if (hasMotion)
            {
                GH_String motionGH = null;
                DA.GetData("Motion", ref motionGH);
                motion = (motionGH == null) ? Target.Motions.Joint : (Target.Motions)Enum.Parse(typeof(Target.Motions), motionGH.Value);
            }
            else if (sourceTarget != null)
            {
                if (sourceTarget.Value is CartesianTarget)
                {
                    motion = (sourceTarget.Value as CartesianTarget).Motion;
                }
            }

            if (hasTool)
            {
                GH_Tool toolGH = null;
                DA.GetData("Tool", ref toolGH);
                tool = toolGH?.Value;
            }
            else if (sourceTarget != null)
            {
                tool = sourceTarget.Value.Tool;
            }

            if (hasSpeed)
            {
                GH_Speed speedGH = null;
                DA.GetData("Speed", ref speedGH);
                speed = speedGH?.Value;
            }
            else if (sourceTarget != null)
            {
                speed = sourceTarget.Value.Speed;
            }

            if (hasZone)
            {
                GH_Zone zoneGH = null;
                DA.GetData("Zone", ref zoneGH);
                zone = zoneGH?.Value;
            }
            else if (sourceTarget != null)
            {
                zone = sourceTarget.Value.Zone;
            }

            if (hasCommand)
            {
                GH_Command commandGH = null;
                DA.GetData("Command", ref commandGH);
                command = commandGH?.Value;
            }
            else if (sourceTarget != null)
            {
                command = sourceTarget.Value.Command;
            }

            if (hasFrame)
            {
                GH_Frame frameGH = null;
                DA.GetData("Frame", ref frameGH);
                frame = frameGH?.Value;
            }
            else if (sourceTarget != null)
            {
                frame = sourceTarget.Value.Frame;
            }

            if (hasExternal)
            {
                GH_String externalGH = null;
                if (!DA.GetData("External", ref externalGH))
                {
                    external = new double[0];
                }
                else
                {
                    string[] externalText = externalGH.Value.Split(',');
                    int      length       = externalText.Length;
                    external = new double[length];
                    for (int i = 0; i < length; i++)
                    {
                        if (!GH_Convert.ToDouble_Secondary(externalText[i], ref external[i]))
                        {
                            return;
                        }
                    }
                }
            }
            else if (sourceTarget != null)
            {
                external = sourceTarget.Value.External;
            }

            Target target;

            bool localCartesian = isCartesian;

            if (hasTarget && !hasPlane && !hasJoints)
            {
                localCartesian = sourceTarget.Value is CartesianTarget;
            }

            if (localCartesian)
            {
                target = new CartesianTarget(plane, configuration, motion, tool, speed, zone, command, frame, external);
            }
            else
            {
                target = new JointTarget(joints, tool, speed, zone, command, frame, external);
            }

            if (sourceTarget != null)
            {
                target.ExternalCustom = sourceTarget.Value.ExternalCustom;
            }

            DA.SetData(0, new GH_Target(target));
        }
Пример #25
0
        SolveResults Compute(string fileLoc, List <Color> colors, int tskId)
        {
            var  rc           = new SolveResults();
            bool filterColors = colors.Any();

            List <GH_Colour>        topCols     = new List <GH_Colour>();
            List <GH_Integer>       colCount    = new List <GH_Integer>();
            GH_Structure <GH_Point> colLocation = new GH_Structure <GH_Point>();


            try
            {
                using (Bitmap bitmap = new Bitmap(fileLoc))
                {
                    GH_Integer pixCount = new GH_Integer();
                    GH_Convert.ToGHInteger(bitmap.Height * bitmap.Width, 0, ref pixCount);
                    rc.PixCount = pixCount;

                    ///https://www.grasshopper3d.com/forum/topics/unsafe?page=1&commentId=2985220%3AComment%3A808291&x=1#2985220Comment808291
                    GH_MemoryBitmap sampler = new GH_MemoryBitmap(bitmap);

                    Color col = Color.Transparent;
                    for (int x = 0; x < bitmap.Width; x++)
                    {
                        for (int y = 0; y < bitmap.Height; y++)
                        {
                            ///GH_MemoryBitmap Sample is faster than GetPixel
                            //col = bitmap.GetPixel(x, y);
                            if (sampler.Sample(x, y, ref col))
                            {
                                if (colors.Contains(col))
                                {
                                    GH_Path path = new GH_Path(tskId, colors.IndexOf(col));
                                    colLocation.Append(new GH_Point(new Point3d(x, y, 0)), path);
                                }
                                else if (!filterColors)
                                {
                                    colors.Add(col);
                                    GH_Path path = new GH_Path(tskId, colors.IndexOf(col));
                                    colLocation.Append(new GH_Point(new Point3d(x, y, 0)), path);
                                }
                            }
                        }
                    }

                    sampler.Release(false);
                    bitmap.Dispose();
                }
            }

            catch
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Could not load image from file path: " + fileLoc);
            }

            List <GH_Colour> ghColors = new List <GH_Colour>();

            foreach (var c in colors)
            {
                ghColors.Add(new GH_Colour(c));
            }

            rc.TopColors     = ghColors;
            rc.ColorLocation = colLocation;

            return(rc);
        }
Пример #26
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)
        {
            IGH_Goo trailData   = null;
            IGH_Goo colorData   = null;
            bool    texture     = new bool();
            object  displayMode = null;

            VisualData visualData = new VisualData();

            if (!DA.GetData(0, ref trailData) || trailData == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Trail Data Detected, please connect Trail Data to enable the component");
                return;
            }
            DA.GetData(1, ref colorData);
            string dataType = trailData.GetType().Name.ToString();

            if (trailData.ToString() == "Culebra_GH.Data_Structures.TrailData")
            {
                TrailData td;
                bool      worked = trailData.CastTo(out td);
                if (worked)
                {
                    visualData.trailData = td;
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Could not convert trail data, ensure you have the correct inputs");
                    return;
                }
            }
            else
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please input Trail Data Output value for Trail Data not a " + dataType);
                return;
            }
            if (colorData != null)
            {
                string colorType = colorData.GetType().Name.ToString();
                if (colorData.ToString() == "Culebra_GH.Data_Structures.ColorData")
                {
                    ColorData cd;
                    bool      worked = colorData.CastTo(out cd);
                    if (worked)
                    {
                        visualData.colorData = cd;
                    }
                    else
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Could not convert color data, ensure you have the correct inputs");
                        return;
                    }
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please input Trail Data Output value for Trail Data not a " + colorType);
                    return;
                }
            }
            else
            {
                ColorData color = new ColorData();
                color.colorDataType  = "Base";
                visualData.colorData = color;
            }
            if (!DA.GetData(2, ref texture))
            {
                return;
            }
            if (texture)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "WARNING USING TEXTURE CAN MAKE THE SIMULATION VERY UNSTABLE AND MAY CRASH WITHOUT WARNING, I RECOMMEND USING THE GH BUILT IN CLOUD DISPLAY FOR THE CREEPERS OUTPUT");
            }
            visualData.useTexture = texture;

            if (!DA.GetData(3, ref displayMode))
            {
                return;
            }
            string type2 = displayMode.GetType().Name.ToString();

            if (displayMode.GetType() != typeof(GH_Integer) && displayMode.GetType() != typeof(GH_Number))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please input a integer/float value for Display Mode not a " + type2);
                return;
            }
            else
            {
                if (displayMode.GetType() == typeof(GH_Integer))
                {
                    GH_Integer ghInt = (GH_Integer)displayMode;
                    visualData.displayMode = ghInt.Value;
                }
                else
                {
                    GH_Number ghNum = (GH_Number)displayMode;
                    visualData.displayMode = Convert.ToInt32(ghNum.Value);
                }
            }
            IGH_VisualData igh_Viz = new IGH_VisualData(visualData);

            DA.SetData(0, igh_Viz);
        }
Пример #27
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;
                }
            }
        }
Пример #28
0
 /// <summary>
 /// Data constructor: Creates a Zone Data Goo instance from an Integer Goo instance.
 /// This result a Predefined Zone Data Value.
 /// </summary>
 /// <param name="zone"> The size (the radius) of the TCP zone in mm. </param>
 public GH_ZoneData(GH_Integer zone)
 {
     this.Value = new ZoneData(zone.Value);
 }
Пример #29
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GsaMember1d gsaMember1d = new GsaMember1d();

            if (DA.GetData(0, ref gsaMember1d))
            {
                if (gsaMember1d == null)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Member1D input is null");
                }
                GsaMember1d mem = gsaMember1d.Duplicate();

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

                // 2 curve
                GH_Curve ghcrv = new GH_Curve();
                if (DA.GetData(2, ref ghcrv))
                {
                    Curve crv = null;
                    if (GH_Convert.ToCurve(ghcrv, ref crv, GH_Conversion.Both))
                    {
                        GsaMember1d tempmem = new GsaMember1d(crv);
                        mem.PolyCurve    = tempmem.PolyCurve;
                        mem.Topology     = tempmem.Topology;
                        mem.TopologyType = tempmem.TopologyType;
                    }
                }

                // 3 section
                GH_ObjectWrapper gh_typ = new GH_ObjectWrapper();
                if (DA.GetData(3, ref gh_typ))
                {
                    GsaSection section = new GsaSection();
                    if (gh_typ.Value is GsaSectionGoo)
                    {
                        gh_typ.CastTo(ref section);
                        mem.Section         = section;
                        mem.Member.Property = 0;
                    }
                    else
                    {
                        if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both))
                        {
                            mem.Member.Property = idd;
                            mem.Section         = null;
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer");
                            return;
                        }
                    }
                }
Пример #30
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);
        }
Пример #31
0
        /// <inheritdoc />
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Box box = null;

            if (!DA.GetData(0, ref box))
            {
                return;
            }

            GH_Integer nx = null;

            if (!DA.GetData(1, ref nx))
            {
                return;
            }

            GH_Integer ny = null;

            if (!DA.GetData(2, ref ny))
            {
                return;
            }

            GH_Integer nz = null;

            DA.GetData(3, ref nz);

            switch (_type)
            {
            case FieldType.Scalar:
            {
                if (nz == null)
                {
                    InitScalar(DA, nx.Value, ny.Value, box.Value.BoundingBox.ToInterval2d());
                }
                else
                {
                    InitScalar(DA, nx.Value, ny.Value, nz.Value, box.Value.BoundingBox.ToInterval3d());
                }
                break;
            }

            case FieldType.Vector:
            {
                if (nz == null)
                {
                    InitVector(DA, nx.Value, ny.Value, box.Value.BoundingBox.ToInterval2d());
                }
                else
                {
                    InitVector(DA, nx.Value, ny.Value, nz.Value, box.Value.BoundingBox.ToInterval3d());
                }
                break;
            }

            default:
            {
                throw new ArgumentException("The specified field type is not supported.");
            }
            }
        }
Пример #32
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String name = new GH_String("");
            GH_String view = new GH_String("");
            List<Rule> rules = new List<Rule>();
            List<GH_String> cats = new List<GH_String>();
            List<string> categories = new List<string>();

            GH_Colour CutFillColor = null;
            GH_Colour CutLineColor = null;
            GH_Colour ProjectionFillColor = null;
            GH_Colour ProjectionLineColor = null;
            GH_Integer CutLineWeight = new GH_Integer(-1);
            GH_Integer ProjectionLineWeight = new GH_Integer(-1);
            GH_String CutFillPattern = null;
            GH_String CutLinePattern = null;
            GH_String ProjectionFillPattern = null;
            GH_String ProjectionLinePattern = null;

            DA.GetData<GH_Colour>("CutFillColor", ref CutFillColor);
            DA.GetData<GH_Colour>("CutLineColor", ref CutLineColor);
            DA.GetData<GH_Colour>("ProjectionFillColor", ref ProjectionFillColor);
            DA.GetData<GH_Colour>("ProjectionLineColor", ref ProjectionLineColor);
            DA.GetData<GH_Integer>("CutLineWeight", ref CutLineWeight);
            DA.GetData<GH_Integer>("ProjectionLineWeight", ref ProjectionLineWeight);
            DA.GetData<GH_String>("CutFillPattern", ref CutFillPattern);
            DA.GetData<GH_String>("CutLinePattern", ref CutLinePattern);
            DA.GetData<GH_String>("ProjectionFillPattern", ref ProjectionFillPattern);
            DA.GetData<GH_String>("ProjectionLinePattern", ref ProjectionLinePattern);

            DA.GetData<GH_String>("Name", ref name);
            DA.GetData<GH_String>("View", ref view);
            DA.GetDataList<Rule>("Rules",rules);
            DA.GetDataList<GH_String>("Categories",cats);

            foreach (GH_String cat in cats) categories.Add(cat.Value);

            Grevit.Types.Filter filter = new Filter()
            {
                name = name.Value,
                view = view.Value,
                categories = categories,
                Rules = rules
            };
            

            if (CutFillColor != null) filter.CutFillColor = CutFillColor.ToGrevitColor();
            if (CutLineColor != null) filter.CutLineColor = CutLineColor.ToGrevitColor();
            if (ProjectionFillColor != null) filter.ProjectionFillColor = ProjectionFillColor.ToGrevitColor();
            if (ProjectionLineColor != null) filter.ProjectionLineColor = ProjectionLineColor.ToGrevitColor();

            filter.CutLineWeight = CutLineWeight.Value;
            filter.ProjectionLineWeight = ProjectionLineWeight.Value;

            if (CutFillPattern != null) filter.CutFillPattern = CutFillPattern.Value;
            if (CutLinePattern != null) filter.CutLinePattern = CutLinePattern.Value;
            if (ProjectionFillPattern != null) filter.ProjectionFillPattern = ProjectionFillPattern.Value;
            if (ProjectionLinePattern != null) filter.ProjectionLinePattern = ProjectionLinePattern.Value;

            

            DA.SetData("GrevitComponent", filter);
        }
        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;
                }
            }
        }
Пример #34
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_String panelname = new GH_String("");
            GH_Integer id = new GH_Integer(0);
            DA.GetData<GH_Integer>("PanelID",ref id);
            DA.GetData<GH_String>("PanelType",ref panelname);
            List<Parameter> param = new List<Parameter>();
            if (!DA.GetDataList<Parameter>("Parameters", param)) param = new List<Parameter>();

            Grevit.Types.SetCurtainPanel scp = new SetCurtainPanel();
            scp.panelID = id.Value;
            scp.panelType = panelname.Value;
            scp.parameters = param;
            //scp.GID = this.InstanceGuid.ToString();
            DA.SetData("GrevitComponent", scp);
        }