Fix Python code to get all walls of type, and console?

Hi, can you take a look at my Python script and see if you can spot an error? I get nothing/no result in a watch panel.

Also, a question: is there a debugger console window in Dynamo I can use to catch exceptions so I can self-fix my code in the future?

DynamoNode

import sys
import clr
import RevitServices
import System
import Revit

clr.AddReference('ProtoGeometry')
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")
clr.AddReference("RevitNodes")

from Autodesk.DesignScript.Geometry import *
from RevitServices.Persistence import DocumentManager
from Revit.Elements import *
from RevitServices.Transactions import TransactionManager

userWallType = IN[0]

doc = DocumentManager.CurrentDBDocument

walls = FilteredElementCollector(doc).WhereElementIsElementType(userWallType).ToElements()

OUT = walls

Hi @Breton_Smith ,

You are currently working in the Custom Node editor environment (.dyf), indicated by the yellow background.
In this environment you can’t run scripts, only create Custom Nodes to use in scripts.

What you could do is copy-paste the Python node itself into a .dyn-workspace and see if running the code there (on a single item, not a list) returns any errors.

The method WhereElementIsElementType() takes no arguments.

Link to method.

Hey @Breton_Smith,

Here is a FilteredElementCollector to grab the walls and an if statement to grab ones of the type you are looking for.

import clr
 
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc =  DocumentManager.Instance.CurrentDBDocument
 
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
 
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
 
#collect all walls in the project...

walls = FilteredElementCollector(doc).OfClass(Wall).WhereElementIsNotElementType().ToElements()

#Empty Lists

list = []

#code

for w in walls:
	if w.WallType == ViewType.userWallType:
		list.append(w)
	else:
		pass
		
#output

OUT = list

I would keep this website handy when working with the FilteredElementCollector, I think your references were coming in wrong. Lot of good stuff on this site to get it to do exactly what you want it to.

Hope this helps!