So I’m a programming / Dynamo noob, but I’m trying to write a little conditional statement to learn more about Dynamo. What I want seems simple: If a door is created in the phase existing (Phase created outputs a numeric value?), then change the door swing angle to 45 degrees, if not, then swing angle to 90 degrees. I want to get even crazier and have all doors run this. I know I can do this easy enough in Revit, any ideas for Dynamo? Here is my futile attempt. Thanks!
Wow, never seen a single digit element ID before!
Andreas and Dave,
Thanks for the quick responses, it's great to have resources like you available.
As far as the "2" I have as an output from Phase Created, that is the ID for Existing Phase in my project (not sure how it got to be that number), and New Construction for me was ID 9521.
Also I was on version 0.5.3 from 7/30
Thanks again, I got that definition to run successfully!
Great, lots to chew on…thanks a lot! This will be a good way to get into Python and learn more about the API.
Dave, just saw the new issue you created regarding filtering. Here's an example of a FilteredElementCollector that will get you a list of all instances of one or several family type(s) in the model. You will notice that actually the Python node only contains a few lines of code - everything else is done with native Dynamo elements. There's actually lots of different filter mechanisms available in the API which are all more or less equally easy to implement as this example.
I get an ID, no matter if I use the Get Parameter node or a String node to identify the parameter. I'm on yesterday's daily build, perhaps Drew is using an older version.
Regarding the filtering of objects, the Revit/Vasari API has a mechanim called FilteredElementCollector. You can find a lot of examples in the SDK and on the internet. And Nathan Miller has shown here how to create FECs in Python.
Tried both approaches but I get an element id in each case. Not sure how the original example has a watch node with a value of "2". Getting the element ID is not very useful as you cannot evaluate what it means as far as I know.
Interesting application, especially if we had nodes to create filtered collections of objects (ex: all doors on Level 1 or all doors of family name/type etc.). Sounds like something we could do with python, but I'm just not at all versed in python yet.
Andreas, it's quite interesting that your example pulled an element ID for the Phase Created parameter, but Drew's example seems to pull an integer.
it looks like you ran into two separate problems with your Formula node:
1. You're comparing apples and oranges. As you can see in the screenshot below, Phase Created stores an Element ID. You're trying to compare that with a string, but as far as I know, Dynamo will only let you compare values of the same data type. To convert your element ID into a string, you can use a Python Script node and replace the code inside by the following line:
OUT = str(IN)
(Of course, it would be better to compare the phase ID to that of another element instead of starting to convert IDs into strings...)
2. As I understand it, the formula node can only evaluate numerical data, so there's the second problem. Combine an Equal node and an If node and you should be good.