2

I'm trying to get the active view of my family's document but it returns null. In Revit 2019, it would always return a value however I've recently switched to Revit 2020 and it seems to be giving me an issue.

Has anyone else run into this yet and come across a solution?

I've stumbled across this post but its recommendation is to use a filtered element collector which I am not a fan of. I'm having issues passing it to other classes. Revit 2019 seemed so simple.

Note: this also persists in Revit 2021

Here's a picture of my debug showing its nullenter image description here

and then here's a picture of my Snoop for the family document after it is open and activated showing it has a value. enter image description here

Cflux
  • 1,423
  • 3
  • 19
  • 39
  • Is the `familyDocument` open in Revit? – Rahul Bhobe Jun 12 '20 at 12:42
  • @RahulBhobe yes it is open. – Cflux Jun 12 '20 at 14:39
  • My wildest guess is that: you might opened but not yet activated the document, or you activated the document but for some reason the document activation was not finished or the active document has been changed again. When you use Revit Lookup, you always activate the document, thus it has a value. – Thế Long Jun 23 '20 at 09:59

1 Answers1

0

The reason behind this is that you are currently working on a project document, which means the project document is open and 1 of its view is showing in Revit graphical view, not the family document. Therefore, the View from the family document is not showing - A.K.A no active view for the family document. The solution you are looking for is explained in this post:

switch view or document by showing elements

In short, you create an UIDocument from family document, then use the newly created UIDocument to show the family document via:

UIDocument.ShowElements()

After that, you have an active view for your family document.

Thế Long
  • 516
  • 7
  • 19