Sunteți pe pagina 1din 29

CI124118

MEP Modeling Made Easy with Dynamo


Cesare Caoduro
Geodata Engineering Spa

Learning Objectives
• Understand how to approach an alignment-based model
• Learn how to create families optimized for a rule-driven algorithm
• Learn about the basics of Python and Code Blocks to improve Dynamo “out of the
box” capabilities
• Learn how to use direct integration between Civil 3D and Revit to extract alignment
details

Description
In this class, we’ll understand how to use Dynamo software to perform daily activities from a
Mechanical and Electrical contractor point of view—starting from simple parameters mirroring and
going to more-advanced techniques, including the use of Python scripting. The requirement of a
LOD400 model for 34 kilometers of tunnel can be quite complex if you don't choose the right way.
Starting from a simple Microsoft Excel file with the tunnel alignment, you'll be able to create a fully
detailed design, including all the information useful for the facilities management system. Dynamo
is the key when you've got to place thousands of elements based on rules and algorithms. This
is a real-world applications in one of the most iconic rail projects in the Middle East

Speaker(s)
Cesare is an experienced BIM enthusiast and user of Autodesk Revit MEP. He has more than
ten years of continuous experience using this package and has a particular interest in
researching, developing and implementing BIM strategies, methodologies and workflows.
Pursuing the continuous development and research of new strategies/workflows to improve
efficiency and productivity using generative design and visual programming. Cesare believes the
most important pieces of the “BIM puzzle” to be the 3C’c – Collaboration, Communication and
Coordination. Cesare’s passion for BIM is translated into the outstanding quality of achievements
delivered. He is a strong believer in teamwork that is always committed and dedicated to deliver
the best in each project. He is also well known for his creative visions and ideas – an innovative
and a practical thinker – “simplicity is the most sophisticated method”. His work and experience
has developed through exposure across different projects and countries including Qatar and
Denmark, this provides him with a high cultural intelligence and capability of adaption to any
cultural environments/challenges.

Page 1
Contents
MEP Modeling Made Easy with Dynamo.................................................................................... 1
Introduction ................................................................................................................................ 3
Tunnel modelling........................................................................................................................ 3
The power of curves ................................................................................................................................. 5
Back to basics ............................................................................................................................ 9
LandXML importer .................................................................................................................................... 9
Let’s code ................................................................................................................................................ 11
Subassembly composer .......................................................................................................................... 14
Sprinkler System To CAD .........................................................................................................19
Shortest Path Problem ..............................................................................................................25
Dijkstra's algorithm ................................................................................................................................. 25
Conclusion ................................................................................................................................29

Page 2
Introduction
The idea of this class it to share some best practices related to infrastructure modelling with a
particular focus on MEP modelling.
Parametric design is a real game changer during the construction phase in order to complete
complex and repetitive tasks right on time.
This hands-out targets users with all kind of experience but, to take the most from this document,
a previous experience with Dynamo, Revit and a basic knowledge of Python can be useful.
Let’s begin!

Tunnel modelling
The first time the Engineering team approached the modelling process of a Tunnel, was a little bit
scary because, as always, the schedule was very tight and the number of tasks to be performed
was huge.
As main challenges we identified:
1. Revit out of the box capabilities to model complex alignements. Basically Revit is not ready
to model pipes, cable trays and ducts following complex 3D splines path (pipes should be
of a length of 6 meters and cable trays about 3 meters)
2. Once the models is ready, we need to import information from the as built, especially
related to electrical lighting, equipment, sockets, earthing bars, etc.
3. We didn’t have a clear picture about how the model will be used, later in the process, from
other stakeholders.
It is immediately clear that Dynamo is the best solution to:
1. Drive the model of the tunnel, including the first stage concrete. This model was produced
directly from the main contractor
2. Using the same Excel file provided for the tunnel, drive the linear systems in the tunnel
using simple curve operations
3. Place single instance families using the same technique and link as-built data from an
external Excel file

Page 3
The result was pretty good and finally we delivered all the tunnel models including the linear
systems.

Page 4
The power of curves
Curves are one of the most powerful geometric element in Dynamo. We can use curves to drive
almost everything and we can create curves starting from Revit elements or from an Excel
spreadsheet.
Let’s try to understand how to use an axis curve and hot to split this curve with a predefined
interval, create vertical and horizontal offsets.

Page 5
We can easily find points on the curve using a range. As start we can use 0 (the starting point of
the curve), end will be the total length of the curve, step will be value that we want to use as
increment. Instead of using the range node we can use code blocks with the right syntax.

