Beispiel #1
0
        /*******************************************/

        public int QC_CompareTo(IGH_QuickCast other)
        {
            double a = QC_Num();
            double b = other.QC_Num();

            return(a.CompareTo(b));
        }
Beispiel #2
0
        /*******************************************/

        public double QC_Distance(IGH_QuickCast other)
        {
            Point3d a = QC_Pt();
            Point3d b = other.QC_Pt();

            return(a.DistanceTo(b));
        }
Beispiel #3
0
        static public string readString(GH_Component u, IGH_DataAccess da, int idx, string msg)
        {
            IGH_QuickCast c = null;
            var           r = da.GetData(idx, ref c);

            u.Message = !r ? msg : "";
            return(c?.QC_Text() ?? "");
        }
Beispiel #4
0
        static public float readFloat(GH_Component u, IGH_DataAccess da, int idx, string msg)
        {
            IGH_QuickCast c = null;
            var           r = da.GetData(idx, ref c);

            u.Message = !r ? msg : "";
            return((float)(c?.QC_Num() ?? 0.0));
        }
Beispiel #5
0
        static public Vector3d readVector(GH_Component u, IGH_DataAccess da, int idx, string msg)
        {
            IGH_QuickCast c = null;
            var           r = da.GetData(idx, ref c);

            u.Message = !r ? msg : "";
            return(c?.QC_Vec() ?? Vector3d.Zero);
        }
Beispiel #6
0
        static public Color readColor(GH_Component u, IGH_DataAccess da, int idx, string msg)
        {
            IGH_QuickCast c = null;
            var           r = da.GetData(idx, ref c);

            u.Message = !r ? msg : "";
            return(c?.QC_Col() ?? Color.Gray);
        }
Beispiel #7
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);
            }
        }