onsdag 14. desember 2016

Ammo: Centre of Gravity

A challenge arose some days ago as to define a script that could calculate the Centre of Gravity in a Revit model, and of course Dynamo was made for solving these kinds of challenges. Based on the "Algorithm" found here, we applied it to three dimensions in Dynamo. The script uses project base point as Datum and no particular effort has been made to make the units in the calculation usable for anything else. The python script has however been modified to extract density in SI units.

Enjoy! :)

In action:

A version of the script can be found here

torsdag 17. november 2016

Ammo: Sliding Windows - Python tip of the day

Just a quick Python tip of the day.

I regularly find my self in the position of needing to slice lists with "sliding windows"

Like if I have the list {1,2,3,4,5,6,7,8} I would like to return {{1,2},{2,3},{3,4}..etc}

Just found this great way of doing it in dynamo. (I'm sure there are many ways of doing it, but quite simple this one anyways.)

tirsdag 25. oktober 2016

MeshToolkit: Terrain analysis in Dynamo

Just a quick showoff of the new mesh coloring possibilities in MeshToolkit v1.2.

Mind you that there is two different meshtypes in Dynamo and the MeshToolkit doesn't provide a converter between them unfortunately..

But the Springs packages does however! :)


Here's some links to the datasets used above + some extra analysis "tools"

RVT-file: Test_Topography

DYN-file: Mesh Analysis

mandag 24. oktober 2016

The Player: Dynamo for the masses

Revit 2017.1 is out and the best summary you'll find is over at the Revit cat: http://revitcat.blogspot.no/2016/10/whats-new-in-revit-20171.html

The biggest news would be the inclusion of the Dynamo player. This is a brand new tool located right next to the Dynamo icon on the manage pane focused on being a "player" for all your dynamo scripts:

Since the majority of Revit users in any firm is still not very proficient in Dynamo, this means that they can use the scripts that others have created without the hassle of opening dynamo. Awesome!

Comparable to Dyno: http://dyno.arcprojects.ru/  but a cleaner user interface in my opinion: 

Pretty basic. Set script folder, refresh, filter functionality and PLAY! :) You can also edit the scripts by hitting the pen icon and Dynamo will open

But, because there is a but, it only works for scripts with OOTB nodes.The script can't contain any custom packages. On the few test I've done it doesn't seem to work even when the user have these packages installed on their computer, unfortunately.

Still, with a bit of converting and copy/paste you can create scripts with user input as well. The little script below number elements based on a spline running through them. The functionality in the Python scripts below is copied from the Springs and Clockwork packages.

And the results:

fredag 24. juni 2016

Ammo: "Hidden Commands" in Design Script

I'm naturally curious and you kinda have to be to figure your way into the mysterious language of DesignScript. Not so long ago a forum post by Dimitar Venkov sparked my interest as to where to find these commands that are no where to be found. So I asked him, and he guided me to this place in the Dynamo Core. After some tests you can see some of my more useful findings below.

onsdag 22. juni 2016

Star Wars API and Dynamo

It turns out that having a second kid kinda ruin the amount of time one can spend on writing blogs, so here's a short summer-nerd-fest-post from me! :)

Step by step:
1. Luke Johnson posted this: https://twitter.com/lukeyjohnson/status/743343858155610113 
2. Somebody oughta do it..
3. Headed over to this gentleman
4. Voila! Head in to the package manager and search for "Swapi"! :)
(Ps. there is an example script in the extra folder.)


turns out R5-D4 is just 1 cm higher than R2-D2. Who would have known..

Have a nice holiday everybody!

mandag 2. mai 2016

Ammo: Point Analysis with Revit and Dynamo

First of all, congratulations to the Dynamo team on the 1.0.0 release. Long awaited, but the work is still in progress according to Zach Kron: http://dynamobim.org/dynamo-1-0-0-release/

The Dev team has also made some changes to the node names. Old definition with the old nodes will be "translated" into the new ones automatically, but it won't update inside code blocks so please be aware of the following changes: https://github.com/DynamoDS/Dynamo/wiki/Dynamo-Node-Changes

Secondly, check out the Prorubim packages right now. I mean right now.. The creator of this collection of packages is Aleksey Lobanov, which some of you already know have created the neat little Dyno addin. In the Prorubim DS Common Kit you'll find the small, but not insignificant GetVar and SetVar nodes which will take any of the standard Dynamo inputs and store it as a kind of a global variable for you to use elsewhere on the canvas. Nice!
Sadly it doesn't work with lists or code block inputs as of yet, but I really think the Dynamo Dev team should implement some of the same logic into "Portal"-nodes. That would be really helpful in this odd spaghetti world we operate in..

