HELP! Activate multiple views on multiple sheets

I have over 300 sheet for a project that I am working on. I have to change all of the framing because of revisions.

I want to Activate View for all of the viewports with the “Bill of Material” title in the entire project at once.

I am very new to Dynamo. How do I create this?

what do you mean by “Activate View”? Like the same result after double click the viewport?

yes, that is what I mean

( I ultimately want to “Refresh” all of my Bill of Material viewports for sheets D-6000 to D-6200 at once.
I currently have to open each individual sheet, activate my Bill of Material viewport, then refresh view. This is very time consuming.)

Hey,

Slightly modifying this…

Means I can edit the python to get a different PostableCommend Enumeration…

http://www.revitapidocs.com/2018/f6ccdc1b-6ac3-9c49-d0bb-8a7d1877eab0.htm

Which seems to work…

PostableCommandEnumeration.dyn (3.7 KB)

import clr

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIDocument
uiapp = DocumentManager.Instance.CurrentUIApplication

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System.Core')
from System.Collections.Generic import HashSet

def tolist(obj1):
if hasattr(obj1,'__iter__'): return obj1
else: return [obj1]

# IN variables...
run = tolist(IN[0])[0]
elems = tolist(UnwrapElement(IN[1]))

# Main Code...
if run:
# Get ElementIds to list...
elemIds = HashSet[ElementId]([e.Id for e in elems])
# Set Selection (required for the postable command)...
uidoc.Selection.SetElementIds(elemIds)
uidoc.RefreshActiveView()

# Get RevitCommandId of PostableCommand...
rvtComId = RevitCommandId.LookupPostableCommandId(PostableCommand.ActivateView)
# Run PostableCommand...
uiapp.PostCommand(rvtComId)

OUT = 'Command Has Run'
else:
OUT = 'Please set Run to True';

Hope that helps,

Mark

1 Like

Can you post a video of you doing this step by step? I do not see “Pick Model Elements” in Library

Postable commands can’t really be run more than once.

Wouldn’t it be easier to just delete it and put it back on in the same place?

“It” as in the Bill of Material Viewport?

Hey Keisha,

I presumed you’d feed a list of views filtered by name…

However, Daniel knows more than me and his idea sounds like a better method…

How about you refresh 1… Grab the locations of the out of date ones, delete them and replace with duplicates of the refreshed one? If that makes sense?

Cheers,

Mark

Just out of curiousity Daniel, I tried putting the command inside a transaction then tried looping with a range… It gave the ‘not supporting more than one command error’ but shouldn’t this be doing multiple ‘commands’?

Any advice welcome :slight_smile:

Mark

   # Run PostableCommand...
    	for r in range(len(elemIds)):
	
		TransactionManager.Instance.EnsureInTransaction(doc)
	
		uiapp.PostCommand(rvtComId)
		
		TransactionManager.Instance.TransactionTaskDone()

Nope, postable commands cannot be run more than once as far as I’m aware, so looping will not work I’m afraid. In fact, I don’t even think you can daisy chain them in the Dynamo graph, although I haven’t tested thoroughly as I try to avoid Postable Commands if I can.

Perhaps you could use the TransactionManager.Instance.ForceCloseTransaction() and put the transaction in your loop rather than outside but I think this will also fail.

You are correct, it fails in a daisy chain as well as inside a transaction which is then looped.

I only questioned it as there are hundreds of commands which we otherwise need work around’s for.

Cheers,

Mark

Yup, I thought it might. Postable commands are really a last resort, and generally not really meant to be used like this.

The method of getting the viewport (inc location and view), deleting viewport and replacing is probably the best solution.

What type of view is it?

Each sheet has a different “Bill of Material”. I use a program called StrucSoft MWF to frame walls and it generates the “Bill of Material” once we create the shop drawings. If the framing in the walls change I “Activate View” of one of the “Bill of Material” Viewport and use the StrucSoft program to “Refresh View”. This updates the “Bill of Material”. I want to figure out a way to “Refresh View” of all 200 different “Bill of Material” at once. Currently I have to open every single sheet, double click on that particular Viewport (there are 3 different viewports on each page), then “Refresh View”. Unfortunately, I don’t think the method you suggest in this instance will work.

@keisha.chapman

I’m not sure what the plugin you mentioned is. But these views are in the project somewhere. Can these only be updated from within the sheet? If you delete one and undo, does it update?

Can we have a sample project to test with?

@keisha.chapman

Maybe create a new View/Sheet and place a copy of all the Bill of Material on it, update there / all at once?

2 Likes

That is a great Idea!

I tried copying the Bill of Material onto a new sheet. It only updated for that one sheet instead of the entire project.

sooo!!! :slight_smile:
place copies of all of them with Dynamo
now you dont have to use all of the Sheets
what is that thing btw, a view yes, a schedule? filtered schedule?

1 Like

That is a great idea. I just found a video that walks me through the steps with Dynamo, thanks!