Create Panel Schedule Sheet Instances on Sheets

Hi all,

First time poster and relatively new to Dynamo and could use some help. I’ve been taking a stab at creating a graph that allows the user to select a titleblock, multiple panel schedules, and a panel schedule graphic that’s been placed on a sheet, so as to get it’s position relative to titleblock, and then create new sheets with panel schedule graphic instances placed using the position data acquired.

Basically, the code is @SeanP’s Schedule.dyn from Place Legends on Multiple Sheets with Template Legend tweaked just a bit. (see attached)

His code uses Rhythym, Data-Shapes, Spring, and Archi-Lab package nodes just like mine.

My problem is in the node “Create Panel Schedule Graphics 2”, where I get the error “list can not be called”. I was hoping someone might be able to point out what’s causing my error and if it can be remediated. When ran the node is actually receiving a list of Panel Schedule Views for IN[0] and a list of Sheets for IN[1]. Can provide more detail as necessary.

pschedules = IN[0]
templateSheets = IN[1]

try:

pschedGraphics =
for i in range (0, 24):
pschedGraphics.append(PanelScheduleSheetInstance.Create(doc, pschedules(i), templateSheets(i)))

except:
import traceback

errorReport = traceback. format_exc ()

if errorReport is None:
OUT = pschedGraphics
else:
OUT = errorReport

Without the whole node to work with, it looks like you should be using pschedules[I] not “(I)” as that is for methods not indices. Change them to open brackets and see if that works.

If that doesn’t work, then also try to post and image with all of the result windows open and a full copy of the code for troubleshooting.

Thanks for the shout out, and glad to see my graph is being used for other stuff!

1 Like

Thanks man and no problem! I apologize for the haphazardness of this inquiry. I was in a rush to get out of the office on Friday after spending way too much time just trying to get this code to work and didn’t think to just email myself the .dyn itself, so I could make this post the next day. I’ll try your suggestion and if it doesn’t work I’ll post the .dyn so the forum can have a better chance at troubleshooting. I’ll try and sneak back into my office on Friday the 28th (even though I’m on PTO) just cause I’m headed that way that day anyway and get the .dyn. If that doesn’t work I’ll get it out on the 1st.

Hey @SeanP, sorry for the delay… Here is my full graph and screenshot as promised. I tried switching the parantheses with brackets for pschedules and templateSheets, but no luck. The error I get when I try that is “Expected ElementID, got UnknownElement” PanelSchedules2Sheets2.dyn (106.2 KB)

Hi Nathan,

There are some changes to make in your scripts :

Create Panel Schedule :

import clr
# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import RevitAPI
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Electrical import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#The inputs to this node will be stored as a list in the IN variable.
pschedules = UnwrapElement(IN[0])
templateSheets = UnwrapElement(IN[1])

#Start the transaction
TransactionManager.Instance.EnsureInTransaction(doc)

pschedGraphics = []
for i,j in zip(pschedules,templateSheets):
	pschedGraphics.append(PanelScheduleSheetInstance.Create(doc, i.Id, j))

#End the transaction
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable
OUT = pschedGraphics

Set location script:

# Copyright(c) 2017, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
import sys

pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit

clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

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


def process_list(_func, _list):
    return map(lambda x: process_list(_func, x) if type(x) == list else _func(x), _list)

for loc in IN[1]:
	def set_location(item, location=loc.ToXyz()):
		pschedule = UnwrapElement(item)
		pschedule.Origin = location
		return item

output = []
try:
    errorReport = None
    TransactionManager.Instance.EnsureInTransaction(doc)
    output = process_list(set_location, IN[0])
    TransactionManager.Instance.TransactionTaskDone()
except:
    import traceback

    errorReport = traceback.format_exc()

# Assign your output to the OUT variable
if errorReport is None:
    OUT = output
else:
    OUT = errorReport

PanelSchedules2Sheets3.dyn (72.6 KB)

2 Likes

Beautiful! Works like a charm.

Everything works as expected when a single panel schedule is used as a template (boolean set to True for SelectSingleElement on UI.SelectModelElecments data), but when I select multiple panel schedules as the template, I get the following error in the “Set Panel Schedule Graphic Location” python code:
line 33, in AttributeError: ‘list’ object has no attribute ‘ToXyz’

This is related to the following loop:
for loc in IN[1]:
def set_location(item, location=loc.ToXyz()):
pschedule = UnwrapElement(item)
pschedule.Origin = location
return item
I’ve set up a Watch, and IN[1] is a list of multiple locations as expected.

Does anyone know why the ToXyz() is causing the error?