Message 1 of 3
Creating rooms using the revit api

Not applicable
08-16-2017
06:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create rooms using the revit api. It is working for simpler models, it is not working for complex models. For complex models it throws the following exception:
Autodesk.Revit.Exceptions.ArgumentException : circuit
Parameter name: Could not find a point within this circuit.
at NewRoom(Room room, PlanCircuit circuit) method
Way to reproduce the error: Just copy and call the method (attached below) in the Execute method.
private void CreateRooms(Document document) { PhaseArray phases = document.Phases; Phase createRoomsInPhase = phases.get_Item(phases.Size - 1); FilteredElementCollector collector = new FilteredElementCollector(document); collector.OfClass(typeof(Level)); using (Transaction tran = new Transaction(document)) { int x = 1; tran.Start("tran1"); foreach (Level level in collector) { PlanTopology topology = document.get_PlanTopology(level, createRoomsInPhase); PlanCircuitSet circuitSet = topology.Circuits; foreach (PlanCircuit circuit in circuitSet) { if (!circuit.IsRoomLocated) { Room room = document.Create.NewRoom(null, circuit); room.Name = "Room name: " + x; x++; } } } tran.Commit(); } }