Creating rooms using the revit api

Creating rooms using the revit api

Anonymous
Not applicable
3,534 Views
2 Replies
Message 1 of 3

Creating rooms using the revit api

Anonymous
Not applicable

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();
            }
        }

 

0 Likes
3,535 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

Please supply the 'complex model' that you mention as well.

 

Keep it minimal. Optimally, delete everything in it except one single circuit that causes the problem.

 

Then, include the code snippet you show above as a macro in the sample model, so the development team can easily reproduce the issue:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3

1240904365
Enthusiast
Enthusiast

So how to slove it?

0 Likes