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
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
for i in IN[1]:
Min.append(UnwrapElement(i.ToXyz(True)))
for i in IN[2]:
Max.append(UnwrapElement(i.ToXyz(True)))
elementlist = list()
failedlist = list()
TransactionManager.Instance.EnsureInTransaction(doc)
for number in views:
try:
newbox = app.Create.NewBoundingBoxXYZ()
newbox.Max = UnwrapElement(Max.ToXyz)
newbox.Min = UnwrapElement(Min.ToXyz)
box.append(newbox)
elementlist.append[views]
except:
elementlist.append(list())
TransactionManager.Instance.TransactionTaskDone()
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)
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”)…
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…
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.
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