Hey everyone, I made my own toolbar through pyRevit and Data Shapes.
However I want my button to directly Select Viewports rather than having the button activate the SelectModelElements Data node and getting the Viewports that way.
I suspect I will need to forfeit Dynamo and use a python script.
How can I get this done easily?
Hi @RevitRobot you can get all viewports with archilab get all viewporpts or Grumple have a node for that as well, both written in python
Yeah I guess I could go for all Viewports on the Active Sheetview
But I’d rather be able to press my toolbar button and jump straight to selecting viewports in Revit. Is that possible within Dynamo?
1 Like
arhh sorry i think about viewporttypes
Thank @john_pierson not me, run it in Ironpython
#Copyright(c) 2017, john pierson
# @60secondrevit, http://sixtysecondrevit.com
#Thanks to Dimitar and Troy Gates for Guidance
#and this blog http://pythoncvc.net/?p=116
import clr
import msvcrt
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
TaskDialog.Show('Select your viewports!', 'In your Revit window, pick viewports in desired order then press the ESC key to finish.')
sel1 = uidoc.Selection
obt1 = Selection.ObjectType.Element
class CustomISelectionFilter(Selection.ISelectionFilter):
def __init__(self, nom_categorie):
self.nom_categorie = nom_categorie
def AllowElement(self, e):
if e.Category.Name == self.nom_categorie:
return True
else:
return False
def AllowReference(self, ref, point):
return True
msg1 = 'In your Revit window, pick viewports in desired order then press the ESC key to finish.'
out1 = []
flag = True
while flag:
try:
el1 = doc.GetElement(sel1.PickObject(obt1, CustomISelectionFilter("Viewports"), msg1).ElementId)
out1.append(el1.ToDSType(True))
except:
flag = False
OUT = out1
3 Likes
Wow this was so easy!
This is exactly what I needed.
1 Like