Revit 2017.1 & Dynamo Tutorial – Setting All Rebar Visible and Solid in View

As many of you will already know, controlling the visibility of reinforcement within Revit can be challenging and time consuming as each new rebar modelled needs to have the visibility set, for example, you create a new range of rebar and then are required to click ‘View Visibility States’ and then select the views that you wish to see the rebar unobscured and ‘as solid’.

Link to Video: https://youtu.be/BmDQ02GhtfE

revit-rebar-view-visibility

In this tutorial I will take you through the steps required to write your own app to automatically control the rebar visibility, the tutorial will use Dynamo 1.2.1 and Revit 2017. With this tutorial no external packages are required.

Here is the end result of the tutorial shown in the video clip below.

dynamo-player

  1. Open an existing model that contains a 3D view with Reinforcement and leave the 3D view active.
  2. On the Manage ribbon, click the Dynamo Icon and start a new dynamo session.
  3. Create the following nodes as shown below (Leave the Python Script Node to step 4).

revit-rebar-visibility-dynamo

I have labelled each node so you can understand how each node operates but feel free to watch the short tutorial video if you have never used Dynamo before.

4. In the Search Bar in the Node library search for Python and add the Python Script node as shown below.

python-script-node

Double Click the Python Node in the grey area as shown below to open the ‘Edit Python Script’ dialog box.

python-edit-script-node

Copy and Paste the Python Script below and Accept Changes (to Line 35).


import clr
#Import RevitAPI for Rebar Control
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference("System")
from System.Collections.Generic import List

# Import RevitNodes
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

#Assign Inputs and Output
rebarElements = UnwrapElement(IN[0])
views = UnwrapElement(IN[1])

#Change rebar Visibility
TransactionManager.Instance.EnsureInTransaction(doc)
for view in views:
 for rebarElement in rebarElements:
 rebarElement.SetUnobscuredInView(view,1)
 rebarElement.SetSolidInView(view,1)
TransactionManager.Instance.TransactionTaskDone()

OUT = rebarElements

Your Code should now look like the image below.

python-code
Add an additional input to the Python node as shown below and wire the Rebar elements into IN[0] and the view into IN[1]. (Note that even if you are just requiring one view it must be a list for the Python Code to run without errors.)

python-script-node-with-second-input-added

Dynamo Player (Revit 2017.1)

For those of you running Revit 2017.1 you can run this simple tool directly from the Player without having to open Dynamo, this could be very useful for people that want to use these tools without wanting to open Dynamo.

On the Manage Ribbon, select the Dynamo Player Icon as shown below.

dynamo-player-icon

The Dynamo Player will then launch, you need to select the folder icon as shown in the image below and browse to the folder that contains your .dyn files. You can then simply play the script!

dynamo-player-folder

Revit and Dynamo  – Set Rebar Unobscured and solid

Advertisements

About lawrenceh

I am employed by Excitech, one of the largest Autodesk resellers in the UK, to provide training and other services such as implementation and project support to our clients. The main products I get involved with are Autodesk Revit Structure, Dynamo & Autodesk Inventor. My personal interests include aviation, engineering and walking.
This entry was posted in Tutorials and tagged , , , , , , . Bookmark the permalink.

9 Responses to Revit 2017.1 & Dynamo Tutorial – Setting All Rebar Visible and Solid in View

  1. Pingback: Revit 2017.1 & Dynamo Tutorial – Setting All Rebar Visible and Solid in View - Revit news

  2. Thomas Kunsman says:

    Very nice! Thanks!

  3. Mark ratcliff says:

    Hi.
    I’m getting the following error message on the python node.
    “Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
    expected an indented block”
    Any ideas on what I’m doing wrong?
    Thanks for your tutorials.

  4. lawrenceh says:

    Yep, Make sure that the Tabs are set exactly as my screen capture in the blog.

  5. Mark ratcliff says:

    Thanks, now it works.

  6. lawrenceh says:

    Hi Mark, Python is very fussy about indents so they have to be exact. Glad it worked for you.

  7. bauenmitbim says:

    Folks, sorry for this commercial, but for those of you who think that working with Dynamo and Python is too complex or time consuming, please check our App SOFiSTiK Reinforcement Detailing (/https://apps.autodesk.com/RVT/en/Detail/Index?id=354751925106132518&appLang=en&os=Win64). We solved this and many more problems and believe that using it makes all reinforcement detailing work much more productive.

    Thomas Fink
    SOFiSTiK AG

    • lawrenceh says:

      Thanks Thomas, all good points and I can varyfy that the SOFiSTiK tool is a good addition to standard reinforcement within Revit. However, the simple script gives us a few quick wins for those not using SOFiSTiK.

  8. Pingback: Weekly Roundup – 2017.05 | The BIMsider

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s