コード例 #1
0
        private void Room2SpaceData(Element e)
        {
            string name   = e.get_Parameter(BuiltInParameter.SPACE_ASSOC_ROOM_NAME).AsString();
            string number = e.get_Parameter(BuiltInParameter.SPACE_ASSOC_ROOM_NUMBER).AsString();

            e.get_Parameter(BuiltInParameter.ROOM_NAME).Set(name);
            e.get_Parameter(BuiltInParameter.ROOM_NUMBER).Set(number);

            Parameter cat_p_space = e.LookupParameter("ADSK_Категория помещения");

            if (cat_p_space != null)
            {
                RevitLinkInstance[] links = DocumentUtils.GetRevitLinkInstances(e.Document);
                foreach (RevitLinkInstance link in links)
                {
                    Document linked_doc = link.GetLinkDocument();
                    if (linked_doc != null)
                    {
                        Element[] rooms = new FilteredElementCollector(linked_doc).OfCategory(BuiltInCategory.OST_Rooms).ToArray();
                        foreach (Element room in rooms)
                        {
                            Parameter cat_p_room = room.LookupParameter("ADSK_Категория помещения");
                            if (room == null)
                            {
                                break;
                            }
                            else
                            {
                                string current_name   = room.get_Parameter(BuiltInParameter.ROOM_NAME).AsString();
                                string current_number = room.get_Parameter(BuiltInParameter.ROOM_NUMBER).AsString();
                                if (current_name == name && current_number == number)
                                {
                                    cat_p_space.Set(cat_p_room.AsString());
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }