Exemple #1
0
        //this updates the data to the obj of this instance
        private void UpdateData(IGH_DataAccess DA)
        {
            Dictionary <string, List <IGH_Goo> > dataDict = new Dictionary <string, List <IGH_Goo> >();

            for (int i = 0; i < Params.Input.Count; i++)
            {
                List <IGH_Goo> obj_in = new List <IGH_Goo>();//this is for before you decide the type
                if (!DA.GetDataList(i, obj_in))
                {
                    return;
                }
                //here check if all data are of same type within the list of this param
                if (!validDatatypes(obj_in))
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "All data in an object member should be of the same type!");
                    return;
                }

                MemberInput param = (MemberInput)Params.Input[i];
                param.HasGeometry = typeof(IGH_GeometricGoo).IsAssignableFrom(obj_in[0].GetType());

                dataDict.Add(Params.Input[i].NickName, obj_in);
            }

            this.obj = new GeomObject(this.NickName, dataDict);
            updateSettings();
            //Rhino.RhinoApp.WriteLine(this.obj.dataCount.ToString());
        }
Exemple #2
0
        /// This is the method that actually does the work.
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GeomObjGoo objGoo = new GeomObjGoo();

            if (!DA.GetData(0, ref objGoo))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No Object received");
                return;
            }

            this.obj = objGoo.Value.Duplicate();
            if (obj.MemberDict.Count == 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The Object is empty");
                return;
            }
            //making a copy of the object in case mutation fails
            GeomObject obj_original = obj.Duplicate();

            MemberSelect param0 = Params.Input[0] as MemberSelect;

            param0.Update(obj);

            //now mutating the object
            List <IGH_Goo> obj_in = new List <IGH_Goo>();

            if (!DA.GetDataList(1, obj_in))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "The member was not replaced: No replacement received");
                DA.SetData(0, new GeomObjGoo(obj_original));
                return;
            }
            //Debug.WriteLine(obj_in[0] == null);
            //here check if all data are of same type within the list of this param
            if (!ObjectifyComponent.validDatatypes(obj_in))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "All data in an object member should be of the same type!");
                return;
            }

            MemberInput param1 = Params.Input[1] as MemberInput;

            param1.HasGeometry = typeof(IGH_GeometricGoo).IsAssignableFrom(obj_in[0].GetType());
            if (!obj.MemberDict.ContainsKey(param0.NickName))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The object does not have a member with this name !");
                return;
            }

            //deleting the old member
            obj.MemberDict.Remove(param0.NickName);
            obj.MemberDict.Add(param0.NickName, obj_in);

            //now updating the visibility and bakability settings
            this.obj.Visibility[param0.NickName] = param1.Settings["Visible"];
            this.obj.Bakability[param0.NickName] = param1.Settings["Bakable"];

            DA.SetData(0, new GeomObjGoo(obj));
        }
Exemple #3
0
        //The parameter returned by this func is what is added to the component when user creates a component
        public IGH_Param CreateParameter(GH_ParameterSide side, int index)
        {
            int paramNum = Params.Input.Count + 1;
            //memberInput param = newParam("Label_" + paramNum, index);
            MemberInput param = new MemberInput("Label_" + paramNum);

            return(param);
        }
Exemple #4
0
        /// Registers all the input parameters for this component.
        protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
        {
            MemberInput param = new MemberInput("Label_1");

            //pManager.AddParameter(, "Label", "L1", "This is the descriptions", GH_ParamAccess.list);
            pManager.AddParameter(param);
            //pManager.AddGenericParameter("", "Label_1", "", GH_ParamAccess.list);
        }
Exemple #5
0
 //update settings
 private void updateSettings()
 {
     this.obj.Bakability.Clear();
     this.obj.Visibility.Clear();
     for (int i = 0; i < Params.Input.Count; i++)
     {
         MemberInput param = Params.Input[i] as MemberInput;
         this.obj.Bakability.Add(param.NickName, param.Settings["Bakable"]);
         this.obj.Visibility.Add(param.NickName, param.Settings["Visible"]);
     }
 }
Exemple #6
0
        /// Registers all the input parameters for this component.
        protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
        {
            MemberSelect objToMutate = new MemberSelect("O");

            objToMutate.Optional = true;
            pManager.AddParameter(objToMutate, "", "", "Object - Member to Mutate", GH_ParamAccess.item);

            MemberInput newMember = new MemberInput("R");

            newMember.Name            = "New Member Value";
            newMember.Description     = "Replacement Value for the member in the parameter above";
            newMember.MutableNickName = false;
            pManager.AddParameter(newMember);
        }