Modify view range

Those conversion nodes were because Revit handles everything in decimal feet internally. So when we want to set something in mm or m, we have to convert the dimension to feet first and then send it to RevitAPI commands.

You can do this conversion in the python node but that conversion node is more accurate than the number you might type in. Also, it should be from whatever your project’s base unit is to feet, not millimeters to millimeters. That is why your number is so far off.

So if your units are millimeters, set it to millimeters to feet.

2 Likes

Okay thanks you sir i’ll try it

Hi Kenny,

I would like to change only the Offset of Cut Plane because I set the other levels to infinitive. I edited your code but it did not work. I am beginner at Python. Could you please take a look?

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

def modViewrange(cof):
v = UnwrapElement(vp)
viewrange = v.GetViewRange()
asslvl = v.GenLevel

viewrange.SetOffset(PlanViewPlane.CutPlane,cof)

#Applying the viewrange to the view
v.SetViewRange(viewrange)

doc = DocumentManager.Instance.CurrentDBDocument
count = 0

TransactionManager.Instance.EnsureInTransaction(doc)
if isinstance(IN[0],list) and isinstance(IN[1],list):
for cof in zip(IN[0],IN[1]):
modViewrange(cof)
count += 1

TransactionManager.Instance.TransactionTaskDone()

OUT = ‘%d view ranges altered’ %(count)

I tried it again and now it works! Thanks Kenny!!!

2 Likes

Hi guys!

I’m trying to use this script with a list of levels, but it is not working. Can anyone help me?

I created a list to input in the node “String.Contais”, but the result is empty list. On the Revit I have the levels (Level 01, Level 02)

It would be better to search them seperately but you can still “search for” @L1 and than for Level 01 and Level 02 two lists. Or you can change to Lacing to Cross Product and then transpose the list. My recommandation would be to create 2 String Contains Node and search seperately and then create a new list with 2 results.

i’m using the list because the next step of my script is import from excel the values of “Level name” and “view range”. If I change my script to create 2 “String.Contains” , I can’t import automatically from excel more then one value.

Now I get it what you want to do. You search for Levels in PlanViews and it is normal to get an empty list. You want to change automaticly the levels in view ranges… so you have to edit the Python script.

1 Like

Hi Kenny!
Some time ago there was question about Ceiling Plans, your advice was about filtering method but I think the problem is somewhere else.
I’m poor in python but even when picking single view script is working with Structural Plans oriented down, but there is an error when I changed view direction to UP.

Hello everyone,
I would like to select a special level and set it with 0.
but i don’t get it.
Can You Help?

image

thank you