Now to the main point of this post. I have to admit one thing..
The analysis nodes in Dynamo located right under the Revit tab has passed right by me up until now. Seen them, thought they were for solar studies, not understood them one bit, moved on.

Thankfully, a cunning fellow over at Autodesk, Dieter Vermeulen, has shown the way in this here blogpost.

It can be used for anything really! If you have data and it is somewhat connected to points, UV's on a surface or maybe even a vector field you can use Dynamo to create a visualisation of that data inside of Revit.
To keep things fairly short I'll focus on the PointAnalysis in this post, the others (Vector and Face) works in a near identical manner so I'll guess you can figure it out.

Proof of concept: Height map on topography
Just a simple little test for showing the capabilities. Takes a topo, creates a point grid and project it on the surface. Measures the distance to topo and send the data to Revit.

A little proof of concept script
(Ps, the Unit Type node seems to be flawed in 1.0.0, have reported it..)
Once you've run the definition once the PointAnalysis node has sent the data to a view in Revit, but you will have to conjure the data up by doing a little view settings exercise.

1. Select the Default Analysis Display Style
2. Hit the new Display style icon
3. Choose your analysis style
Now figure out your settings with colors, sizes etc. and you're all set.

Few other examples of use:

Stadion C-values:

Where the best place is to be at the AU 2016 opening keynote according to my last post and visualised in Revit:

As I said, endless possibilities! :)

tirsdag 5. april 2016

Dynamo and Optimo: Optimizing your Carl Bass Keynote Experience

For a long time now, I've have felt an urge to explore the capabilities of the Optimo package in Dynamo. However it has seemed like such a montainous task that I've constantly postponed my interest. Easter break however, provided a window for dwelving into these things.

I've experienced that the best way to learn anything in the world of Dynamo is to have a problem that you can experiment on. As I'll have to be somewhat careful with examples from my daily job, I figured why not make it an abstract one.

So to get you in the mood, picture yourself at AU 2016. Tech nerds are swarming and Carl Bass (CB) is about to hold his opening keynote. This year however, there are no seats provided in the room and the room acoustics are horrendous. To accomodate this awful planning mistake, Autodesk has put up a number of bars serving the finest beers available.
(An appreciation party and opening keynote all at once make for one heck of a opening, right?)
Lazy as you are you want to be as close to the bar as possible while also be as close as possible to CB. Additionally you want to hear CB as good as you can as he speaks about coming trends and whatnot.

Or somewhat redefined: Given CB's position, the position of the bars and an acoustic map of the venue, which X,Y gives me the shortest distance to both beer and Mr. Bass, while also having the best acoustics?
Where to stand? (PS. stick figure not drawn with dynamo.)

My acoustic map. More black=Better Acoustics

Although the example is "dumb" it provides an interesting enough example case for taking Optimo for a run. Consider the post a Layperson's guide to the galaxy of optimization.

If you want to learn the indepths of Optimo I suggest going over to their website
here: http://bim-sim.org/Optimo/

