Exemplo n.º 1
0
        /// <summary>
        /// Converts a line into a GH_Line
        /// </summary>
        /// <param name="line">The line to convert</param>
        /// <returns>The GH_Line</returns>
        public static GH_Line ConvertToGHLine(Line line)
        {
            GH_Line ghl = new GH_Line();
            bool    c   = GH_Convert.ToGHLine(line, GH_Conversion.Both, ref ghl);

            return(ghl);
        }
        public override bool CastTo <Q>(out Q target)
        {
            // This function is called when Grasshopper needs to convert this
            // instance of GsaElement into some other type Q.


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

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

            //Cast to Curve
            if (typeof(Q).IsAssignableFrom(typeof(Line)))
            {
                if (Value == null)
                {
                    target = default;
                }
                else
                {
                    target = (Q)(object)Value.Line;
                }
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(GH_Line)))
            {
                if (Value == null)
                {
                    target = default;
                }
                else
                {
                    GH_Line ghLine = new GH_Line();
                    GH_Convert.ToGHLine(Value.Line, GH_Conversion.Both, ref ghLine);
                    target = (Q)(object)ghLine;
                }

                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(Curve)))
            {
                if (Value == null)
                {
                    target = default;
                }
                else
                {
                    target = (Q)(object)Value.Line;
                }
                return(true);
            }
            if (typeof(Q).IsAssignableFrom(typeof(GH_Curve)))
            {
                if (Value == null)
                {
                    target = default;
                }
                else
                {
                    target = (Q)(object)new GH_Curve(Value.Line);
                }

                return(true);
            }


            target = default;
            return(false);
        }
Exemplo n.º 3
0
        /*******************************************/

        public static bool CastToGoo(object value, ref GH_Line target)
        {
            return(GH_Convert.ToGHLine(value, GH_Conversion.Both, ref target));
        }