public List <IRoom> FindGamesWithFilter(string legalUserName, bool leagueOnly, string gameType, int buyInPolicy, int chipPolicy, int minBet, int minPlayers, bool sepctatingAllowed) { var context = _userLogic.GetUser(legalUserName, _gameCenter.Users); var predicates = new List <Predicate <IRoom> >(); var r = new RoomFilter { PlayerName = legalUserName, LeagueOnly = leagueOnly, GameType = gameType, BuyInPolicy = buyInPolicy, ChipPolicy = chipPolicy, MinBet = minBet, MinPlayers = minPlayers, SepctatingAllowed = sepctatingAllowed }; if (context.League != -1 && r.LeagueOnly != null && r.LeagueOnly.Value) { predicates.Add(room => room.League == context.League); } if (r.PlayerName != null) { predicates.Add(room => room.HasPlayer(r.PlayerName)); } if (r.PotSize != null) { predicates.Add(room => room.Pot == r.PotSize.Value); } if (r.GameType != null) { predicates.Add(room => room.GamePreferences.GameType.ToString() == r.GameType); } if (r.BuyInPolicy != null) { predicates.Add(room => room.GamePreferences.BuyInPolicy == r.BuyInPolicy.Value); } if (r.ChipPolicy != null) { predicates.Add(room => room.GamePreferences.ChipPolicy == r.ChipPolicy.Value); } if (r.MinBet != null) { predicates.Add(room => room.GamePreferences.MinBet == r.MinBet.Value); } if (r.MinPlayers != null) { predicates.Add(room => room.GamePreferences.MinPlayers == r.MinPlayers.Value); } if (r.MaxPlayers != null) { predicates.Add(room => room.GamePreferences.MaxPlayers == r.MaxPlayers.Value); } if (r.SepctatingAllowed != null) { predicates.Add(room => room.GamePreferences.Spectating == r.SepctatingAllowed.Value); } return(_gameCenter.FindGames(predicates)); }
public (IEnumerable <RoomViewModel> model, int count) ReadRooms(RoomFilter filter) { var(rooms, count) = roomRepository.ReadRooms(filter); var roomsModel = mapper.Map <IEnumerable <RoomViewModel> >(rooms); return(roomsModel, count); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { Document document = commandData.Application.ActiveUIDocument.Document; FilteredElementCollector filtereElementCollector = new FilteredElementCollector(document); RoomFilter roomFilter = new RoomFilter(); List <Room> rooms = filtereElementCollector.WherePasses(roomFilter).OfType <Room>().ToList(); rooms = rooms.OrderBy(r => r.Level.Name).ToList(); if (rooms.Count == 0) { TaskDialog.Show("Message", "This model does not contain rooms."); } else { try { using (Form_AutoChangeRoomNumber formAutoChangeRoomNum = new Form_AutoChangeRoomNumber(document, rooms)) { formAutoChangeRoomNum.ShowDialog(); } } catch (Exception ex) { TaskDialog.Show("Exception", ex.Message); } } } catch (Exception ex) { TaskDialog.Show("Exception", ex.Message); } return(Result.Succeeded); }
/// <summary> /// Возвращает список всех чистых помещений /// </summary> public static List <Room> GetAllCleanRooms(Document doc) { FilteredElementCollector collector = new FilteredElementCollector(doc); RoomFilter roomFilter = new RoomFilter(); collector.WherePasses(roomFilter); // Настройка фильтра для комнат заданным параметром "BL_Класс чистоты", // равным "A", "B", "C" или "D" Guid spGuid = new Guid("02f7e9d4-f055-479e-a36f-5b8e098d40f5"); Room fRoom = collector.FirstElement() as Room; Parameter testSharedParam = fRoom.get_Parameter(spGuid); ElementId sharedParamId = testSharedParam.Id; ParameterValueProvider provider = new ParameterValueProvider(sharedParamId); FilterStringRuleEvaluator fsreEqual = new FilterStringEquals(); string testStrCNC = "CNC"; string testVoidStrCNC = ""; FilterRule fCNCRule = new FilterStringRule(provider, fsreEqual, testStrCNC, false); FilterRule fVoidStrRule = new FilterStringRule(provider, fsreEqual, testVoidStrCNC, false); ElementParameterFilter paramNoCNCFilter = new ElementParameterFilter(fCNCRule, true); ElementParameterFilter paramNoVoidFilter = new ElementParameterFilter(fVoidStrRule, true); collector.WherePasses(paramNoVoidFilter).WherePasses(paramNoCNCFilter); List <Room> cleanRooms = (from e in collector.ToElements() where e is Room select e as Room).ToList <Room>(); return(cleanRooms); }
private IQueryable <Room> SetFilter(IQueryable <Room> q, RoomFilter f) { if (f == null) { return(q); } if (!String.IsNullOrEmpty(f.searchString)) { q = q.Where(s => ( s.Number.Contains(f.searchString) || s.Description.Contains(f.searchString) )); } if (f.Capacity > 0) { q = q.Where(s => s.Capacity == f.Capacity); } if (f.BedCont > 0) { q = q.Where(s => s.BedCont == f.BedCont); } if (f.VPN > 0) { q = q.Where(s => s.VPN == f.VPN); } if (f.CurrencyId != 0) { q = q.Where(s => s.CurrencyID == f.CurrencyId); } return(q); }
private void NewMethod(FloorType floorType, CurveArray curves, Level level1) { RoomFilter filter = new RoomFilter(); FilteredElementCollector collector = new FilteredElementCollector(_doc); IList <Element> rooms = collector.WherePasses(filter).ToElements(); int n = rooms.Count(); foreach (Room room in rooms) { IList <IList <BoundarySegment> > segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions()); CurveArray roomsCurves = new CurveArray(); // Array to hold curv data collected from room boundreis roomsCurves.Clear(); SpatialElementBoundaryOptions bo = new SpatialElementBoundaryOptions(); SketchPlane sp = _doc.ActiveView.SketchPlane; foreach (IList <BoundarySegment> lstBs in room.GetBoundarySegments(bo)) { foreach (BoundarySegment bs in lstBs) { roomsCurves.Append(bs.GetCurve()); } } _doc.Create.NewFloor(roomsCurves, floorType, level1, false); } //_doc.Create.NewFloor(curves, floorType, level1, true); }
/// <summary> /// get all the rooms and room tags in the project /// </summary> private void GetAllRoomsAndTags() { // get the active document Document document = m_revit.ActiveUIDocument.Document; RoomFilter roomFilter = new RoomFilter(); RoomTagFilter roomTagFilter = new RoomTagFilter(); LogicalOrFilter orFilter = new LogicalOrFilter(roomFilter, roomTagFilter); FilteredElementIterator elementIterator = (new FilteredElementCollector(document)).WherePasses(orFilter).GetElementIterator(); elementIterator.Reset(); // try to find all the rooms and room tags in the project and add to the list while (elementIterator.MoveNext()) { object obj = elementIterator.Current; // find the rooms, skip those rooms which don't locate at Level yet. Room tmpRoom = obj as Room; if (null != tmpRoom && null != tmpRoom.Level) { m_rooms.Add(tmpRoom); continue; } // find the room tags RoomTag tmpTag = obj as RoomTag; if (null != tmpTag) { m_roomTags.Add(tmpTag); continue; } } }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiApp = commandData.Application; Document currentDoc = uiApp.ActiveUIDocument.Document; View av = currentDoc.ActiveView; ViewFamilyType vft = GenerateViews.ViewTypeSetup(currentDoc); if (av.ViewType == ViewType.FloorPlan) { RoomFilter filt = new RoomFilter(); ICollection <Element> roomset = new FilteredElementCollector(currentDoc, av.Id).WherePasses(filt).ToElements(); foreach (Element e in roomset) { Room r = e as Room; GenerateViews.GenViews(vft, av, r); } } else { TaskDialog.Show("Error", "Active a plan view!"); } return(Result.Succeeded); }
public RoomConvertorViewModel(RoomConversionManager manager) { this.manager = manager; rooms = new List <RoomConversionCandidate>(manager.Candidates); MassCreationMode = true; SheetCreationMode = false; filter = new RoomFilter(); }
public void Update(Room room, RoomFilter filter) { try { string cmd = string.Format("Update Room set " + "number = {0}, description = '{1}', type = '{2}', places = {3}, price = {4}, status = '{5}', assignedTo = '{6}' ", room.number, room.description, room.type, room.places, room.price, room.status, room.assignedTo); List <string> wcmd = new List <string>(); if (filter.Number.HasValue) { wcmd.Add("number = " + filter.Number); } if (!String.IsNullOrEmpty(filter.Description)) { wcmd.Add("description LIKE '" + filter.Description + "%'"); } if (!String.IsNullOrEmpty(filter.Type)) { wcmd.Add("type LIKE '" + filter.Type + "%'"); } if (filter.Places.HasValue) { wcmd.Add("places = " + filter.Places); } if (filter.Price.HasValue) { wcmd.Add("price = " + filter.Price); } if (filter.PriceLowerThan.HasValue) { wcmd.Add("price < " + filter.PriceLowerThan); } if (filter.PriceUpperThan.HasValue) { wcmd.Add("price > " + filter.PriceUpperThan); } if (!String.IsNullOrEmpty(filter.Status)) { wcmd.Add("status LIKE '" + filter.Status + "%'"); } if (!String.IsNullOrEmpty(filter.AssignedTo)) { wcmd.Add("assignedTo LIKE '" + filter.AssignedTo + "%'"); } if (wcmd.Count() > 0) { cmd += "where " + string.Join(" AND ", wcmd.ToArray()); } ExecuteNonQuery(cmd); } catch (Exception e) { Console.WriteLine("Error " + e.ToString()); Console.ReadKey(); } }
public void Delete(RoomFilter filter) { try { string cmd = "Delete from Room "; List <string> wcmd = new List <string>(); if (filter.Number.HasValue) { wcmd.Add("number = " + filter.Number); } if (!String.IsNullOrEmpty(filter.Description)) { wcmd.Add("description LIKE '" + filter.Description + "%'"); } if (!String.IsNullOrEmpty(filter.Type)) { wcmd.Add("type LIKE '" + filter.Type + "%'"); } if (filter.Places.HasValue) { wcmd.Add("places = " + filter.Places); } if (filter.Price.HasValue) { wcmd.Add("price = " + filter.Price); } if (filter.PriceLowerThan.HasValue) { wcmd.Add("price < " + filter.PriceLowerThan); } if (filter.PriceUpperThan.HasValue) { wcmd.Add("price > " + filter.PriceUpperThan); } if (!String.IsNullOrEmpty(filter.Status)) { wcmd.Add("status LIKE '" + filter.Status + "%'"); } if (!String.IsNullOrEmpty(filter.AssignedTo)) { wcmd.Add("assignedTo LIKE '" + filter.AssignedTo + "%'"); } if (wcmd.Count() > 0) { cmd += "where " + string.Join(" AND ", wcmd.ToArray()); } ExecuteNonQuery(cmd); } catch (Exception e) { Console.WriteLine("Error " + e.ToString()); Console.ReadKey(); } }
/// <summary> /// Get all rooms in current Revit project /// </summary> private void GetAllRooms(Document activeDoc) { // get all room elements // try to find all rooms in the project and add to the list RoomFilter filter = new RoomFilter(); FilteredElementCollector collector = new FilteredElementCollector(activeDoc); m_rooms = collector.WherePasses(filter).ToElements().Cast <Room>().ToList <Room>(); // sort rooms by number m_rooms.Sort(CompRoomByNumber); }
public List <IRoom> FindGames(string username) // UC 11 (Finds any available game) { var context = _userLogic.GetUser(username, _gameCenter.Users); var predicates = new List <Predicate <IRoom> >(); var r = new RoomFilter { SepctatingAllowed = true }; if (context.League != -1 && r.LeagueOnly != null && r.LeagueOnly.Value) { predicates.Add(room => room.League == context.League); } if (r.PlayerName != null) { predicates.Add(room => room.HasPlayer(r.PlayerName)); } if (r.PotSize != null) { predicates.Add(room => room.Pot == r.PotSize.Value); } if (r.GameType != null) { predicates.Add(room => room.GamePreferences.GameType.ToString() == r.GameType); } if (r.BuyInPolicy != null) { predicates.Add(room => room.GamePreferences.BuyInPolicy == r.BuyInPolicy.Value); } if (r.ChipPolicy != null) { predicates.Add(room => room.GamePreferences.ChipPolicy == r.ChipPolicy.Value); } if (r.MinBet != null) { predicates.Add(room => room.GamePreferences.MinBet == r.MinBet.Value); } if (r.MinPlayers != null) { predicates.Add(room => room.GamePreferences.MinPlayers == r.MinPlayers.Value); } if (r.MaxPlayers != null) { predicates.Add(room => room.GamePreferences.MaxPlayers == r.MaxPlayers.Value); } if (r.SepctatingAllowed != null) { predicates.Add(room => room.GamePreferences.Spectating == r.SepctatingAllowed.Value); } return(_gameCenter.FindGames(predicates)); }
private void GetRoomInProject(out IList <Element> rooms) { // The normal vector (0,0,1) that must be perpendicular to the profile. //XYZ normal = XYZ.BasisZ; //Get room's RoomFilter filter = new RoomFilter(); // Apply the filter to the elements in the active document FilteredElementCollector collector3 = new FilteredElementCollector(_doc); rooms = collector3.WherePasses(filter).ToElements(); }
private async void GetFilteredRoomList(Floor myFloor) { // 1. aanmaken FloorFilter RoomFilter rf = new RoomFilter() { // ... }; // 2. opvragen van de lijst van rooms adhv de gekozen floor List <Room> roomList = await _locationRepo.GetRoomList(rf); // 3. weergeven van lijst in dropdown list }
/// <summary> /// Retrieves a list of datacenter room objects /// </summary> /// <param name="page"> /// The requested page from the server. This is an optional /// argument and if omitted the server will default to returning the /// first page with a maximum of `100` items.</param> /// <param name="filter"> /// A filter object to filter the datacenter rooms on /// the server.If omitted, the server will return all objects as a /// paginated response. /// </param> /// <param name="sort"> /// A sort definition object to sort the datacenter rooms /// on supported properties.If omitted objects are returned in the /// order as they were created in. /// </param> /// <returns></returns> public RoomList GetRooms( PageInput page = null, RoomFilter filter = null, RoomSort sort = null) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("page", page, true); parameters.Add("filter", filter, true); parameters.Add("sort", sort, true); return(RunQuery <RoomList>(@"getLabs", parameters)); }
public async Task <ProcessResult <int> > CountAsync(RoomFilter filter) { IQueryable <Room> q = context.Rooms; q = SetFilter(q, filter); Func <Task <int> > action = async() => { var countItems = await q.CountAsync(); return(countItems); }; return(await Process.RunAsync(action)); }
public async Task <IActionResult> Count(RoomFilter filter) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _RoomService.CountAsync(filter); if (!result.Succeeded) { return(BadRequest(result.Errors)); } return(Ok(result)); }
public IActionResult Index(int?pageNumber, RoomFilter roomFilter) { try { ViewData["CurrentSort"] = roomFilter.SortOrder; ViewData["RoomNumberSortParm"] = String.IsNullOrEmpty(roomFilter.SortOrder) ? "roomNumber" : ""; ViewData["MaxPersonSortParm"] = roomFilter.SortOrder == "MaxPerson" ? "maxPerson" : "MaxPerson"; roomFilter.Take = 5; pageNumber ??= 1; roomFilter.Skip = (pageNumber.Value - 1) * roomFilter.Take; var(rooms, count) = roomService.ReadRooms(roomFilter); return(View(PaginatedList <RoomViewModel> .Create(rooms, count, pageNumber.Value, roomFilter.Take))); } catch (Exception) { return(BadRequest()); } }
public Dictionary <Room, List <string> > GetRoomInfo(Document document, UIDocument uidoc) { using (Transaction t = new Transaction(document, "Turn on volume calculation")) { t.Start(); AreaVolumeSettings settings = AreaVolumeSettings.GetAreaVolumeSettings(document); settings.ComputeVolumes = true; t.Commit(); } Dictionary <Room, List <string> > dimensions = new Dictionary <Room, List <string> >(); List <string> info = new List <string>(); RoomFilter filter = new RoomFilter(); FilteredElementCollector collector = new FilteredElementCollector(document); collector.WherePasses(filter); FilteredElementIdIterator roomIdItr = collector.GetElementIdIterator(); roomIdItr.Reset(); while (roomIdItr.MoveNext()) { ElementId roomId = roomIdItr.Current; Room room = document.GetElement(roomId) as Room; //Make sure room is valid if (room != null) { //Wall wall = document.GetReference(room) as Wall; //Fill out dictionary with room attributes info.Add(room.Name); info.Add(room.Volume.ToString()); info.Add(room.Area.ToString()); info.Add(room.Perimeter.ToString()); info.Add(room.UnboundedHeight.ToString()); dimensions.Add(room, info); } } return(dimensions); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiapp = commandData.Application; var uidoc = uiapp.ActiveUIDocument; var doc = uidoc.Document; var sel = uidoc.Selection; var roomfilter = new RoomFilter(); var collector = new FilteredElementCollector(doc); var rooms = collector.WherePasses(roomfilter).WhereElementIsNotElementType(); foreach (var element in rooms) { var location = element.Location; } MessageBox.Show(rooms.Count().ToString()); return(Result.Succeeded); }
/// <summary> /// Opvragen van de lijst van rooms, aangeleverd door de API. /// </summary> /// <returns>Task<List<Room>></returns> public async Task <List <Room> > GetRoomList(RoomFilter rf) { List <Room> result = new List <Room>(); String pagejson = await AzureMobileClient.DefaultClient.InvokeApiAsync <RoomFilter, string>("/api/RoomSearch", rf, System.Net.Http.HttpMethod.Post, null, System.Threading.CancellationToken.None); List <Room> page = JsonConvert.DeserializeObject <List <Room> >(pagejson); result.AddRange(page); while (page.Count == rf.EffectivePageSize) { rf.LastRoom = page[page.Count - 1]; pagejson = await AzureMobileClient.DefaultClient.InvokeApiAsync <RoomFilter, string>("/api/RoomSearch", rf, System.Net.Http.HttpMethod.Post, null, System.Threading.CancellationToken.None); page = JsonConvert.DeserializeObject <List <Room> >(pagejson); result.AddRange(page); } return(result); }
/// <summary> ///constructor /// </summary> public RoomsData(ThisDocument hostAddIn, Autodesk.Revit.ApplicationServices.Application application) { m_application = application; m_thisDocument = hostAddIn; RoomFilter roomFilter = new RoomFilter(); RoomTagFilter roomTagFilter = new RoomTagFilter(); LogicalOrFilter orFilter = new LogicalOrFilter(roomFilter, roomTagFilter); FilteredElementIterator elementIterator = (new FilteredElementCollector(m_thisDocument.Document)).WherePasses(orFilter).GetElementIterator(); elementIterator.Reset(); // try to find all the rooms and room tags in the project and add to the list while (elementIterator.MoveNext()) { object obj = elementIterator.Current; // find the rooms, skip those rooms which don't locate at Level yet. Room tmpRoom = obj as Room; if (null != tmpRoom && null != tmpRoom.Level) { m_rooms.Add(tmpRoom); continue; } // find the room tags RoomTag tmpTag = obj as RoomTag; if (null != tmpTag) { m_roomTags.Add(tmpTag); continue; } } //find out the rooms that without tag ClassifyRooms(); }
public async Task <IActionResult> GetRoomsPaged([FromQuery] RoomFilter roomFilter) { // validasyon if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // IQueryCollection queryString = Request.Query; // roomFilter.RouteValues = queryString.ToRouteValues(); roomFilter.RouteName = string.Concat(Request.Scheme, "://", Request.Host.Value); roomFilter.RouteValues = Request.Query.ToRouteValues(); var rooms = await _roomService.GetRoomsPagedAsync(roomFilter); if (rooms.Data == null || !rooms.Data.Any()) //rooms.Data.Count() <= 0 ) /* 1 2 3 4 ... 10.000*/ { return(NoContent()); } return(Ok(rooms)); }
public (IEnumerable <Room> rooms, int count) ReadRooms(RoomFilter filter) { var query = context.Rooms.Include(r => r.RoomStatus).Include(r => r.RoomType).Take(filter.Take).Skip(filter.Skip); switch (filter.SortOrder) { case "RoomNumber": query = query.OrderBy(r => r.RoomNumber); break; case "MaxPerson": query = query.OrderBy(r => r.MaxPerson); break; default: query = query.OrderBy(r => r.Id); break; } var rooms = query.ToList(); return(rooms, rooms.Count); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiapp = commandData.Application; var uidoc = uiapp.ActiveUIDocument; var doc = uidoc.Document; var acview = doc.ActiveView; var sel = uidoc.Selection; var roomfilter = new RoomFilter(); var collector = new FilteredElementCollector(doc); var rooms = collector.WherePasses(roomfilter).WhereElementIsNotElementType(); foreach (var element in rooms) { var location = element.Location; } MessageBox.Show(rooms.Count().ToString()); //ParameterFilterElement filterelement = ParameterFilterElement.Create(doc,"喷淋"); var wall = doc.TCollector <Wall>().First(); var schemas = Schema.ListSchemas(); foreach (var schema in schemas) { var guids = wall.GetEntitySchemaGuids(); var schemas1 = guids.Select(m => Schema.Lookup(m)); foreach (var schema1 in schemas1) { wall.DeleteEntity(schema1); } } return(Result.Succeeded); }
public RoomList Post([FromBody] RoomFilter value, string token) { var ret = new RoomList(); try { Server.CheckToken(token); var rooms = Server.GameFacade.FindGames(Crypto.Decrypt(value.User), new TexasHoldem.Game.RoomFilter( value.PlayerName, value.PotSize, value.LeagueOnly, value.GameType, value.BuyInPolicy, value.ChipPolicy, value.MinBet, value.MinPlayers, value.MaxPlayers, value.SpectatingAllowed)); ret.Rooms = new Room[rooms.Count]; for (var i = 0; i < rooms.Count; i++) { ret.Rooms[i] = new Room { RoomName = rooms.ElementAt(i).Name, GameType = rooms.ElementAt(i).GamePreferences.GameType.ToString(), League = rooms.ElementAt(i).League, BuyInPolicy = rooms.ElementAt(i).GamePreferences.BuyInPolicy, MinBet = rooms.ElementAt(i).GamePreferences.MinBet, MinPlayers = rooms.ElementAt(i).GamePreferences.MinPlayers, MaxPlayers = rooms.ElementAt(i).GamePreferences.MaxPlayers, SpectatingAllowed = rooms.ElementAt(i).GamePreferences.Spectating, ChipPolicy = rooms.ElementAt(i).GamePreferences.ChipPolicy } } ; } catch (Exception e) { ret.Message = e.Message; } return(ret); }
public List <Room> Get(RoomFilter filter) { try { Console.Clear(); Console.WriteLine("Repository: ROOM\n\n"); string cmd = "Select * from Room "; List <string> wcmd = new List <string>(); if (filter.Number.HasValue) { wcmd.Add("number = " + filter.Number); } if (!String.IsNullOrEmpty(filter.Description)) { wcmd.Add("description LIKE '" + filter.Description + "%'"); } if (!String.IsNullOrEmpty(filter.Type)) { wcmd.Add("type LIKE '" + filter.Type + "%'"); } if (filter.Places.HasValue) { wcmd.Add("places = " + filter.Places); } if (filter.Price.HasValue) { wcmd.Add("price = " + filter.Price); } if (filter.PriceLowerThan.HasValue) { wcmd.Add("price < " + filter.PriceLowerThan); } if (filter.PriceUpperThan.HasValue) { wcmd.Add("price > " + filter.PriceUpperThan); } if (!String.IsNullOrEmpty(filter.Status)) { wcmd.Add("status LIKE '" + filter.Status + "%'"); } if (!String.IsNullOrEmpty(filter.AssignedTo)) { wcmd.Add("assignedTo LIKE '" + filter.AssignedTo + "%'"); } if (wcmd.Count() > 0) { cmd += "where " + string.Join(" AND ", wcmd.ToArray()); } List <Room> roomList = new List <Room>(); DbDataReader reader = ExecuteReader(cmd); while (reader.Read()) { Room room = new Room(); room.number = (int)reader["number"]; room.description = (string)reader["description"]; room.type = (string)reader["type"]; room.places = (int)reader["places"]; room.price = (double)reader["price"]; room.status = (string)reader["status"]; room.assignedTo = (string)reader["assignedTo"]; roomList.Add(room); } return(roomList); } catch (Exception e) { Console.WriteLine("Error " + e.ToString()); Console.ReadKey(); return(new List <Room>()); } }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; Document doc = app.ActiveUIDocument.Document; FilteredElementCollector rooms = new FilteredElementCollector( doc ); // // this is one way of obtaining rooms ... but see below for a better solution: // //rooms.OfClass( typeof( Room ) ); // Input type is of an element type that exists in the API, but not in Revit's native object model. Try using Autodesk.Revit.DB.Enclosure instead, and then postprocessing the results to find the elements of interest. //rooms.OfClass( typeof( Enclosure ) ); // this works but returns all Enclosure elements RoomFilter filter = new RoomFilter(); rooms.WherePasses( filter ); if( 0 == rooms.Count() ) { LabUtils.InfoMsg( "There are no rooms in this model." ); } else { List<string> a = new List<string>(); /* foreach( Enclosure e in rooms ) // todo: remove this { Room room = e as Room; // todo: remove this if( null != room ) // todo: remove this { */ foreach( Room room in rooms ) { string roomName = room.Name; string roomNumber = room.Number; string s = "Room Id=" + room.Id.IntegerValue.ToString() + " Name=" + roomName + " Number=" + roomNumber + "\n"; // Loop all boundaries of this room //BoundarySegmentArrayArray boundaries = room.Boundary; // 2011 IList<IList<BoundarySegment>> boundaries // 2012 = room.GetBoundarySegments( // 2012 new SpatialElementBoundaryOptions() ); // 2012; passing in a null value throws an exception // Check to ensure room has boundary if( null != boundaries ) { int iB = 0; //foreach( BoundarySegmentArray boundary in boundaries ) // 2011 foreach( IList<BoundarySegment> boundary in boundaries ) // 2012 { ++iB; s += " Boundary " + iB + ":\n"; int iSeg = 0; foreach( BoundarySegment segment in boundary ) { ++iSeg; // Segment's curve Curve crv = segment.GetCurve(); if( crv is Line ) { Line line = crv as Line; XYZ ptS = line.GetEndPoint( 0 ); XYZ ptE = line.GetEndPoint( 1 ); s += " Segment " + iSeg + " is a LINE: " + LabUtils.PointString( ptS ) + " ; " + LabUtils.PointString( ptE ) + "\n"; } else if( crv is Arc ) { Arc arc = crv as Arc; XYZ ptS = arc.GetEndPoint( 0 ); XYZ ptE = arc.GetEndPoint( 1 ); double r = arc.Radius; s += " Segment " + iSeg + " is an ARC:" + LabUtils.PointString( ptS ) + " ; " + LabUtils.PointString( ptE ) + " ; R=" + LabUtils.RealString( r ) + "\n"; } } } a.Add( s ); } LabUtils.InfoMsg( "{0} room{1} in the model{2}", a ); } } return Result.Failed; }
/// <summary> /// Get all rooms in current Revit project /// </summary> private void GetAllRooms(Document activeDoc) { // get all room elements // try to find all rooms in the project and add to the list RoomFilter filter = new RoomFilter(); FilteredElementCollector collector = new FilteredElementCollector(activeDoc); m_rooms = collector.WherePasses(filter).ToElements().Cast<Room>().ToList<Room>(); // sort rooms by number m_rooms.Sort(CompRoomByNumber); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; Document doc = app.ActiveUIDocument.Document; FilteredElementCollector rooms = new FilteredElementCollector(doc); // // this is one way of obtaining rooms ... but see below for a better solution: // //rooms.OfClass( typeof( Room ) ); // Input type is of an element type that exists in the API, but not in Revit's native object model. Try using Autodesk.Revit.DB.Enclosure instead, and then postprocessing the results to find the elements of interest. //rooms.OfClass( typeof( Enclosure ) ); // this works but returns all Enclosure elements RoomFilter filter = new RoomFilter(); rooms.WherePasses(filter); if (0 == rooms.Count()) { LabUtils.InfoMsg("There are no rooms in this model."); } else { List <string> a = new List <string>(); /* * foreach( Enclosure e in rooms ) // todo: remove this * { * Room room = e as Room; // todo: remove this * if( null != room ) // todo: remove this * { */ foreach (Room room in rooms) { string roomName = room.Name; string roomNumber = room.Number; string s = "Room Id=" + room.Id.IntegerValue.ToString() + " Name=" + roomName + " Number=" + roomNumber + "\n"; // Loop all boundaries of this room //BoundarySegmentArrayArray boundaries = room.Boundary; // 2011 IList <IList <BoundarySegment> > boundaries // 2012 = room.GetBoundarySegments( // 2012 new SpatialElementBoundaryOptions()); // 2012; passing in a null value throws an exception // Check to ensure room has boundary if (null != boundaries) { int iB = 0; //foreach( BoundarySegmentArray boundary in boundaries ) // 2011 foreach (IList <BoundarySegment> boundary in boundaries) // 2012 { ++iB; s += " Boundary " + iB + ":\n"; int iSeg = 0; foreach (BoundarySegment segment in boundary) { ++iSeg; // Segment's curve Curve crv = segment.GetCurve(); if (crv is Line) { Line line = crv as Line; XYZ ptS = line.GetEndPoint(0); XYZ ptE = line.GetEndPoint(1); s += " Segment " + iSeg + " is a LINE: " + LabUtils.PointString(ptS) + " ; " + LabUtils.PointString(ptE) + "\n"; } else if (crv is Arc) { Arc arc = crv as Arc; XYZ ptS = arc.GetEndPoint(0); XYZ ptE = arc.GetEndPoint(1); double r = arc.Radius; s += " Segment " + iSeg + " is an ARC:" + LabUtils.PointString(ptS) + " ; " + LabUtils.PointString(ptE) + " ; R=" + LabUtils.RealString(r) + "\n"; } } } a.Add(s); } LabUtils.InfoMsg("{0} room{1} in the model{2}", a); } } return(Result.Failed); }
public RoomFilter CreateFilter() { Console.Clear(); Console.WriteLine("Repository: ROOM\n\n"); Console.WriteLine("Creating conditions for rows\n" + "You can skip some conditions\n" + "(select ... , where): "); RoomFilter filter = new RoomFilter(); Console.WriteLine("NUMBER: "); string a1 = Console.ReadLine(); if (a1 != "") { filter.Number = Convert.ToInt32(a1); } Console.WriteLine("DESCRIPTION: "); filter.Description = Console.ReadLine(); Console.WriteLine("TYPE: "); filter.Type = Console.ReadLine(); Console.WriteLine("PLACES: "); string a2 = Console.ReadLine(); if (a2 != "") { filter.Number = Convert.ToInt32(a2); } Console.WriteLine("PRICE: "); string a = Console.ReadLine(); if (a != "") { filter.Price = Convert.ToDouble(a); } Console.WriteLine("PRICE lower than: "); string b = Console.ReadLine(); if (b != "") { filter.PriceLowerThan = Convert.ToDouble(b); } Console.WriteLine("PRICE upper than: "); string c = Console.ReadLine(); if (c != "") { filter.PriceUpperThan = Convert.ToDouble(c); } Console.WriteLine("STATUS: "); filter.Status = Console.ReadLine(); Console.WriteLine("ASSiGNED TO: "); filter.AssignedTo = Console.ReadLine(); return(filter); }