Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Door Numbering through getRoomAtPoint() Method

2 REPLIES 2
Reply
Message 1 of 3
inmert
417 Views, 2 Replies

Door Numbering through getRoomAtPoint() Method

Hey Everyone,

 

I've been trying to make a door numbering add in. My main issue is that the template i'm using doesn't have these doors in the latest phase which causes to_room and from_room to return null. My second approach was to try and use the getRoomAtPoint(Point) method and for some reason it returns a null too! I could really use some help to find the rooms in which the doors belong.

foreach (FamilyInstance door in doorArray)
        {
            LocationPoint locationP = door.Location as LocationPoint;
            XYZ roomP = locationP.Point as XYZ;
            Room tempRoom = document.GetRoomAtPoint(roomP);

            using (Transaction t = new Transaction(document, "SetParameter"))
            {
                t.Start();
                try
                {
                    door.LookupParameter("Door Number").Set(tempRoom.LookupParameter("Number").AsString());
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.GetType().ToString() + ": " + ex.Message);
                };
                t.Commit();
            }
        }
2 REPLIES 2
Message 2 of 3
karol.wozniak
in reply to: inmert

Did you try to run your add-in (or macro) 'from' the view with the desired phase? I can't guarantee this will work, as I can't currently test this for you, but I had some similar issues with schedules. When I run my add-in with any active view opened, which was in the desired phase, it worked correctly. Otherwise it was picking up the phase, which didn't include information I was after.

If that is the case for your add-in, you could then read the room_from, room_to parameters of the door and name the doors accordingly.

Good luck.

Message 3 of 3
jeremytammik
in reply to: inmert

Maybe you can first retrieve all the possible phases in the document and save those in a list.

  

Then, for each door, you can determine a room number by calling FromRoom and ToRoom for all possible phases.

  

For safety's sake, I would add an assertion and an error message in case you get two or more different room numbers for different phases.

  

If you are lucky, you will just get one and the same for some, and null for others, so you will know what to use.

  

Please let us know how you end up solving this.

 

Thank you!

 



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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community