Set view range for ceiling plan


I begun with Dyanmo no long ago and I’m having some trouble with setting the view range.
I’ve seen in an old post a python script to choose the view range and set it on one or multiples view plans. I’m not familiar with python code but I king of understand how it works.

The python block didn’t work and I realised that it’s because my views are ceiling plans and not floor plans. I tried to change the code to adapt the view range for ceiling plans but it seems that I only make it worse.

Does someone know what I could try ?

Thank you.

Python script shared by kennyb6 in the old post :

import clr
from Autodesk.Revit.DB import*
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

def modViewrange(vp,tof,bof,cof):
	v = UnwrapElement(vp)
	#getting the viewrange of the view
	viewrange = v.GetViewRange()
	asslvl = v.GenLevel
	#Setting top clip plane of the viewrange
	#	Setting level of topclip plane
	#	setting offset of top clip plane
	#Setting bottom clip plane of the viewrange
	#	Setting level of bottom clip plane
	#	setting offset of bottom clip plane
	#Setting view depth plane of the viewrange
	#	Setting level of view depth plane
	#	setting offset of view depth plane
	if bof < 0 or IN[3]:
	#Applying the viewrange to the view

doc = DocumentManager.Instance.CurrentDBDocument

tof = IN[1]
bof = IN[2]
cof = IN[3]
count = 0

if isinstance(IN[0],list):
	for vp in IN[0]:
		count += 1
	count += 1

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

Error message when I run the dynamo :

Is this the original python script or the one you modified?
Additionally just a thought since ceiling plans are reflected, did you try to swap tof and cof inputs?

1 Like

Would it be easier to use View Templates ?

Yes this is the original script, the one I modified didn’t work and I had even more errors.

I noticed something, when I go see the view range in REVIT, I’ve got the view range for a floor plan. Maybe the error is because dynamo consider it like an ceiling plan but revit like a floor plan, is it possible ?

This is the view range I have when I go in revit :
View range impact plan

I tried to swap the 2 inputs but it don’t work.

For ceiling plan you should have a cut plane with an offset lower than the top offset since you’re looking from the bottom up.
Try to set the values manually in Revit to something that fit your needs and then we will go through code.

I’ve tried your idea but the view range I set in the view template don’t sets in the views I create.

Thank you for your help

I think I’ve found why the view range don’t work. The views that I duplicate have a view template in ceiling plan (which is a error in our template) but the duplicated views have a view template in floor, structural plan. Dynamo seems to keep the information of the orginal views so I’m going to change our template to adjust this and see if it works.