Esempio n. 1
0
        /// <summary>
        /// Creates the value list for the motion type and connects it the input parameter is other source is connected
        /// </summary>
        private void CreateValueList()
        {
            // Creates the empty value list
            GH_ValueList obj = new GH_ValueList();

            obj.CreateAttributes();
            obj.ListMode = Grasshopper.Kernel.Special.GH_ValueListMode.DropDown;
            obj.ListItems.Clear();

            // Add the items to the value list
            for (int i = 0; i < SpeedData.ValidPredefinedNames.Length; i++)
            {
                string name  = SpeedData.ValidPredefinedNames[i];
                string value = SpeedData.ValidPredefinedValues[i].ToString();
                obj.ListItems.Add(new GH_ValueListItem(name, value));
            }

            // Make point where the valuelist should be created on the canvas
            obj.Attributes.Pivot = new PointF(this.Attributes.Pivot.X - obj.Attributes.Bounds.Width / 4, this.Attributes.Pivot.Y - obj.Attributes.Bounds.Height / 2);

            // Add the value list to the active canvas
            Instances.ActiveCanvas.Document.AddObject(obj, false);

            // Created
            _created = true;

            // Expire value list
            obj.ExpireSolution(true);
        }
        /// <summary>
        /// Creates the value list for the motion type and connects it the input parameter is other source is connected
        /// </summary>
        private void CreateValueList()
        {
            // Creates the empty value list
            GH_ValueList obj = new GH_ValueList();

            obj.CreateAttributes();
            obj.ListMode = Grasshopper.Kernel.Special.GH_ValueListMode.DropDown;
            obj.ListItems.Clear();

            // Add the items to the value list
            string[] names  = Enum.GetNames(typeof(CodeType));
            int[]    values = (int[])Enum.GetValues(typeof(CodeType));

            for (int i = 0; i < names.Length; i++)
            {
                obj.ListItems.Add(new GH_ValueListItem(names[i], values[i].ToString()));
            }

            // Make point where the valuelist should be created on the canvas
            obj.Attributes.Pivot = new PointF(this.Attributes.Pivot.X - obj.Attributes.Bounds.Width / 4, this.Attributes.Pivot.Y - obj.Attributes.Bounds.Height / 2);

            // Add the value list to the active canvas
            Instances.ActiveCanvas.Document.AddObject(obj, false);

            // Created
            _created = true;

            // Expire value list
            obj.ExpireSolution(true);
        }
Esempio n. 3
0
 // daq - GH_ValueList from Enum
 protected override void BeforeSolveInstance()
 {
     foreach (var unit in EvalUnits)
     {
         foreach (var item in unit.Inputs)
         {
             // Provide the possibility of a drop-down list in case of enumeration inputs:
             if (item.EnumInput != null && item.Parameter.SourceCount == 1 && item.Parameter.Sources[0] is GH_ValueList)
             {
                 GH_ValueList val = item.Parameter.Sources[0] as GH_ValueList;
                 val.ListMode = GH_ValueListMode.DropDown;
                 // We just want to reset the list once!!!
                 if (val.ListItems.Count != item.EnumInput.Count || !(val.ListItems.Select(x => x.Name).SequenceEqual(item.EnumInput)))
                 {
                     var counter = 0;
                     val.ListItems.Clear();
                     foreach (var input in item.EnumInput)
                     {
                         val.ListItems.Add(new GH_ValueListItem(input, counter.ToString()));
                         counter++;
                     }
                     val.ExpireSolution(true);
                 }
             }
         }
     }
 }
Esempio n. 4
0
        // Method for creating the value list with movement types
        #region valuelist
        /// <summary>
        /// Creates the value list for the motion type and connects it the input parameter is other source is connected
        /// </summary>
        private void CreateValueList()
        {
            if (this.Params.Input[2].SourceCount == 0)
            {
                // Gets the input parameter
                var parameter = Params.Input[2];

                // Creates the empty value list
                GH_ValueList obj = new GH_ValueList();
                obj.CreateAttributes();
                obj.ListMode = Grasshopper.Kernel.Special.GH_ValueListMode.DropDown;
                obj.ListItems.Clear();

                // Add the items to the value list
                // Add the items to the value list
                string[] names  = Enum.GetNames(typeof(MovementType));
                int[]    values = (int[])Enum.GetValues(typeof(MovementType));

                for (int i = 0; i < names.Length; i++)
                {
                    obj.ListItems.Add(new GH_ValueListItem(names[i], values[i].ToString()));
                }

                // Make point where the valuelist should be created on the canvas
                obj.Attributes.Pivot = new PointF(parameter.Attributes.InputGrip.X - 120, parameter.Attributes.InputGrip.Y - 11);

                // Add the value list to the active canvas
                Instances.ActiveCanvas.Document.AddObject(obj, false);

                // Connect the value list to the input parameter
                parameter.AddSource(obj);

                // Collect data
                parameter.CollectData();

                // Set bool for expire solution of this component
                _expire = true;

                // First expire the solution of the value list
                obj.ExpireSolution(true);
            }
        }
        // Method for creating the value list with coordinate system types
        #region valuelist
        /// <summary>
        /// Creates the value list for the motion type and connects it the input parameter is other source is connected
        /// </summary>
        private void CreateValueList()
        {
            if (this.Params.Input[1].SourceCount == 0)
            {
                // Gets the input parameter
                var parameter = Params.Input[1];

                // Creates the empty value list
                GH_ValueList obj = new GH_ValueList();
                obj.CreateAttributes();
                obj.ListMode = Grasshopper.Kernel.Special.GH_ValueListMode.DropDown;
                obj.ListItems.Clear();

                // Add the items to the value list
                //obj.ListItems.Add(new GH_ValueListItem("Undefined", "0")); // doesn't return a robtarget
                obj.ListItems.Add(new GH_ValueListItem("World", "1"));
                obj.ListItems.Add(new GH_ValueListItem("Base", "2"));
                //obj.ListItems.Add(new GH_ValueListItem("Tool", "3")); // doesn't return a robtarget
                obj.ListItems.Add(new GH_ValueListItem("Work Object", "4"));

                // Make point where the valuelist should be created on the canvas
                obj.Attributes.Pivot = new PointF(parameter.Attributes.InputGrip.X - 120, parameter.Attributes.InputGrip.Y - 11);

                // Add the value list to the active canvas
                Instances.ActiveCanvas.Document.AddObject(obj, false);

                // Connect the value list to the input parameter
                parameter.AddSource(obj);

                // Collect data
                parameter.CollectData();

                // Set bool for expire solution of this component
                _expire = true;

                // First expire the solution of the value list
                obj.ExpireSolution(true);
            }
        }