I am using Revit 2016 R2 Update 2 , Dynamo 0.9.1.4062, Dynamo for rebar 0.2.7
I’m trying to toggle the appearance of rebar in the current view between solid and line. If I put the same code in a script that creates rebar it works. But this doesn’t when I select existing rebar.
I think the fault lies in your Rebar input in the Rebar.SetUnobscureInView node. As you can see in my post from March 7th I input the Rebar outputted from the Rebar.ByCurve node into the SetSolid node. I see that you use an Element Types node. Try switching to your output from the Rebar.ByCurve node. That should do it I think
Yes, I saw that, but I’m trying to do this through a rebar which is already placed in my model, not created though Dynamo. Is it only working witch bars created through Dynamo?
Aah, ok. Hmm, I think my method only works with rebar generated from Dynamo. However, Im pretty shure Dynamo can handle existing rebar. I have not tried it though
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference("System")
from System.Collections.Generic import List
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
#Preparing input from dynamo to revit
rebarElements = UnwrapElement(IN[0])
views = UnwrapElement(IN[1])
#Change rebar in transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for view in views:
for rebarElement in rebarElements:
rebarElement.SetUnobscuredInView(view,1)
TransactionManager.Instance.TransactionTaskDone()
OUT = rebarElements
I’ve tried inputing your code and I’m getting the following error:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 29, in
TypeError: iteration over non-sequence of type View3D
@Brenden_Picton The view must be in a list.Use List.Create or { 3d }; in a codeblock. If you download the custom node, it will take care of this for you.
Thanks for sharing your code, @Einar_Raknes.
I made some improvements for my implementation and thought I’d post it back.
It now accepts single rebar objects and selections that include other objects.
import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference(“System”)
from System.Collections.Generic import List
clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
#Preparing input from dynamo to revit
rebarElements = UnwrapElement(IN[0])
views = UnwrapElement(IN[1])
#Change rebar in transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for view in views: #Check if single rebar is selected
if type(rebarElements).name == “Rebar”:
rebarElements.SetSolidInView(view,1)
else:
for rebarElement in rebarElements: #Check if object is rebar
if type(rebarElement).name == “Rebar”:
rebarElement.SetSolidInView(view,1)