Get active view of file open in background

Get active view of file open in background

Anonymous
Not applicable
2,748 Views
3 Replies
Message 1 of 4

Get active view of file open in background

Anonymous
Not applicable

Hey guys,

 

I'm trying to get the Starting View of a Revit file that I have just opened in the background by doing this:

Document currentDoc = app.OpenDocumentFile(ModelPath, OpeningOptions);

// Get opening view
Autodesk.Revit.DB.View openingView = currentDoc.ActiveView;

// Get opening view's name
string openingViewName = openingView.ViewName;

But everytime I get a NullReferenceException because the openingView object is null, which means that I cannot get the .ActiveView property of my currentDoc.

 

Is it because the currentDoc is opened in the background and not Active?

Is there a way to get the active view of a doc open in the background?
Or really, is there a way to get the Starting View of a document?

I searched the APIs everywhere but couldn't find anything.

 

Thanks!

 

Andrea

0 Likes
Accepted solutions (1)
2,749 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

No one?

I thought this one would have been an easy one 🙂

0 Likes
Message 3 of 4

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Andrea,

 

Thank you for your query.

 

The Building Coder answered it for you, in 2017:

 

https://thebuildingcoder.typepad.com/blog/2017/08/forge-installed-version-move-group-filter-by-name....

 

I hope this helps.

 

Since your email is registered as an ADN member, this thread was already automatically escalated to an ADN case 15419502 [Get active view of file open in background].

 

In addition, you manually escalated it to create a duplicate ADN case 15423509 [Get active view of file open in background].

 

There is no need for that, since, as said, it just creates a duplicate case.

 

I hope this clarifies, and am closing both ADN cases now.

 

If we need to discuss anything further, we can happily do so right here in this thread.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 4

Anonymous
Not applicable

Yeah that's exactly what I needed! Weird I didn't initially find it! Thanks a lot for the suggestion!!

 

Sorry about the duplication. I didn't know about the ADN thing. This won't happen again 😉

0 Likes