Creating dependent views with scope boxes

Hi there,

I am trying to create dependent views from the current view with a scope box.
The script does make the views, but the created views does not contain the scope boxes i want to create from it.

I am trying to create them while using a python script, with 3 inputs.
IN[0] are the views
IN[1] are the minimums for the scope box
IN[2] are the maximums for the scope box

The script i have is :

import clr
from Autodesk.Revit.DB import *

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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

views = UnwrapElement(IN[0])
Min =
Max =

for i in IN[1]:
for i in IN[2]:

elementlist = list()
failedlist = list()

for number in views:
newbox = app.Create.NewBoundingBoxXYZ()
newbox.Max = UnwrapElement(Max.ToXyz)
newbox.Min = UnwrapElement(Min.ToXyz)

OUT = elementlist

Once i run the the dynamo script, it does work, does create the view, but gives back an empty list as output because it does not create the scope boxes (like in the image)

Can anyone help me with the code and show me what i’m doing wrong?


Hi Spijkerman

I wanted to do something to with scope boxes
see my topic:

maybe some answers off the experts can help you

maybe this post from the building coder can help you

i am stil learning python (net yet good in it)

revit API does not support creation off scope boxes
i looked it up and i think al the experts are right


Take a look at Modelical, there’s a Scope Boxes to Views node in it that could help (description: “Create as many dependent view as needed to selected views to apply selected Scope Boxes”)…


You cannot CREATE a new scope box, but if one exist you can assign it to a view.


Please refer to: How to get help on the Dynamo forums for information on how to properly post code on this blog.


Actually, you can create a new scope box using Dynamo. The API gives you acces to the PostableCommands (your toolbar buttons basically). Have a look at the following code…

import clr

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc =  DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
uiapp = DocumentManager.Instance.CurrentUIApplication

import Revit

from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

pCmd = RevitCommandId.LookupPostableCommandId(PostableCommand.ScopeBox)

This will initiate the create scope box command and let you draw one insitu.

A bit of a hack but does the trick. :stuck_out_tongue_winking_eye:



Great suggestion, but imagine that you put this in a loop and now a user has to click twice for every dependant view that gets created. It will be a bit of a hassle. Until we are able to pass arguments into postable commands I can’t suggest them to others as workable solutions. Also, you are missing one last line that will actually prompt the command:



Haha, oops! That is the most important line, my bad! Thanks for pointing that out.

Yeah, in this context it wouldn’t be ideal unless you could zoom the view extents and programmatically get two points in the UI space as mouse clicks. There is also the other matter of how you continue postable commands downstream as they return null. There are ways to get around this but super-hacky.


Well to that point currently Dynamo doesn’t support setting active view so that only reinforces my point that i would stay away from workflows that require user input in a loop like that. It’s very similar to plotting 100s of sheets to PDF and forgetting to have default print location set…now you are clicking OK for every view. It’s bad.

Ps. What’s the hacky way of programmatically setting inputs into postable commands? Care to share?


Yeah, I do wish changing view wasn’t prohibited sometimes.

What I meant is when you create a scope box via postable command it returns null although it has clearly placed one. But typically you want the output that element downstream to manipulate it somehow. The way you could do this is finding the last ElementId created as it will be the largest integer value. It is not the nicest method but works.

But, we’ve both agreed this is not a solution for this problem, but you can create scope boxes through Dynamo, just the same way you would in Revit.

1 Like

Hi Daniel and Konrad

Good thinking
i have tried youre script and indeed with dymamo we can create a scope box
and i agree it is not the solution for this problem and mine problem

thanks for your effort :+1:

1 Like