It was a cold and rainy night in January, the wind was lashing rain hard against my windows in relentless sheets and naught on TV (as usual), with outdoor activities definitely out the question (as it was cold enough to make even Vinnie Jones and Chuck Norris run home crying) and boring myself to death watching reality TV shows which are more scripted than the news, I had some time to mess around with Dynamo with the objective of building a counter node…
I had recently been reading the DynamoBIM forum and saw a post by Ben Goh – White Christmas, he had this little Zero-Touch node in there called Tick, I quickly adapted this to my own code I was writing and had a fully functioning counter node to play with (I also threw in some DateTime nodes with Periodic Updating) but what to do with them? Hmmm…
Well, I thought an animation would be fun! I have time, quite literally, to play with. What better thing to animate than a clock. So, project in mind I got cracking. It didn’t take too long to get something working. (Update, this now works with the DateTime nodes straight out of the box)
How does it work?
It’s really simple actually, first of all I quickly made some families for the clock face and hands. No parameters needed as the geometry will all be controlled by Dynamo but made sure that all the families geometry was at the intersection of the OOTB Ref Planes – this is so when I place them they will all sit correctly and when I rotate the hands I can use the Placement Point as my axis of rotation. For further aesthetics, I quickly massed up a cheeky Grandfather Clock to place all my clock pieces on and to make it look prettier. Note: All the families are placed individually in Revit and not as one family, you’ll see why later!
Ok, with the model ready let’s have a look at what’s driving it.
Firstly, I needed to get the current time. I used my own nodes when I first did this as the periodic updater wouldn’t work on the OOTB nodes but now that’s been fixed we can use the ones straight out of Dynamo. Here is what it looks like…
Cool, we have time and a small digital clock! Woohoo! Nothing groundbreaking there. But how do we get that to rotate our clock hands? Well, again not too tricky, although my brain did get a little confused with some of the calculations, it was getting a bit late when I was piecing it together and making silly mistakes. This part of the script gets all the families I made earlier (individually) and gets their Geometry, it also takes the Hours, Mins & Seconds and converts them to a rotation value in degrees. (Note: Since we are going clockwise we need the inverse of the rotation so cwRot = Rot * -1)
Awesome! That’s pretty much it. However, it all looked a bit boring in grey, let’s add some colour.
So that completes the script! We now have a fully functioning clock in Dynamo and we can customise the colours! But what about Revit you may ask? Can we have a Revit clock too? Well of course you can. Here is the final piece of the script…
One thing to watch out for though when using Periodic Updating though is setting it too fast. A second (or 1000 milliseconds) works well with the above script but setting it to like 20 milliseconds would not be advisable as it will probably crash Dynamo. 🙂
Anyway, thought I would share this with you all. It was a fun little project. Maybe you can take some of it and use it in your own projects.
Cheers!
Leave a Reply