Hi,
I’m trying to set a parameter to none for a Parent View parameter and have failed miserably. See attached the different attempts.
Any ideas?
Thanks a lot
Hi,
I’m trying to set a parameter to none for a Parent View parameter and have failed miserably. See attached the different attempts.
Any ideas?
Thanks a lot
the parameter Is Read Only
I was unable to find a way using OOTB nodes, but you can do it within a Python node:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import ElementId
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
element = UnwrapElement(IN[0])
name = IN[1]
invalid = ElementId.InvalidElementId
parameter = element.LookupParameter(name)
parameter.Set(invalid)
I’ll give it a shot in a bit. Thanks a lot
Judging by the error, it looks like View.GetByType is outputting a list of views (or possibly a single view nested in a list). Try this code instead:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import ElementId
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
elements = UnwrapElement(IN[0])
if not hasattr(elements, '__iter__'):
elements = [elements]
name = IN[1]
invalid = ElementId.InvalidElementId
for element in elements:
parameter = element.LookupParameter(name)
if parameter:
parameter.Set(invalid)
I’ve also implemented an if statement which ensure that the parameter actually exists so that detail views without a parent view are skipped.
Wish my Python chops were good enough to tell, but is it possible there’s a syntax mistake I’m making when copying the code? I still get an error even when trying a single view and not a list of views. I’m feeding a known detail view made with a callout. I get this:
“Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 19, in
Exception: Attempt to modify the model outside of transaction.”
Oops, I forgot to add a transaction manager. See below:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import ElementId
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
elements = UnwrapElement(IN[0])
if not hasattr(elements, '__iter__'):
elements = [elements]
name = IN[1]
invalid = ElementId.InvalidElementId
TransactionManager.Instance.EnsureInTransaction(doc)
for element in elements:
parameter = element.LookupParameter(name)
if parameter:
parameter.Set(invalid)
TransactionManager.Instance.TransactionTaskDone()
This did the trick! I knew there was something missing!
Thanks a lot man this was YUGE