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
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.
- Open an existing model that contains a 3D view with Reinforcement and leave the 3D view active.
- On the Manage ribbon, click the Dynamo Icon and start a new dynamo session.
- Create the following nodes as shown below (Leave the Python Script Node to step 4).
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.
Double Click the Python Node in the grey area as shown below to open the ‘Edit Python Script’ dialog box.
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) views = UnwrapElement(IN) #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.
Add an additional input to the Python node as shown below and wire the Rebar elements into IN and the view into IN. (Note that even if you are just requiring one view it must be a list for the Python Code to run without errors.)
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.
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!
Revit and Dynamo – Set Rebar Unobscured and solid