/// <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);
        }
Пример #2
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);
        }
Пример #3
0
        private void AddMotion(object sender, EventArgs e)
        {
            AddParam(4);
            var parameter = parameters[4];

            if (Params.Input.Any(x => x.Name == parameter.Name))
            {
                var valueList = new GH_ValueList();
                valueList.CreateAttributes();
                valueList.Attributes.Pivot = new PointF(parameter.Attributes.InputGrip.X - 130, parameter.Attributes.InputGrip.Y - 11);
                valueList.ListItems.Clear();
                valueList.ListItems.Add(new GH_ValueListItem("Joint", "\"Joint\""));
                valueList.ListItems.Add(new GH_ValueListItem("Linear", "\"Linear\""));
                Instances.ActiveCanvas.Document.AddObject(valueList, false);
                parameter.AddSource(valueList);
                parameter.CollectData();
                ExpireSolution(true);
            }
        }
        public static GH_ValueList CreateDropDown(string name, List<string> values, float x, float y)
        {
            var valueList = new GH_ValueList();
              valueList.CreateAttributes();
              valueList.Name = name;
              valueList.NickName = name + ":";
              valueList.Description = "Select an option...";
              valueList.ListMode = GH_ValueListMode.DropDown;
              valueList.ListItems.Clear();

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

              valueList.Attributes.Pivot = new PointF(x - 200, y - 10);

              return valueList;
        }
Пример #5
0
        private IGH_Param CreateTupleValueList(int d)
        {
            //instantiate  new value list
            var valueList = new GH_ValueList();

            valueList.CreateAttributes();
            valueList.ListMode = GH_ValueListMode.Sequence;

            //populate value list with our own data
            valueList.ListItems.Clear();
            for (int i = 0; i < ghGrid.Value.NodeDimCount[d]; i++)
            {
                var val  = "" + i;
                var item = new GH_ValueListItem(val, val);
                valueList.ListItems.Add(item);
            }

            return(valueList);
        }
Пример #6
0
        private IGH_Param CreateNumberValueList(int d)
        {
            //instantiate  new value list
            var valueList = new GH_ValueList();

            valueList.CreateAttributes();
            valueList.ListMode = GH_ValueListMode.Cycle;

            //populate value list with our own data
            valueList.ListItems.Clear();
            for (int i = 0; i < ghGrid.Value.NodeDimCount[d]; i++)
            {
                var val  = String.Format("{0:F3}", ghGrid.Value.Data[d][i]);
                var item = new GH_ValueListItem(val, val);
                valueList.ListItems.Add(item);
            }

            return(valueList);
        }
Пример #7
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);
            }
        }
        protected override void BeforeSolveInstance()
        {
            if (valueList == null)
            {
                if (parameter.Sources.Count == 0)
                {
                    valueList = new GH_ValueList();
                }
                else
                {
                    foreach (var source in parameter.Sources)
                    {
                        if (source is GH_ValueList)
                        {
                            valueList = source as GH_ValueList;
                        }
                        return;
                    }
                }

                valueList.CreateAttributes();
                valueList.Attributes.Pivot = new PointF(this.Attributes.Pivot.X - 200, this.Attributes.Pivot.Y - 1);
                valueList.ListItems.Clear();

                var alignmentNames  = Enum.GetNames(typeof(GlulamData.CrossSectionPosition));
                var alignmentValues = Enum.GetValues(typeof(GlulamData.CrossSectionPosition));

                for (int i = 0; i < alignmentNames.Length; ++i)
                {
                    valueList.ListItems.Add(new GH_ValueListItem(alignmentNames[i], $"{i}"));
                }

                valueList.SelectItem(4);

                Instances.ActiveCanvas.Document.AddObject(valueList, false);
                parameter.AddSource(valueList);
                parameter.CollectData();
            }
        }
Пример #10
0
        ////////////////////////////////////////////////////////////////////////
        // Create a drop down to select supported robot if no robot selected.
        private void RobotOptionList()
        {
            // TODO: check instead if alreeady set.
            // Create robot Option List.
            GH_ValueList robotValueList = new GH_ValueList();

            robotValueList.CreateAttributes();
            robotValueList.Attributes.Pivot = new PointF(this.Attributes.Pivot.X - 300, this.Attributes.Pivot.Y - 41);
            robotValueList.ListItems.Clear();
            robotValueList.NickName = "Robot";
            // Add supported robot names.
            foreach (string robotName in HoloBot.listRobotNames)
            {
                GH_ValueListItem item = new GH_ValueListItem(robotName, "\"" + robotName + "\"");
                robotValueList.ListItems.Add(item);
            }
            // Update grasshopper document.
            GH_Document document = this.OnPingDocument();

            document.AddObject(robotValueList, false);
            this.Params.Input[0].AddSource(robotValueList);
            this.Params.Input[0].CollectData();
        }
Пример #11
0
        protected override void BeforeSolveInstance()
        {
            if (valueList == null)
            {
                if (parameter.Sources.Count == 0)
                {
                    valueList = new GH_ValueList();
                }
                else
                {
                    foreach (var source in parameter.Sources)
                    {
                        if (source is GH_ValueList)
                        {
                            valueList = source as GH_ValueList;
                        }
                        return;
                    }
                }

                valueList.CreateAttributes();
                valueList.Attributes.Pivot = new PointF(this.Attributes.Pivot.X - 200, this.Attributes.Pivot.Y - 1);
                valueList.ListItems.Clear();

                var glulamParameters = Glulam.ListProperties();

                foreach (string param in glulamParameters)
                {
                    valueList.ListItems.Add(new GH_ValueListItem(param, $"\"{param}\""));
                }

                Instances.ActiveCanvas.Document.AddObject(valueList, false);
                parameter.AddSource(valueList);
                parameter.CollectData();
            }
        }
Пример #12
0
        protected override void BeforeSolveInstance()
        {
            if (valueList == null)
            {
                if (parameter.Sources.Count == 0)
                {
                    valueList = new GH_ValueList();
                }
                else
                {
                    foreach (var source in parameter.Sources)
                    {
                        if (source is GH_ValueList)
                        {
                            valueList = source as GH_ValueList;
                        }
                        return;
                    }
                }

                valueList.CreateAttributes();
                valueList.Attributes.Pivot = new PointF(this.Attributes.Pivot.X - 180, this.Attributes.Pivot.Y - 31);
                valueList.ListItems.Clear();

                var robotSystems = RobotSystem.ListRobotSystems();

                foreach (string robotSystemName in robotSystems)
                {
                    valueList.ListItems.Add(new GH_ValueListItem(robotSystemName, $"\"{robotSystemName}\""));
                }

                Instances.ActiveCanvas.Document.AddObject(valueList, false);
                parameter.AddSource(valueList);
                parameter.CollectData();
            }
        }
Пример #13
0
        private void AddMotion(object sender, EventArgs e)
        {
            AddParam(4);
            var parameter = parameters[4];

            if (Params.Input.Any(x => x.Name == parameter.Name))
            {
                var valueList = new GH_ValueList();
                valueList.CreateAttributes();
                valueList.Attributes.Pivot = new PointF(parameter.Attributes.InputGrip.X - 130, parameter.Attributes.InputGrip.Y - 11);
                valueList.ListItems.Clear();
                valueList.ListItems.Add(new GH_ValueListItem("Joint", "\"Joint\""));
                valueList.ListItems.Add(new GH_ValueListItem("Linear", "\"Linear\""));
                Instances.ActiveCanvas.Document.AddObject(valueList, false);
                parameter.AddSource(valueList);
                parameter.CollectData();
                ExpireSolution(true);
            }
        }