Esempio n. 1
0
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            // grab input family instance
            DB.FamilyInstance famInst = default;
            if (!DA.GetData("Family Instance", ref famInst))
            {
                return;
            }

            // grab input phase if provided
            DB.Phase phase = default;
            DA.GetData("Phase", ref phase);

            if (phase is null)
            {
                DA.SetData("FromRoom", famInst.FromRoom);
                DA.SetData("ToRoom", famInst.ToRoom);
                DA.SetData("Room", famInst.Room);
                DA.SetData("Space", famInst.Space);
            }
            else
            {
                DA.SetData("FromRoom", famInst.get_FromRoom(phase));
                DA.SetData("ToRoom", famInst.get_ToRoom(phase));
                DA.SetData("Room", famInst.get_Room(phase));
                DA.SetData("Space", famInst.get_Space(phase));
            }
        }
Esempio n. 2
0
        public static Dictionary <string, Room> FromAndToRooms(Revit.Elements.FamilyInstance familyInstance, Revit.Elements.Element phase)
        {
            Autodesk.Revit.DB.FamilyInstance uwFi    = familyInstance.InternalElement as Autodesk.Revit.DB.FamilyInstance;
            Autodesk.Revit.DB.Phase          uwPhase = phase.InternalElement as Phase;

            Room fromRoom = null;
            Room toRoom   = null;

            var tempFromRoom = uwFi.get_FromRoom(uwPhase);
            var tempToRoom   = uwFi.get_ToRoom(uwPhase);

            if (tempFromRoom != null)
            {
                fromRoom = tempFromRoom.ToDSType(true) as Room;
            }

            if (tempToRoom != null)
            {
                toRoom = tempToRoom.ToDSType(true) as Room;
            }


            var returnDict = new Dictionary <string, Room>
            {
                { "FromRoom", fromRoom },
                { "ToRoom", toRoom },
            };

            return(returnDict);
        }
Esempio n. 3
0
        public static Dictionary <string, List <Revit.Elements.Element> > GetToFromRoom(List <Revit.Elements.Element> FamilyInstance, Revit.Elements.Element Phase)
        {
            List <Revit.Elements.Element> toRooms   = new List <Revit.Elements.Element>();
            List <Revit.Elements.Element> fromRooms = new List <Revit.Elements.Element>();
            ElementId phaseId = Spring.Elements.UnwrapElement(Phase);

            try
            {
                Autodesk.Revit.DB.Phase phase = DocumentManager.Instance.CurrentDBDocument.GetElement(phaseId) as Autodesk.Revit.DB.Phase;
                try
                {
                    foreach (Revit.Elements.Element v in FamilyInstance)
                    {
                        ElementId elemId = Spring.Elements.UnwrapElement(v);
                        Autodesk.Revit.DB.FamilyInstance    elements = DocumentManager.Instance.CurrentDBDocument.GetElement(elemId) as Autodesk.Revit.DB.FamilyInstance;
                        Autodesk.Revit.DB.Architecture.Room fromRoom = elements.get_FromRoom(phase);
                        Autodesk.Revit.DB.Architecture.Room toRoom   = elements.get_ToRoom(phase);
                        toRooms.Add(toRoom.ToDSType(true));
                        fromRooms.Add(fromRoom.ToDSType(true));
                    }
                    ;
                }
                catch (Exception ex)
                {
                    toRooms.Add(null);
                    fromRooms.Add(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(new Dictionary <string, List <Revit.Elements.Element> >
            {
                { "From Room", fromRooms },
                { "To Room", toRooms }
            });
        }