Please see the script I have created so far. It creates and places sheets, but not in the location I would like.
I am wondering if there is a way to specify a coordinate location to place a view on a sheet, or any other way of defining the precise location of the view.
That’s pretty awesome man!
would adding a for loop for the Sheets in the python script allow placement for more than one at a time ? ( am still a beginner in python )
Yup, I have revised the code as shown below, just switch the code out in the Python node with this instead…
################### Import References ###################
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
################### Definitions ###################
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
################### Inputs ###################
#get the bool in port IN[0]...
r = tolist(IN[0])
r = r[0]
#get the sheet in port IN[1] and UnwrapElement if not already...
sheets = tolist(UnwrapElement(IN[1]))
#get the views in port IN[1] and UnwrapElement if not already...
views = tolist(UnwrapElement(IN[2]))
#get the points in port IN[2] (no need to unwrap as these are Dynamo Points)...
locs = tolist(IN[3])
################### Outputs ###################
outList = []
################### Script ###################
if r:
if len(views) == len(locs):
for sht,v,l in zip(sheets, views, locs):
TransactionManager.Instance.EnsureInTransaction(doc)
try:
if Viewport.CanAddViewToSheet(doc,sht.Id,v.Id):
vp = Viewport.Create(doc,sht.Id,v.Id,l.ToXyz())
outList.append(vp)
except Exception, e:
outList.append(e.message)
TransactionManager.Instance.TransactionTaskDone()
OUT = outList
else:
OUT = "Number of Views must match the number of Locations"
else:
OUT = "Set Run to True"
@Nick_Boyts
Thats how i did to make it work. I count the views and cycle the sheet id 3 times so sheet, views and location matches. What i cannot do is to loop to the next sheet and do same but to the new sheet, new 3 different views and same 3 locations.
thanks
There shouldn’t be any looping. You need to cycle the points too. If you have 5 sheets with 3 views each you should have 15 sheets with 15 views at 15 points.
Thanks a lot. I will post tomorrow. I will tidy it a bit as its in a mess now coz i am playing with it. I will also add some notes as per above so it will be clear for you. Thanks a lot for you time.
Was just about to have a look and seems it’s solved already which is great as I have as many cells this week as an amoeba! Glad you guys got it working.
First @Daniel_Woodcock1 thanks for the python script it’s awesome, managed to get single views on single sheets to work!
Happy to start a new topic as this has been solved but wondered if you could help, either by showing a graph that shows it working for multiple sheets/views?
Heres a graph that im working on. Any help much appreciated.
Hi. Can you post your dyn and the dyf so i can adjust it and repost. If not the answer is that you need to have the same number of sheet ids. views. locations. I can see you have mismatch…you have 18 locations 6 views and 2 sheets. They do not match on numbers. Also views should not be duplicated on sheets as it will not work. Maybe it will be good to start a new topic. I or Dan i think will be happy ti help. For me its just the weekend so i can answer you with graphs and dyn next week. Or others in the forum may be able to.
Sorry I haven’t got to this sooner, I have been exceptionally busy. With that said, I have updated the nodes in this thread in the thread below to handle multiple sheets - raised by @Kotey.Nikoi
There is a new preview node too so you can visualize all the sheets and view locations easily (it creates a tiled array in the Dynamo viewport - handles multiple sheet sizes too).
Move on over to the thread in this post for any new updates/comments as I think this thread has got to it’s end.