Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Door Numbering through getRoomAtPoint() Method

inmert
Participant

Door Numbering through getRoomAtPoint() Method

inmert
Participant
Participant

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();
            }
        }
0 Likes
Reply
462 Views
2 Replies
Replies (2)

karol.wozniak
Contributor
Contributor

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.

0 Likes

jeremytammik
Autodesk
Autodesk

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

0 Likes