In this post i will demonstrate how to automatically determine if door is left or right handed.
One of my fellow Bloggers asked me this morning about determining door set handing programmatically (or any other automated way). Dynamo is a pretty good at accessing Revit API so i quickly cooked up a solution using three of the door properties: HandFlipped, ToRoom and FacingFlipped. Those three combined together make it easy to determine if a door is left or right handed. For all doors swinging into space that has no room placed (most likely exterior) there is another set of hardware called Right Hand Reversed and Left Hand Reversed. Here’s a solution:
Here’s what the Dynamo definition looks like:
Here’s the code that sits under the hood of Door Set Handing node:
Door Set Handing is now a custom node available for download here: Dynamo Download Page.
Preview of this functionality:
Also, Håvard Vasshaug has made a short video and a write up on his blog demonstrating this node in real world application. You can find it here.
In response to questions posted below originally by Dominik, I made some changes to the Door Set Handing Node. Code that you see above reflects those changes. There is an additional input now, for a Phase, since extracting door ToRoom and FromRoom information required that input. I had originally made a silly assumption that everyone’s phases would be called “New Construction” or “Existing”, while in reality some people like to change their names. Anyways, it was an issue with Phase names, and the node should be working well. Thank you to Dominik and recently Jan for pointing out that the node wasn’t functioning well. Here’s the latest example that uses Document.Phases from Clockwork package, to extract a phase on which door might reside:
Will this update automatically if the entire plan is mirrored?
Yes, mirroring doors will not affect correctness of this definition. Also, it does not “update itself”, you would have to re-run the Dynamo definition, but yes after you run it again it will update all doors that were mirrored.
Would it be also easy possible to write a right value to a Revit parameter?
This for forwarding the right “Operation” parameter
Greetings, Hans Hendriks.
Yes, I dont see why not. This IFC standard looks pretty nice. I wish I had it when i first started looking at this issue. I really just did this as a quick proof of concept for a friend of mine so I haven’t tested for all possible door type and combinations. The way it works now, its possible to write any parameter back to door family. Those code block nodes that you see and values within them that have ” ” around them mean that its text. Feel free to change any string/text value to any other and it will write that.
I’m a spanish speaker, so my english es very bad, I hope you understand.
I’m following the instructions of the video and the image, but the code doesn’t work, I don’t know what is happening, when I do the last part, (Element.SetParameterByName) and apply “run” the node it’s turn yellow and show me the Warning: Dereferencing a non-pointer. I no have idea.
Even edit my family door and create a new parameter called “Abatimiento”.
Thanks for your time.
This must be a language issue. I have never tried running Dynamo on a non-english version of software so I have no idea how the code gets translated. My guess is that is is not getting translated at all, but parameters in Revit do. This can cause a lot of problems if parameters called out in code are stored under different name. Try creating parameters in English that match ones used in my video. Other than that I am not sure what I can do for you. I am sorry.
Would you be so kind to contact me in reference to the door set. Looking for some assistance on getting started.
I would say give it a go and post questions here or on a Dynamo blog if you run into trouble. I will try and help as time permits (I am a practicing architect working for a busy office so there might be delays).
I have the same problem
“Warning: Dereferencing a non-pointer”
I tested this with the parameters of your example or others and always getting thie serror message.
Any idea where the problem could be?
Can you post an image or a definition + Revit file that you are testing this on? Since max file size upload for this blog is 2MB use Dropbox or any other similar service for sending me large files. I will need to see it to be able to respond.
thanks for your answer.
I zipped the rvt and the definition file here
Same problem here:
“Warning: Dereferencing a non-pointer”
Did you manage to troubleshoot Dominik’s issue already?
Thank you for your help.
You’re the best! Now it works!!
Many thanks for the help and your great scripts.
You are welcome!
Hi, thank You for the great script.
For some reasons it does not work on a real project, but does work on a test one. I think the problem is in the way you get information “to_room = i.ToRoom[phase]”. For some reasons i don’t have a room in the phase doors are created, but i do have a room in the next phase. Maybe due to this, the entire list get empty.
Also, i don’t get the logics of assigning ‘left’ and ‘lhr’. According to the code, only ‘left’ can be assigned for every matching internal door and only can be ‘lhr’ is assigned for every matching external door.
You might be correct about the Phase. I am not sure why I chose to use this method to obtain ToRoom property of a door, but there is another way to get that: just use i.ToRoom and not include the Phase and that will get the room in the latest phase of the project. I think I will incorporate that change when I get a chance because it makes for a more flexible solution where user doesn’t have to think about what Phases are the Rooms/Doors on. Thank you for the suggestion.
you actually don’t need the phase at all, unless you need to process permanent doors only. I’ve figured it out today, http://ejs.seniejitrakai.net/2015/03/03/on-the-door-handiness-in-autodesk-revit/
Awesome! Thanks for making it better. Care to share a DYN and modified Python code? I bet a lot of users will find it useful.
Yes, no problems. I used to be AutoLISP guy and these are my initial steps to Python and Dynamo.
Well, welcome to the community and I hope I can help in the future.
Oh I missed the second part of your question. Yes, you are correct, if the goal is to eliminate all of the Right and RightHandedReversed doors from the Project, then this tools serves as means of quickly identifying doors that violate the code. I didn’t intend this tool to be the enforcer of the code, but rather quickly allow you to visualize what handing all of your doors have. In case that any of the handing is incorrect, please feel free to change it, and then re-run the definition so that all parameters update. Again, this tool will not flip/reverse doors for you, it will rather tell you that you need to do it yourself.
As far as assigning LHR and RHR goes, this is purely based on an assumption that you DO NOT have a room on the exterior of the building so exterior door when queried for a room it will return None. Now, in case that you are missing interior rooms as well, this tool will treat those interior doors as exterior because of missing room information.
I have the same problem to
“Warning: Dereferencing a non-pointer”
When you passed Dominiks problem, so could you explain the thinking behind what was wrong, or send me working code.
it was working beautifully but after installing Revit update 7 it does not work anymore.
The custom node ‘DoorSetNG’ is now turning red.
I am sorry to bother you with this again, but how do you fix this?
Thansk a lot,
I just figured it out.
It is not your node that broke but Eugenijus’s node.
It still works with yours (incl. the phases).
Glad to hear that! Thanks for the update.
Why does the Run button disappears, when i open your script in dynamo?
I have no clue. That’s weird.
I’m new to dynamo and tried to use your “script” (I don’t know if it’s the proper way to call it) and get w yellow warning sign above every “Element.SetParameterByName” piece. It reads “Warning: No function called SetParameterByName on a _SingleFunctionObject that takes string,string could be found”. Would you be so kind as to help me with this?
Krzysztof, that warning usually means that you are feeding in a wrong type of data. Is the Parameter you are trying to write a string (text) parameter? Please check that it’s not a double or boolean, because passing a string to boolean will throw that error.
I am copying exactly what is shown in the image above, I also tried your updated version that includes phasing. Am I supposed to create some parameter in side my door family, or is Dynamo supposed to do it for me with some kind of Project parameter? I suppose it’s a noobie question, but I installed Dynamo a few days ago solely for the purpose of showing the “left”, “right” parameter in my doors and have no idea what I’m doing :)
I’m trying to use your Door Set Handing but the Element.SetParameterByName turns yellow and bounces a message: “Warning: Internal Error, please report. Dereferencing a non-pointer”. I know it worked a year ago. Any idea how to make it work?
is the door set handing node actually returning a list of doors? it sounds like you might be trying to set a parameter for a null element maybe. Please post images and or better description.
I’m getting the exact same message. Check out the image. Any idea how to make it work?
Hi Roberto, did you manage to solve the error message? I am trying to use the script, but the same error is appearing.
Hi and thanks for this great example.
Concerning the phasing, all works perfectly until there is at least one “demolished” element in the file (“Phase Demolished” parameter different than “none”).
Even with only one demolished element in the file there is no more output at all (see enclosed file), however the macro runs without warnings.
I would recommend that you exclude all doors that were demolished. Please use a node called Phase.Demolished that you can find in archi-lab package and then just combine that with List.FilterByBool to exclude demolished doors.
Hello Konrad, thank you for this post and sharing the code. Is there any way for this definition to work with groups? I’ve got apartment layout groups in my projects and when I run the definition it can’t complete unless I ungroup. Thanks, Karen
Yes, there is a way to re-write that to make it operate on groups. You would basically just need to write a piece of code that tells it to edit the group or ungroup it, and then perform the operation and restore the group. It would have to be a custom piece of code, which I have not written yet. Please post this question to a Dynamo forum and I am sure someone will be keen to write it.
Hello Konrad, thanks for your response. A colleague found that the definition works perfect if the shared parameter for Door Set Handing is changed by selecting ‘Values can vary by group instance’ in project parameter settings also.
Ah! I didn’t think of that. Thanks for sharing.
Thanks for putting this together and it’s great help! I have created the same definition in Dynamo and also added the shared parameter to the doors, however I only get “RHR” and “LHR” no matter how I flip the door, is there a step I have missed? Can you kindly help me a bit in that?
Thanks in advance.
I am using Revit 2017 and Dynamo 0.9.1.4062 (not an expert user)
trying to use custom node Door set handing but got error as under
Warning: Internal error, please report: Dereferencing a non-pointer. (3f47aacd)
please reply soon
Hi Konrad, thank you very much for sharing, I am trying to use your script but the attached error appears. Can you hepl me?
Thanks for putting this together and it’s great help, ideed. I am new in Dynamo, and tried to run the script, but the attached warnind appears and the script does not give any data back. can you hepl me?
First time trying dynamo
It is not working for me :(
There is nothing comming out from the Door set handling code?
Waring no function is called
got the files from
But I am using 2017
I can see a few issues here. First and foremost the nodes that are red, indicate that they are mission. I think they are missing because you don’t have packages that they are from installed. Try going to Package Manager and installing Archi-lab and Steam Nodes perhaps. I am not entirely sure what package is the Tool.GetPhaseByName node from. Try googling around to find out.
Hallo Sorry but dont really understand what you want me do to. went to https://dynamopackages.com/# but it only a vote site got “the nod” or “the code” from your Github and the other cod which was the same from Vasshaugs page. Checked it with what you written on you page. I am not a coder dont understand how you found out the definitions in Revit for the positioning is to_room and Faceflipped , Handflipped: But it dosen’t really matter just want it to work.
Start here: http://dynamoprimer.com/en/
thanks I got it. In the Dynamo programs there is a tab called packeges. It is working great now thanks
It would be useful to add a check like try: except: to check if a door exists in the correct phase. I hade this error because one door was in a different phase. All doors could be filtered by a phase but this just saves a trouble I suppose.
Compliments for your work!
I can’t display the node’s download about door set handing and I don’t know why.
Also I’m working with 2018 version of revit and Dynamo 0.9.1. Is this node compatible with these versions?
0.9.1 is pretty old. Please update to at least 1.3.3 or even latest 2.0.1.
Hello Konrad, thanks you for sharing your script.
How can i do to show the information of the door set handing in a tag (like in your video), i tried with project, sharing and global parameters and the door tag don´t show that information; Schedules and Object properties inside Revit have not problem with that, when i create a door set project parameter, your script run nice for all the doors in the project, when i create a door set parameter inside the door family, your script run only for the doors that include the parameter inside in the family, but when i try to get the information in a tag (right, left), i can´t do that. can you please explain me, how do you that in your video.
Thanks in advance.
I found the solution creating a shared parameters first and then using that in a project parameter. Everything is fine at the moment, my schedules and my tags.
Now i need to discovery a way to get that your script read only the doors that i want to read, because i created my owns families for the project and in aluminium profiles, normaly with fixed glasses or sliding, i don´t need the opening information, but cause the parameter “Door Set” is a project parameter, the script run for all the doors in the project. i will try to combine a List.FilterByBool with something else to exclude aluminium doors, but i am new with Dynamo. Any idea? Thanks in advance.
That sounds like a fine idea. Please give it a try and report if you need any help. Please remember that I can’t see what you are doing. Be brief, but detailed and hopefully attach samples or images of things that you want me to comment on. Otherwise it’s not possible for me to do that.
Was googling something and encountered your page. Awesome solution, but have some questions,
How does it work with fire strategy?
Do you also assume that the door is set correctly when its placed in the first place? Flipping is done only once?
I am not sure I understand the question. Let’s assume I have no idea what fire strategy is. Can you try and explain this to me like I am a 5 year old. Images and examples will help tremendously.
This looks great. Usually we do this with a plugin developed by our supplier, but ran into problems in my current project because the plugin can only count doors7windows in main model and primary design options. How does this react to doors in other design options? Also, what does the reversed outputs mean?
Would you be able to post a sample file or a link to a sample file here: https://github.com/ksobon/archilab/issues I might have some time to have a look at it, but I will need a file that has all of the things that you ask about so that I don’t waste time re-creating it. Thanks!
I’m using your Dynamo package, but it’s not working. The “Door set handing” package provides two functions and these are not read by “Element set parameter by name”. I have attached a screen from my script.
Thank you very much,
Your work is great!
You have to supply a Phase input.
Thank you, now it run.
This is an amazing example of what Dynamo can do – Thanks for sharing! I’m trying to think of a way to make it more accurate. Technically a door is RHR or LHR when it is opened towards the secured space. This could be an office or other interior room. Currently this isn’t how the script works. I was thinking about creating an instance parameter indicating a “reverse swing” door and filtering things, but that’s a bit more manual than I would like. Any idea of a better way to do this?
You can get a ToRoom() property from a Door, and use that to determine if the room is “secured”. I am not sure what determines if the room is secured, but I am sure you can sort it out.
to anyone with the “Warning: Dereferencing a non-pointer” problem – I think there’s some kind of struggle with phase naming. If the phase doesn’t matter to you, you can edit the python script removing reference to the phase, and it should work OK.
Caveat: I’m no dynamo expert! but it worked for me :)
Yes, so you can remove the phase reference in the code, but bear in mind that it doesn’t actually stop Revit from using a Phase when getting that Room. What it does, it make it grab the room from a currently active phase by default. Just FYI.
That’s really helpful, thanks! I’m slowly slowly learning, never have enough time at work to actually get past the basics though
Removed all phases from my project, and deleted the reference in the script, but im still getting this error :(.
very wierd since if i open a new file, and place some doors in it, it works fine..
Well fixed it, by adding this instead of the all category instances.
Think it also selected instances witch had locked parameters, so i could not change them.
Hopefully you are able to spare some time for me. I tested your node in a workshared project but the door handing node does not seem to produce any results. I have ot it working if I test it in a new non workshared project but for some reasong it doesn’t work in the workshared file.
I have attached a screenshot of the completed run of the script.
It probably has nothing to do with the file being workshared or not. I will guess it has to do with Curtain Wall Doors or Doors embedded into Curtain Wall Panels. We will need a sample file (Revit), and the Script (Dynamo) to even consider checking it out.