Placing ScheduleViews on Sheets

Hey, i have a problem with adding a list of existing Schedules to list of existing Sheets.

I think I have all my data correct, number of sheets is the same as number of schedules, I’ve even provided same number of exact same points…

I checked other topics on this forum related to this question, none of solutions/nodes work.
I’ve tried Julien Benoit python code, I’ve tried PlaceViews nodes from Steam, Create.Viewport from Rhythm. They return all different kinds of error messages.

Can you guys help?

Hello
try this

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

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

toList = lambda x : x if hasattr(x, "__iter__") else [ x ]

sheets = toList(UnwrapElement(IN[0]))
views = toList(UnwrapElement(IN[1]))
points = toList(UnwrapElement(IN[2]))

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
out = []
for s in sheets:
	for v,p in zip(views,points):
		a = ScheduleSheetInstance.Create(doc, s.Id, v.Id, p.ToXyz()) 
		out.append(a)

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT=out

Note:
“Internal” schedules can’t be placed on sheet

2 Likes

Whoa, that was quick. Thank you! I need to finally get into python for revit, this seems to solve most of the problems.

There is one issue though - this code always splats out two of instances of the same Schedule on Sheet - am I feeding it wrong perhaps?

@filip.kabelis
strange…
the list of Points (IN[2]) and the list of ViewSchedule (IN[1]) must be same length
IN[0] are sheets to place

I fed it only 1 point, 47 sheets and 47 schedules. As it’s seen in post above it did work on all sheets, but twice.

When I fed it 47 same points, 47 sheets and 47 schedules, it’s somehow added 47 schedules to every view…:slight_smile:

Other problem i’ve noticed it adds same schedule to every view …
image

It’s the same ViewSchedule to place on other sheets?

What i’m looking for is to place corresponding Schedules on their Sheets. Lists are already sorted and of same lenght, but this script places only first Schedule from list on all Sheets

Hey, i found another code that seems to work for me!

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

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

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

doc = DocumentManager.Instance.CurrentDBDocument
sheets = IN[0]
views = IN[1]
x = IN[2]
y = IN[3]
viewsplaced = list()

TransactionManager.Instance.EnsureInTransaction(doc) # you need an active transaction as you will create elements

for number in range(len(sheets)):
	sheet = UnwrapElement(sheets[number])
	view = UnwrapElement(views[number])
	ScheduleSheetInstance.Create(doc, sheet.Id, view.Id, XYZ(x,y,0))
	viewsplaced.append(view.ToDSType(False))
	
TransactionManager.Instance.TransactionTaskDone()
OUT = viewsplaced
3 Likes

another way

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

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

toList = lambda x : x if hasattr(x, "__iter__") else [ x ]

sheets = toList(UnwrapElement(IN[0]))
views = toList(UnwrapElement(IN[1]))

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
out = []
for v, s in zip(views, sheets):
	a = ScheduleSheetInstance.Create(doc, s.Id, v.Id, XYZ.Zero) 
	out.append(a)

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT=out
1 Like

Hi there,

Can you expand on what you mean by ‘Internal’ schedules and why they can’t be placed on sheets?

I’m currently trying to write an all python sheet duplication script but the schedule isn’t passing the Viewport.CanAddViewToSheet condition when all the other views are.

The schedule I’m trying to place is already placed on the sheet that I’m duplicating which is why I’m a bit confused!

Ok I just saw the footnote on API docs which reads:

“Schedule views are not handled by the Viewport class. Refer to ScheduleInstance for information about adding schedules to sheets”.

Guess I’ll need to filter around it so schedules arent going through the same condition.

Sorry for asking before reading properly haha

2 Likes

There are Schedules which is what you see in the Browser, then Schedule Sheet Instances are those that have been placed on a sheet and reference back to the main schedule.

3 Likes