lunedì, febbraio 19, 2018

Robot Structural Analysis via Dynamo in Python

Ever wanted to do more with your Robot and connect it to Revit and Dynamo but you didn't know how to do it?

Fire up Robot, Revit and Dynamo for Revit, in Dynamo create a Python Script node and copy the following code (make the necessary adjustments to match the Robot release you are working with).

Robot offers a COM interface, very much like Excel for Dynamo, so in principle you can create your package of nodes using Zero Touch, but what if you don't use C#?
You can do it with Python! you just need to know what to look for.
First, you need to make sure you have the Robot SDK installed. If you install it from the media, you can find it here (pay attention to the release you want to work with):

C:\Autodesk\WI\Autodesk Robot Structural Analysis Professional 2017\x64\Tools\RSASDK

After the install you can find the SDK content in here (again, watch out for the release):
C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2017\SDK

Now you should be good to go!

In the code sample I'm sharing there are two behaviours wrapped inside two if statements.
The first starts at line 13 and it will read the bars you have in the Robot model and recreates them as Dynamo lines. It also returns the bar number, and the label used for the bar section).

The second starts at line 25 and creates a new project in Robot and adds 4 nodes and 3 bars.

You can start from here to leverage the Dynamo geometry and interoperability with Excel to recreate your model in Robot, or again read data directly from Revit elements (even imports from different platforms) and create an analytical model in Robot.

Look at the SDK in Robot if you want to know what you can do. And remember, if you are not having fun in coding, you are doing it wrong.

1 commento:

  1. Hi Paolo, very interesting and nice work. An alternative to the path that you mention is to use the connection to RSA that lies in the Dynamo "Analyze" package. (Location):

    user = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
    clr.AddReferenceToFileAndPath(user +r"\Dynamo\Dynamo Revit\1.3\packages\Structural Analysis for Dynamo\bin\RSA\interop.RobotOM.dll")

    This way the version of RSA used becomes redundant.