It’s important to create a coordinate system along the curve with the axis aligned to the tangent
vector on each point (this is the coordinate system we’re going to use to calculate the horizontal
and vertical offset)

Page 6
Using the vector components of the coordinate systems we can find the right direction to move
points. From the picture you can see that X axis is along the curve tangent, Y axis is pointing
upright and Z axis is normal to the curve (not the curvature)

The last operation is to apply a geometry translate of the list of points, using the vectors and an
variable a value for both vertical and horizontal offset (note that units should reflect the project
units, in this case meters). Note that we apply first the vertical translation and then we use the
result points as an input for the horizontal translation. Finally, we can draw a nurbs by points as
a result of the translation.
Using this basics workflow and a couple of adaptive components families, we could manage to
model pipes and cable trays along all the tunnels with few clicks.

Page 7
The same technique can be applied to place a cross section along the curve and then create a
solid by cross sections (next in the hands-out).

Page 8
Back to basics
After the first approach, I realized that a model is fundamental in the early stages of a project
when we don’t have exact information about the alignment, we don’t have final information
regarding the section and we need a fast a way to draft a 3d model a starting point for the design
process.
Another point to take into account is the possibility to collaborate with other consultant using
different authoring software.
The solution can be to use LandXML as main format to exchange both horizontal and vertical
alignment. Using the LandXML can be quite tricky especially because Revit is not able to manage
all the types of curves that are used in road and rail design.
Those curves are called clothoid and, if you try to import a LandXML using the Site Designer in
Revit, you’ll quickly find out that Revit hates clothoid.
I’m not going to explain deeply what is a clothoid but, just as information, the clothoid is a curve
with a variable radius following a very difficult mathematical equation. We have a clothoid after a
straight stretch and before an arc curve, to give the opportunity to the driver to enter the curve in
a “nice way”.

LandXML importer
In a LandXML the vertical (profile) and horizontal alignment are separated so we can easily
manage these two entities in a different way.

Page 9
In the hand-out I’ll focus on the alignment as an example on how to approach this problem using
Python within Dynamo.
First of all we need to read the XML file and “parse” this file trying to find the right “tags”. The main
tag is “Alignments” and inside this tag we can find all the alignments in the project (in this case
we only have one alignment).

We can point the LandXML file with a simple file path node.

Then, to simplify the placement of the alignment in the project, I’m always trying to normalize the
coordinate system, moving the first point to 0,0.

Page 10
The other number you can see in the picture is the number of segment that we want to use to
discretize the clothoid. Yes, the only way to draw a clothoid in Revit is to use a mathemathical
approximation of the equation and, to do that, we need to decide how many points we want to
use to approximate the curve.

Let’s code
Now is time to code in but, if you’re familiar with this, just explore the code provided as example
in the dataset. To open a custom node just right click on the node and select Edit.

After reading the LanXML file we can start to parse different tags to identify the different type of
curves that we can find in alignments. Lines, curves, spirals, etc.

Using couple of string functions we can isolate text from the LandXML and extract coordinates
and attributes.

Page 11
Lines and curves are pretty easy, because we only have points (2 or 3) that we can reproduce in
Dynamo environment using Point.ByCoordinates, as we are used to do using nodes, this time
using numbers.
The most difficult part of the algorithm is, of course, to draw the spiral curve (our clothoid!) where
we need to use couple of attributes to calculate the equation.

The first time the clothoid is placed in the 0,0 coordinates then we need couple of translation to
place it in the correct location, apply the correct rotation and flip it based on the value of the
rotation direction (cw, ccw)

The final result is pretty amazing, isn’t it?

Page 12
With the same approach you can extract the profile (vertical alignment) and then combine the
information to create the 3D alignment:
• X, Y from the horizontal alignment
• Z from the profile

Careful is not going to be very easy!

Page 13
Subassembly composer
Once you have your alignment you can use it to build the concept model of the tunnel. I’ve always
loved the subassembly composer in Civil 3D and, if you’ve a quick look at it, you’ll immediately
understand that there’re similarities with Dynamo, in terms of parametrization. So why we don’t
have our subassembly composer in Dynamo?

Using the result of the previous workflow we can select a stretch of the tunnel to be used as axis.

Page 14
The main node is just made by multiple basics nodes, emulating Civil names.

Page 15
The good news is that no Python is used in these nodes so they’re really simple to be replicated
and implemented.

Page 16
When the line is selected…

Page 17
This is the result!

