Trying to get the views on a sheet so I can then remove those views from a LegendsView List - eventual export to PyRevit (So trying to avoid toDS for now)
Are the methods broken?
Revit 22 CYPY3
I finally got some traction by looking up the doc.GetElement(by id).Name but all the methods for the sheet.Views failed…
I.e. SheetsAll()[3].Views returned “Warning: AttributeError : ‘ViewSheet’ object has no attribute ‘Views’ [’ File “”, line 57, in \n’]”
Where:
x= SheetsAll()[3]
OUT=x.Views
using the same DEFs below. The CODE below back-ends the View Names using the get element id…
import sys ##Standard system input
import clr
##https://gist.github.com/gtalarico/e6be055472dfcb6f597e3dcd20d11f37
from Autodesk.Revit.DB import FilteredElementCollector
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Drafting Views
from Autodesk.Revit.DB import BuiltInCategory, BuiltInParameter
from Autodesk.Revit.DB import ViewFamilyType, ViewDrafting, Element, ViewFamily
from Autodesk.Revit.DB import ViewFamily
from Autodesk.Revit.DB import ViewType
from Autodesk.Revit.DB import ViewSheet
from Autodesk.Revit.DB import Transaction
###Creates a Drafting View###
from Autodesk.Revit.DB import Transaction, Element, ElementTransformUtils
##https://forum.dynamobim.com/t/collecting-all-elements-of-family-types-in-active-view/19838/2
from Autodesk.Revit.DB import BuiltInCategory, BuiltInParameter
# ViewFamilyTypes and Drafting views creation
from Autodesk.Revit.DB import ViewFamilyType, ViewDrafting, Element
from Autodesk.Revit.DB import ViewFamily
import System ##filterAnnot = System.Predicate <<Work on removing
from System.Collections.Generic import List ##Not same as type() = List <<Work on removing
import math ##For truncate to integer-RA
import re ##Regular expressions for 'natural' sort
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
def ViewLegendsAll():
viewLegends=[v for v in FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).ToElements() if v.ViewType == ViewType.Legend]
return viewLegends
def SheetsAll():
#sheets = FilteredElementCollector(doc).OfClass(ViewSheet).ToElements()
sheets = [i for i in FilteredElementCollector(doc).WhereElementIsNotElementType().OfClass(ViewSheet)]# if i.IsPlaceholder == False]
return sheets
def ViewPortsAll():
#sheets = FilteredElementCollector(doc).OfClass(ViewSheet).ToElements()
sheets = [i for i in FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Viewports)]# if i.IsPlaceholder == False]
return sheets
def ViewsOnSheetsAll(sheets):
VL_On=[]
for sheet in UnwrapElement(sheets):
VL_On.append([v for v in sheet.ViewPorts ])# if v.ViewType == ViewType.Legend])
return VL_On
x=[doc.GetElement(i).Name for i in SheetsAll()[3].GetAllPlacedViews()]
OUT=x
When I dir (Sheet) I get this:
[
[
[
AddFilter,
AreJoined,
BoundingBox,
ByNameNumberTitleBlock,
ByNameNumberTitleBlockAndView,
ByNameNumberTitleBlockAndViews,
ByNameNumberTitleBlockViewAndLocation,
ByNameNumberTitleBlockViewsAndLocations,
CanViewBeDuplicated,
CropBox,
CropBoxActive,
CropBoxVisible,
Curves,
Delete,
Discipline,
Displaystyle,
Dispose,
DuplicateSheet,
DuplicateView,
ElementCurveReferences,
ElementFaceReferences,
ElementType,
Equals,
ExportAsImage,
Faces,
FilterOverrides,
Filters,
Finalize,
Geometry,
GetCategory,
GetCategoryOverrides,
GetChildElements,
GetHashCode,
GetHostedElements,
GetIntersectingElementsOfCategory,
GetJoinedElements,
GetLocation,
GetMaterials,
GetParameterValueByName,
GetParentElement,
GetType,
HideCategoriesTemporary,
HideElementsTemporary,
Id,
InternalElement,
InternalElementId,
InternalUniqueId,
IsAlive,
IsCategoryHidden,
IsFrozen,
IsHiddeninView,
IsPinned,
IsViewTemplate,
IsolateCategoriesTemporary,
IsolateElementsTemporary,
JoinGeometry,
MemberwiseClone,
MoveByVector,
Name,
Origin,
Outline,
Overloads,
OverrideColorInView,
OverrideInView,
OverridesInView,
Parameters,
Partsvisibility,
ReferenceEquals,
RightDirection,
SafeInit,
Scale,
Schedules,
SetCategoryOverrides,
SetCropBox,
SetCropBoxActive,
SetCropBoxVisible,
SetDiscipline,
SetDisplayStyle,
SetFilterOverrides,
SetGeometryJoinOrder,
SetLocation,
SetParameterByName,
SetPartsVisibility,
SetPinnedStatus,
SetScale,
SetSheetName,
SetSheetNumber,
SetSketchPlane,
SheetName,
SheetNumber,
SketchPlane,
Solids,
Tessellate,
TitleBlock,
ToString,
UniqueId,
UnjoinAllGeometry,
UnjoinGeometry,
ViewDirection,
Viewports,
Views,
__call__,
__class__,
__delattr__,
__delitem__,
__dir__,
__doc__,
__enter__,
__eq__,
__exit__,
__format__,
__ge__,
__getattribute__,
__getitem__,
__gt__,
__hash__,
__init__,
__init_subclass__,
__iter__,
__le__,
__lt__,
__module__,
__ne__,
__new__,
__overloads__,
__reduce__,
__reduce_ex__,
__repr__,
__setattr__,
__setitem__,
__sizeof__,
__str__,
__subclasshook__,
get_BoundingBox,
get_CropBox,
get_CropBoxActive,
get_CropBoxVisible,
get_Curves,
get_Discipline,
get_Displaystyle,
get_ElementCurveReferences,
get_ElementFaceReferences,
get_ElementType,
get_Faces,
get_Filters,
get_GetCategory,
get_Id,
get_InternalElement,
get_InternalElementId,
get_IsAlive,
get_IsPinned,
get_Name,
get_Origin,
get_Outline,
get_OverridesInView,
get_Parameters,
get_Partsvisibility,
get_RightDirection,
get_Scale,
get_Schedules,
get_SheetName,
get_SheetNumber,
get_SketchPlane,
get_Solids,
get_TitleBlock,
get_UniqueId,
get_ViewDirection,
get_Viewports,
get_Views,
set_InternalElementId
]
]
]
Which the .Views is in there, but fails.