How do you pass a "null" to API function in Python

Hello Everyone;

I am trying to create a Python Script node in dynamo that would return any Dimension elements used inside of a Filled Region object. I see from the Revit Lookup tool that Snoop Dependent Elements gets to where I want to go. Looking at the API, I see a GetDependentElements method and note that I can get all elements by passing a “null” to the method. So the question is: How do you do that in Python?

region = FilteredElementCollector(doc).OfClass(FilledRegion).WhereElementIsNotElementType().ToElements()

out = []

TransactionManager.Instance.EnsureInTransaction(doc)

for r in region:
	z = UnwrapElement(r)
	out.append(z.GetDependentElements())
#	out.append(z.GetSubelements())
TransactionManager.Instance.TransactionTaskDone()

Sincerely;
Michelle

PS: The overall goal here is to examine all filled regions and masking regions for embedded dimensions and change their style to a company approved style.

Have you tried putting ‘None’?

Failing that wombat has a null node you could feed in.

1 Like

Hi,
according to the API doc, It’s necessary to add an ElementFilter as argument

an example

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

filledRegion = UnwrapElement(IN[0])

def get_DependDims(elem):
	#filterElem = ElementClassFilter(clr.GetClrType(DB.Dimension))
	# OR
	filterElem = ElementCategoryFilter(BuiltInCategory.OST_Dimensions)
	lst_dimIds = elem.GetDependentElements(filterElem)
	lst_dim = [doc.GetElement(xId) for xId in lst_dimIds]
	return lst_dim
	

OUT = get_DependDims(filledRegion)
3 Likes

Hello c.poupin;

The line “filterElem = ElementCategoryFilter(BuiltInCategory.OST_Dimensions)” in your example did the trick. I now need to process the results and get at the dimension style settings.

By the by, mid-way down the documents page, it says that the filter element Can be NULL to return all dependent elements. So I am still wondering, out of curiosity and future use, how do you pass a NULL? I did try “none” and “None” and that did not work.

Sincerely;
Michelle

1 Like

NULL in C# is equivalent to null in Dynamo is equivalent to None in Python.

So the example of utilizing the Element.DependentElements method would be as follows in Python:

5 Likes