Switching between 2d and 3d extent (Levels, Grid)

Kia ora,

With the help of Python and only if you’re using Revit 2016 or higher… Try changing the category to Grids - I got this to work with levels extents and believe they work the same way (ViewSpecific=2D and Model=3D).

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

a = UnwrapElement(IN[0])
v = UnwrapElement(IN[1])
TransactionManager.Instance.EnsureInTransaction(doc)
for i in a:
#    i.SetDatumExtentType(DatumEnds.End0,v, DatumExtentType.Model)
    i.SetDatumExtentType(DatumEnds.End0,v, DatumExtentType.ViewSpecific)
#    i.SetDatumExtentType(DatumEnds.End1,v, DatumExtentType.Model)
    i.SetDatumExtentType(DatumEnds.End1,v, DatumExtentType.ViewSpecific)
TransactionManager.Instance.TransactionTaskDone()

OUT = v
9 Likes