Set Material of Category to Null

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???

THX

Have u tried with blank? ("")

Yes, I did. But that doesn’t work. Seems to a problem with the type.

Have you tried feeding it a null?

Yes - but didn’t work.

Hello @norbert_graeser …how about this ?

PS…the way i have done it in the image above, has this issue it delete the material from the library…

I havent find out yet, how to just empty the subcategori material, set to no material

Maybe this has some clue

1 Like

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.

3 Likes

Hello,
set Material to null (None) works perfectly (no need parameter)

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

from Revit API doc

3 Likes

You can also use

Mat = ElementId.InvalidElemtId

https://www.revitapidocs.com/2015/08ae8886-6ab3-3ef5-d2e0-0da2ffa7bd2c.htm

3 Likes

Thank you for your help!

"cat.Material = None" is what do the job in a perfect way.