Get current view range values. python

Very good days.
I would like your help…
I am trying to enter the parameters and values ​​that are in CURRENT VIEW RANGE.
Could you please guide me on how to access it through a python code… I am very new to python and the revit api.

Thank you so much

GeniusLoci package already has Set ViewRange node. They are generous enough to allow you to edit the node if you want to see how it’s coded with the API. Just remember to give kudos to the creator if you modify and reshare the code here.

1 Like

Thanks for your comment…
But I’m trying to do it through python and at the same time learn code…

How to extract that value for example…?’

Looking at other’s code is a good way to learn, but I understand the effort of wanting to figure out yourself. You have to define which plan view plane you are wanting to get the offset value for.

EDIT
You are close with what you have. You don’t necessarily need the vrange and pvplane output, but that’s just my way of checking my code.

av = doc.ActiveView

vrange = av.GetViewRange()
pvplane = PlanViewPlane.BottomClipPlane
offset = vrange.GetOffset(pvplane)

OUT = vrange, pvplane, offset
1 Like

To add on to the learning (and completely agree - learn from seeing how others do it), the main issue with your code I believe was calling PlanViewRange only. PlanViewRange is what we call an enum (enumeration), which has pre-set values that you append on the end like a Property.

They’re quite common in the RevitAPI and it can be handy to use RevitAPIdocs to identify when they are needed, as well as what options you can use. They confused me a lot when I first came across them, so hopefully that helps.

1 Like

This is really great nodes. Thank you @staylor for the info.
These two nodes are actually python nodes.