Esempio n. 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //  AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Name: " + RoomName +"\nArea: " + RoomArea);

            //AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, AdjacentRoomsList.Count.ToString());

            GH_Document   GrasshopperDocument = Instances.ActiveCanvas.Document;
            List <String> nms = new List <string>();

            nms.Add("ValueContainer"); //node name
            List <IGH_DocumentObject> valueComp = GrasshopperDocument.FindObjects(nms, 1);

            if (valueComp.Count != 0)
            {
                Guid          instGUID    = valueComp[0].InstanceGuid;
                IGH_Component comp        = GrasshopperDocument.FindComponent(instGUID);
                int           userListLen = comp.Params.Input[0].VolatileData.PathCount;
                for (int i = 0; i < userListLen; i++)
                {
                    var roomIDFromNode = comp.Params.Input[0].VolatileData.get_Branch(i)[0].ToString();

                    if (Convert.ToInt16(roomIDFromNode) == this.RoomId)
                    {
                        var  roomNameFromNode = comp.Params.Input[0].VolatileData.get_Branch(i)[1].ToString();
                        var  roomAreaFromNode = comp.Params.Input[0].VolatileData.get_Branch(i)[2].ToString();
                        bool roomIsEnabled    = Convert.ToBoolean(comp.Params.Input[0].VolatileData.get_Branch(i)[3].ToString());

                        RoomName = roomNameFromNode;
                        RoomArea = Convert.ToDouble(roomAreaFromNode);
                        if (roomIsEnabled == false)
                        {
                            this.Locked = true;
                        }
                        else
                        {
                            this.Locked = false;
                        }
                    }
                }
            }

            DA.SetData(0, RoomName);
        }