Set View Range Parameters

Here’s an easier to copy paste version of the code :slight_smile:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument


views = UnwrapElement(IN[0])
ltop = UnwrapElement(IN[1])
toffset = IN[2]
lbottom = UnwrapElement(IN[3])
boffset = IN[4]
count = 0

TransactionManager.Instance.EnsureInTransaction(doc)

for v,lt,tof,lb,bof in zip(views,ltop,toffset,lbottom,boffset):


	#getting the viewrange of the view
	viewrange = v.GetViewRange()

	#Setting top clip plane of the viewrange
	#	Setting level of topclip plane
	viewrange.SetLevelId(PlanViewPlane.TopClipPlane,lt.Id)
	#	setting offset of top clip plane
	viewrange.SetOffset(PlanViewPlane.TopClipPlane,tof)

	#Setting bottom clip plane of the viewrange
	#	Setting level of bottom clip plane
	viewrange.SetLevelId(PlanViewPlane.BottomClipPlane,lb.Id)
	#	setting offset of bottom clip plane
	viewrange.SetOffset(PlanViewPlane.BottomClipPlane,bof)


	#Applying the viewrange to the view
	v.SetViewRange(viewrange)
	count = count +1

TransactionManager.Instance.TransactionTaskDone()


OUT = '%d view ranges altered' %(count)
5 Likes