Since I am still trying to Learn python, I used Chat GPT to ry and generate code to lsit all walls currently in use in the model.
This is what Chat GPT came up with:
# Import necessary modules
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory
from pyrevit import revit, DB
# Initialize the Revit document
doc = revit.doc
# Define the BuiltInCategory for Walls
walls_category = BuiltInCategory.OST_Walls
# Create a FilteredElementCollector to get all wall elements in the document
wall_collector = FilteredElementCollector(doc).OfCategory(walls_category)
# Create a list to store the in-use walls
in_use_walls = []
# Iterate through each wall and check if it's in use
for wall in wall_collector:
if not wall.IsDemolished(doc.ActiveView) and not wall.IsHidden(doc.ActiveView):
in_use_walls.append(wall)
# Print the names of in-use walls
for wall in in_use_walls:
print(wall.Name)
# You can also access other properties of the walls if needed
# For example, wall parameters like height, thickness, etc.
when I use the PythonShell to test it, it gives me an error saying there is no module 'pyrevit'. I do have pyRevit installed.
Hope someone can help with this. Thanks!
hi
if you want all instance of any categories, just simply add ".WhereElementIsnotElementType()" at the end of you wall_collector.
I'm afraid ChatGPT s not savvy enough about the Revit API for it to be much use. I have heard reports of people using it to improve their Python programming skills inside a Revit add-in, but those people had prior basic Revit add-in implementation experience. To get started with the Revit API and programming Revit add-ins, I suggest that you follow the old-school approach of reading the getting started material and working through the My First Plugin video tutorial:
Can't find what you're looking for? Ask the community or share your knowledge.