Hey, I’m working on a python script to place multiple views on sheets. At the moment it takes a list of sheets and a list of views and places all the views on the first sheet then when it gets the 2nd sheet it errors because it tries to place the entire list of views on the 2nd sheet again. I’m hoping to be able to feed it a list of sheets and a list of views with sublists the same length as the sheet list. So when it runs at the first sheet it would place whatever views are contained in the first sublist, at the 2nd sheet the views in the 2nd sublist, etc.
Below is what I have so far but I don’t know how to make it accept a sublist. Any help or a nudge in the right direction would be much appreciated. Below is what I have so far.
I tried the following and got a little closer but still not quite there. It now accepts the sublist of views and places the views of the first sublist on the first sheet. Except then I think it tries to place the first sublist of views on the 2nd sheet as I’m getting the following error Exception: viewId cannot be added to the ViewSheet. So I assume the views it’s trying to place are already on a sheet.
The first 2 views in the list (IDs 2733275, 6777777) are placed on the first sheet in the list (ID 6586160) so the first iteration is performing correctly. But in the next iteration I think it’s failing because it’s trying to place those 2 views again. I was getting the same error earlier when I knew I was accidentally trying to place a view on a sheet that was already on another sheet.
I don’t seem to be able to post any pictures so the script is just in text below. Each for loop is nested within the one before, just can’t indent properly by text.
import clr
clr.AddReference(‘RevitAPI’)
clr.AddReference(‘RevitAPIUI’)
from Autodesk.Revit.DB import *
import Autodesk
import sys
clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager