0% found this document useful (0 votes)
3 views1 page

Revit Category Retrieval Script

The document contains a Python script designed for use with Autodesk Revit API. It defines a function, GetCategory, that retrieves the category ID of various Revit elements based on their type. The script processes input elements and returns their corresponding categories, either as a list or a single category object.

Uploaded by

lutruhbc
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Revit Category Retrieval Script

The document contains a Python script designed for use with Autodesk Revit API. It defines a function, GetCategory, that retrieves the category ID of various Revit elements based on their type. The script processes input elements and returns their corresponding categories, either as a list or a single category object.

Uploaded by

lutruhbc
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import clr

[Link]('RevitAPI')
from [Link] import *

[Link]("RevitNodes")
import Revit
[Link]([Link])

def GetCategory(item):
if not item: return None
objtype = [Link]().ToString()
returnID = None
if objtype == "[Link]": returnID =
[Link]
elif objtype == "[Link]": returnID = [Link]
elif objtype == "[Link]": returnID =
[Link]
elif objtype == "[Link]":
if [Link]:
[Link]("RevitServices")
import RevitServices
from [Link] import DocumentManager
returnID =
[Link]
elif objtype == "[Link]":
if [Link]: returnID = [Link]
elif hasattr(item, "Category"): returnID = [Link]
if returnID:
try: return [Link]([Link])
except: return None
else: return None

items = UnwrapElement(IN[0])

if isinstance(IN[0], list): OUT = [GetCategory(x) for x in items]


else: OUT = GetCategory(items)

You might also like