Some optimization terms explained first: 
Simply put, the genetic optimization in the Optimo package tries to mimick Darwin's theory of evolution.
You make a 1. generation population, decides what is desirable "genes" and Optimo iterates through the "generations" to help you find the optimal solutions to your problem. The spesific algorithm used in Optimo is called NSGA-II
(If you want the whole shebang go to Wikipedia:https://en.wikipedia.org/wiki/Multi-objective_optimization)

This is just how many initial values we would like to evaluate.
In our example that would be how many different values of X and Y would we like to evaluate in our script. A larger population can have some effect on our outcome in terms of accuracy, but more importantly it drives the the main datastructure of the script, so:
Larger population=More datapoints=More readable graph.

Objective:The objectives in our example is to minimize:
  1. The distance from the given X,Y-values to the closest bar
  2. The distance from the given X,Y-values to CB
  3. The amount of white at the given X,Y according to the acoustic map. (Black is better.)

Fitness function:
First of all the term "Fitness" can be anything. It's just a measurement. All Optimo tries to do is to minimize the fitnessvalue for all objectives. This means that we have to design the fitness function so they report fitness in the way Optimo likes it.
If you want to maximize something, you would have to multiply that something with -1 so that the fitness reports lower values for better solutions. If you want the resulting fitness values to be in a comperable range consider introducing some factors to even the fitness functions out between each other (Like multiplying with 10, dividing by 1000 etc..)
In our example two of our fitness functions returns a distance in meters and the lower the distance the fitter the X,Y-value are. The third one obtains a brightness value from an acoustic map based on the given X,Y and the blacker the spot is the lower the fitnessvalue (aka "more fit")

This is our results. A Pareto front is the resulting graph of fitness values that indicates the solutions for the problem at hand where none of the fitness function results can be better without others becoming worse. Read about it here: https://en.wikipedia.org/wiki/Pareto_efficiency 
In our example we will obtain a 3d scatter plot because we have 3 objectives with varying fitness values. the value that is closest to 0 will be the most optimum value if you weigh all the fitness results the same.

The Main script:
The script below shows the basic layout for any script using Optimo. I'll try my best to explain each node to demystify the Optimo package. (It isn't as hard as it looks..) Please notify the organization of variables and fitness functions in lists as this is how the Optimo nodes works.

  • NSGA_II.InitialSolutionList:
    Sounds complicated, but isn't. Creates a number(PopulationSize) of random values between lower and upper limits for our position's X and Y respectively and adds x placeholder lists for our fitness functions. In our example it creates 5 sublists,
    [0] and [1] for random values of X and Y respectively.
    [2],[3],[4] containing just 0's for later to be overwritten with our fitness results.

  • Fitness functions:
    In this script we have 3 objectives, and each of the objectives has its own fitness function. All they do is some simple stuff to calculate the different fitness values,
Bar Fitness
Carl Bass Distance Fitness
Carl Bass Audio Fitness
  • NSGA_II.AssignFitnessFuncResults
    This is just a custom node from the Optimo package to assign our initial fitness results to the initial population list so that the resulting list contain both our X,Y-values as well as the fitness values.
  • NSGA Function
    This is where the magic happens and I'm not gonna go into this in detail. Shortly put it mimicks our main graph, except it has node which sorts the fitness result for each generation and add some randomness as to "mutate" into better fitness results.
  • Loop Completion Check
    This node acts as a counter and returns a boolean value which tells the loop node when to stop. The number you give as a input here equals the number of generations you will iterate through.
    Higher number=More generations=More precise results.
Pressing run begins the iteration and once we have some results we can start to interpret them.

You can observe two things from the above:
1. The resulting Pareto front. As you can see the distance from bars and CB are rather linear on the Pareto front, and the fitness values based on the acoustic map (Z-value) fluctuates a bit more, as one could expect. The closest point to zero is marked by a line.
2. The most optimal point to stand if you value all the objectives equally. (Marked red in gif)
As you can see, the point made by the three fitness values at index 12 is the point closest to 0,0 and we can then extract the X,Y values at index 12 from our population list.

Sooo, where to stand?.. Here:

Now, the Pareto front can look very different depending on the problem, and if I understood it correctly it's practically an entire science just interpreting them, but for many problems in the AEC-industry it should be quite readable. Searching for optimalization online will get you many hits based in Academia, but hopefully we'll see this on more practical cases in the future as it has awesome potential!

Ps. Datasets will not be provided as of yet since you'll learn much more by doing it your self. (That's at least my opinion.) Reach out if you're in dire need! :)

søndag 13. mars 2016

Ammo: Creating Isovists in Revit

I've been inspired lately by raytracing and what you can use it for in an Revit/Dynamo environment. The inspiration came from Twitter and the wonderful expertise the people I follow possess. It started with Dieter Vermeulens tweet and blogpost here. From there I tested a quick example by using some of the same logic in a topography environment in Revit, ended up looking like this:

