Get current view, how?

Hello,

my script for any reson counts any view, but i want only the currient one (active)

import clr
import sys
import System

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
active = FilteredElementCollector(doc,doc.ActiveView.Id)

#Do some action in a Transaction

OUT = active

KR

Andreas

Why are you using a FEC when you’re already getting the active view directly from the document? What are you trying to do?

@Nick_Boyts ,

i just want the current view, to feed isolate elements

But you already have it here:
image

1 Like

@Nick_Boyts ,

yes but i got all views listed… … and revit collabsed!

currView = doc.ActiveView

2 Likes

Just use active = doc.ActiveView. You’re literally getting the active view and then saying filter for this view that I’m supplying.

2 Likes

@Nick_Boyts ,

i will test it

@aaronrumple ,

thats it! minimal as possible

import clr

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

doc = DocumentManager.Instance.CurrentDBDocument

OUT = doc.ActiveView
1 Like

Even more concise.

import clr

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

OUT = DocumentManager.Instance.CurrentDBDocument.ActiveView
3 Likes

Hi, the designscript version isn’t bad either :wink:
image
Document.Current.ActiveView;
cordially
christian.stan

1 Like

@christian.stan ,

hmmm… it does not work
grafik
i get a non pointer

Try with Revit document…

3 Likes