Clockwork Python Script stopped working

Longtime reader, first time poster, as you can probably tell from below I haven’t yet figured out how to properly post code, sorry about that in advance.

I was using the Clockwork node “element.Location” to filter out unplaced rooms, but one day it just started giving me all false’s on the Has Location output. I uninstalled all my nodes and reinstalled, and I thought that fixed it but it’s only working correctly half the time and I’m stumped as to why, I don’t know much about Python but it doesn’t make sense to me why it would stop function correctly. I don’t see anything in the script that would be affected by another package being installed, am I right? Dynamo version 1.3 and Clockwork 1.x, Revit 2017.2

import clr
import math
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

items = UnwrapElement(IN[0])
pointlist, curvepointlist, ispoint, iscurve, curves, haslocation, angles, hasrotation = [], [], [], [], [], [], [], []

for item in items:
try:
# points and text notes
pointlist.append(item.Coord.ToPoint())
ispoint.append(True)
iscurve.append(False)
haslocation.append(True)
hasrotation.append(False)
except:
try:
loc = item.Location
if loc.ToString() == ‘Autodesk.Revit.DB.LocationCurve’:
# line-based elements (e.g. walls)
curvepoints = (loc.Curve.GetEndPoint(0).ToPoint(),loc.Curve.GetEndPoint(1).ToPoint())
curvepointlist.append(curvepoints)
curves.append(loc.Curve.ToProtoType())
ispoint.append(False)
iscurve.append(True)
haslocation.append(True)
hasrotation.append(False)
elif loc.ToString() == ‘Autodesk.Revit.DB.LocationPoint’:
# point-based elements
pointlist.append(loc.Point.ToPoint())
ispoint.append(True)
iscurve.append(False)
haslocation.append(True)
try:
angles.append(math.degrees(loc.Rotation))
hasrotation.append(True)
except:
hasrotation.append(False)
else:
# check for host objects outlines (floor slabs etc.)
try:
refs = HostObjectUtils.GetTopFaces(item)
blines = []
bpoints = []
for ref in refs:
try:
boundaries = item.GetGeometryObjectFromReference(ref).GetEdgesAsCurveLoops()
for loop in boundaries:
cloop = []
clooppoints = []
for line in loop:
cloop.append(line.ToProtoType())
curvepoint = (line.GetEndPoint(0).ToPoint(),line.GetEndPoint(1).ToPoint())
clooppoints.append(curvepoint)
blines.append(cloop)
bpoints.append(clooppoints)
except:
pass
if (len(blines) > 0):
curves.append(blines)
curvepointlist.append(bpoints)
iscurve.append(True)
haslocation.append(True)
else:
iscurve.append(False)
haslocation.append(False)
ispoint.append(False)
hasrotation.append(False)
except:
ispoint.append(False)
iscurve.append(False)
haslocation.append(False)
hasrotation.append(False)
except:
try:
# curves
curvepoints = (item.GetEndPoint(0).ToPoint(),item.GetEndPoint(1).ToPoint())
curvepointlist.append(curvepoints)
curves.append(item.ToProtoType())
ispoint.append(False)
iscurve.append(True)
haslocation.append(True)
hasrotation.append(False)
except:
ispoint.append(False)
iscurve.append(False)
haslocation.append(False)
hasrotation.append(False)
OUT = (pointlist,curvepointlist,curves,ispoint,iscurve,haslocation,angles,hasrotation)

Welcome. The </> icon in the toolbar will format text for you.

Got it right now, paste the code THEN hit the <>

import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

items = UnwrapElement(IN[0])
pointlist, curvepointlist, ispoint, iscurve, curves, haslocation, angles, hasrotation = [], [], [], [], [], [], [], []

for item in items:
	try:
		# points and text notes
		pointlist.append(item.Coord.ToPoint())
		ispoint.append(True)
		iscurve.append(False)
		haslocation.append(True)
		hasrotation.append(False)
	except:
		try:
			loc = item.Location
			if loc.ToString() == 'Autodesk.Revit.DB.LocationCurve':
				# line-based elements (e.g. walls)
				curvepoints = (loc.Curve.GetEndPoint(0).ToPoint(),loc.Curve.GetEndPoint(1).ToPoint())
				curvepointlist.append(curvepoints)
				curves.append(loc.Curve.ToProtoType())
				ispoint.append(False)
				iscurve.append(True)
				haslocation.append(True)
				hasrotation.append(False)
			elif loc.ToString() == 'Autodesk.Revit.DB.LocationPoint':
				# point-based elements
				pointlist.append(loc.Point.ToPoint())
				ispoint.append(True)
				iscurve.append(False)
				haslocation.append(True)
				try:
					angles.append(math.degrees(loc.Rotation))
					hasrotation.append(True)
				except:
					hasrotation.append(False)
			else:
				# check for host objects outlines (floor slabs etc.)
				try:
					refs = HostObjectUtils.GetTopFaces(item)
					blines = []
					bpoints = []
					for ref in refs:
						try:
							boundaries = item.GetGeometryObjectFromReference(ref).GetEdgesAsCurveLoops()
							for loop in boundaries:
								cloop = []
								clooppoints = []
								for line in loop:
									cloop.append(line.ToProtoType())
									curvepoint = (line.GetEndPoint(0).ToPoint(),line.GetEndPoint(1).ToPoint())
									clooppoints.append(curvepoint)
								blines.append(cloop)
								bpoints.append(clooppoints)
						except:
							pass
					if (len(blines) > 0):
						curves.append(blines)
						curvepointlist.append(bpoints)
						iscurve.append(True)
						haslocation.append(True)
					else:
						iscurve.append(False)
						haslocation.append(False)
					ispoint.append(False)
					hasrotation.append(False)
				except:
					ispoint.append(False)
					iscurve.append(False)
					haslocation.append(False)
					hasrotation.append(False)
		except:
			try:
				# curves
				curvepoints = (item.GetEndPoint(0).ToPoint(),item.GetEndPoint(1).ToPoint())
				curvepointlist.append(curvepoints)
				curves.append(item.ToProtoType())
				ispoint.append(False)
				iscurve.append(True)
				haslocation.append(True)
				hasrotation.append(False)
			except:
				ispoint.append(False)
				iscurve.append(False)
				haslocation.append(False)
				hasrotation.append(False)
OUT = (pointlist,curvepointlist,curves,ispoint,iscurve,haslocation,angles,hasrotation)

Not sure what changed. My Element.Location node still works. Try using Room.Location. It’s probably better for this process anyway.