I try to set the material of a Revit Category to Null / Empty. Used the “Set SubCategory Properties” from GeniusLoci, what works well for assigning materials. But how to “deassign”? Inside Revit I can use the Button in the lower left. But how to do this with Dynamo???
Ah! It’s an element ID. The old -1 trick if I am not mistaken. Not sure how to produce that without Dynamo so editing the Python Konrad posted in that topic is the likely best path forward.
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
toList = lambda x : x if hasattr(x, '__iter__') else [x]
#Preparing input from dynamo to revit
cats = toList(UnwrapElement(IN[0]))
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for cat in cats:
cat.Material = None
TransactionManager.Instance.TransactionTaskDone()
OUT = cats