(Just to let you know, the raytracing functionality in revit can't do topos, but it can use family instances generated with spring nodes. Hint hint..)

Anyway, I shared the above pic on Twitter and it got retweeted by, among others, "some guy" called Amar Hanspal. I may have to study the Autodesk Organization Chart a little better, because it was Dieter who had to point out that it was Autodesk' very own Product SVP . Holy cow.. Thanks!

Now another helpful guy called Dimitar Venkov, pointed me in direction of another wise gentleman called Kean Walmsley and his blogpost here.
Reading this post I got to know what isovists are, and naturally wanted to explore this a bit more. 

From Wikipedia: "A single isovist is the volume of space visible from a given point in space, together with a specification of the location of that point."

and a more graphical explanation of a 2d isovist because we are so visually oriented..

Dieter confided to rooms and I thought why not go outside that window and into the cityscape? In a preliminary design phase it would be nice to have some sort of analysis of what you actually see from the 73th floor balcony in your building wouldn't it?

So how do we get about this then? Well, the guys behind the acoustamo package have pointed out that the raytracing in Revit is a bottleneck. But I think it has worked pretty well so far. Another simplification I've made is that I have enclosed the entire test area with a circular wall that I've hidden in all but one view
to complete the isovist inside those walls. Could have been handled by importing all the geometry to Dynamo and creating some sort of enclosing geometry there, but I think it will suffice for all intents and purposes.


Raytracing and filtering:
(There are many way to produce the vectors which are fed into the RayBounce node, but i used spherical coordinates as it is applicable to 3d isovists as well.)

Line based result options:

Polycurve/patch based result options:

As this is more of a proof of concept I've included some different result presentations as examples. Let's hope some real architects come up with something better. (They're probably using grasshopper/rhino anyways, but still..)

Results from the various parts:

Regular detaillines:

Model curves overridden by color by lengths:
Visualisation in dynamo:

Model curves by perimeter:

Detail region created from the above model curves:

Direct shape by perimeter:

Now, there are many things you can use this for and the pics above are but a few examples. Still, the power of Dynamo is that it makes us able to create tools where WE can decide what the outcome will be by ourselves. 

Now if I only can figure out a way to create a 3d Isovist solid..

onsdag 9. mars 2016

Reinventing the Wheel: 3D DWG to Revit Family Instance

It has been possible for as long I've used Revit to import 3D-DWGs. Who haven't wondered why all of my DWG geometry is visible though my section has like 5 mm far clip offset?? (Hint: All elements in Revit needs a category..)
And if that didn't work maybe we tried exporting to SAT and import it in Revit. Pretty decent, but sometimes the geometry went curly when the coordinates were to high numbered.

I've also found myself using the 3D-DWG as reference and try to remodel the entire thing in Revit. But this is at best time consuming, and at worst plain wrong.

As stated, there are many ways to import 3D-DWGs into Revit, but I have yet to find one that really suit my needs.

Then I got inspired when I saw the new features in Dynamo 0.9.1 here. a little down on the page you can read about dwg import possibilities in 0.9.1. Alas, it is only available in Dynamo studio, which I find a little worrisome. Hopefully it will be integrated in Dynamo for Revit sooner, rather than later because this is miiiiles ahead of native Revit import of DWGs. Read all about the new functionality here.

Soooo, a test was required.

The original DWG:

Just a test file, but it is a bridge model consisting of surfaces made by software called Novapoint Bridge. 

In Dynamo Studio:

I'm particularly fond of the selector functionality!

In Dynamo/Revit:

Please notice again the FamilyInstance.ByGeometry node from the spring nodes package! Also I did a little translation to get the model closer to my local coordinates.
If the DWG nodes were available in Dynamo for Revit you could skip the SAT part all together and cope with one script.

The result in Revit:

You be the judge, but I for one thinks this method gives me a far more usable link between a 3D-DWG and Revit environment.

torsdag 3. mars 2016

Ammo: LandXML surfaces to Revit

LandXML to Revit really took a huge step forward with the introduction of the Site Designer for Revit, However this converts the surfaces from the LandXML file to a toposurface, and that is not always the best solution. It can be altogether wrong actually as I will show you later.

The workflow beneath converts a LandXML to a directshape in Revit. I guess you can further develop this to solids and whatnot, but unnecessary in my context.

Overall script:

Close up of meaty part:

I've used a combination of Lunchbox' XML nodes and regular string handling to get to the desired results. That being creating a mesh from the extracted points and index groups.

I may put my head on the block here now, but I've never fully understood what the index groups really is. All of a sudden it just struck me?.. a list of indexgroups always corresponds to a seperate list of points and the numbers contained in each index group is the index of points in the separate list that that together makes one mesh face! Hah, so easy! Dynamo is educating me I guess..

Digression end.

Notice the python script which uses regex in python to find all the names of the surfaces. Somehow this can also be done with the Clockwork regex nodes, but I'm not sure of the input syntax to those. Please notify me if you get it to work with the Lunchbox XML nodes or with Clockworks regex nodes! :)


And the result:
And here you can see the difference. Direct Shape on the left, Topography generated with Site Designer on the right. As you can see the result from site designer is unusable. I'm not familiar with the causes, but Revit topo tools are really bad when points have the same XY value in different heights, so I'm guessing it has something to do with that fact.

I haven't tested this 100% through and through, but I'll give you the link for the script (0.9.0) and let you take it for a spin. Please feel free to comment and maybe we can make the script better together! :)