The tunnel is completely parametric and, if you run Dynamo in automatic mode, you can change
the values connected to the main node and watch the tunnel changing shape.
This is just the starting point and you can work to implement your own sections and subassembly
composer nodes. To place the cross sections along the curve, you can use the simple technique
explained in the first chapter.

Page 18
Sprinkler System To CAD
Let’s jump now to something more related to MEP modelling. The question is simple: why we
need to export a model to AutoCAD and why can’t just use the built-in functionality?
Well, the answer is simple as well: when it comes to sprinkler systems, Revit doesn’t have the
right tools to calculate and size so, most of the times, designers are used to use external
application to run their calculation and guess what? Those application can’t connect with Revit
and most of the times they can only read DWG or DXF. At the same time you need a proper DWG
without round fittings or lines useless for the calculation, just straight lines in a particular layer.
To solve this issue, we need to extract the lines from the systems and kind of “extend/trim” these
lines where we have fittings and then remove all the other lines that can cause trouble to the
external application.

Page 19
Again, we have to use Python to run the necessary workflow and clean all the lines before
exporting to AutoCAD.
The process is quite simple:
1. Isolate in different list:
▪ Pipes
▪ Pipe fittings
▪ Pipe Accessories
▪ Sprinklers
2. Filter fittings to fittings connection from the list: this can cause some issue when
we need to calculate how to extend curves
3. Find the closest fitting to a curve and extend end/start of the curve to the fitting
point (this is the most important part)
4. Use Win32COM to export runtime curves and points (sprinklers) to AutoCAD

You can find all the scripts available in the dataset provided with the class so, I’m
not going to focus too much on the programming details.

Page 20
First we need to isolate different categories from a selection list

The next step is to remove fitting to fittings connections from fittings, accessories and sprinklers

Page 21
This is the most tricky part but is necessary to avoid wrong calculation. The worst part is that we
need to manage separately each kind of fitting and progressively filter from the main list of fittings.

Finally we can find the closest fitting to the end or start of each curve, and extend the curve to
that point. To find the closest point the best way is to use a tolerance that defines a radius where
to search points. The closes one is the point that minimize this value.

Page 22
Page 23
And the final result

Last but not least, the Python script to export lines to AutoCAD

Page 24
Shortest Path Problem
Another interesting problem to be solved is to find the shortest path between two points in the
project. In this particular example I’ll focus on how to connect two different elements (swithboards
or panelboards) using the existing cable trays and, to do this, I’ll choose the best way to reduce
the amount of cables.

Dijkstra's algorithm
“Dijkstra's algorithm is an algorithm for finding the shortest paths
between nodes in a graph, which may represent, for example, road
networks. It was conceived by computer scientist Edsger W. Dijkstra in
1956 and published three years later.
The algorithm exists in many variants; Dijkstra's original variant found the
shortest path between two nodes,but a more common variant fixes a
single node as the "source" node and finds shortest paths from the source
to all other nodes in the graph, producing a shortest-path tree.” (Wikipedia)
The idea is to find all connected elements. Then build a relation network where, each element
(cable trays, cable tray fittings, etc.) is a node and each logical connection is an edge.
As example: the first cable tray (A) is connected to a fitting (B) and then to another cable tray (C)
so, we have 3 nodes and 2 connections A-B, B-C. Those connections can be bi-directional so we
go back and forward in the graph to find the right path.
There’re many implementation of this algorithm available in all the existing programming
languages (python, c++, c#, javascript, etc.) so we choose the one available for python to be used
in a Dynamo node.

Page 25
But first of all, we need to find nodes and relations. In Revit API each MEP element has connectors
(depending on the number of connection) and each connector has an owner. This is the way we
find where an element is connected and how to build the relations.

Once we have the owner we can easily build a list with nodes and connections (those connection
can be multiple for each node)

Page 26
Finally, we can implement the path finding algorithm giving the list of connections in the graph.

As result we can give both, the list of elements and their location curves/points.

Page 27
Writing a string in each elements and setting a view filter, we can also highlight the shortest path
in the viewport.

Page 28
Conclusion
As you can see from these examples Python is the key to automate complex task.
There’re some limitations in the IronPython, which is the version provided with Dynamo but in
most of the cases, you’ve all the tools to deal with native Revit elements and manipulate all kinds
of data available as parameters in the project.
Start today a Python course as a first step to develop your company tools considering Dynamo a
“drafting” platform.
All the material available in the dataset is provided as open source, feel free to modify it and, if
you like it, just mention me 😊
Feel free to connect with me on linkedin or twitter to share ideas and workflows!
Cesare

Page 29

S-ar putea să vă placă și