Determine Document State ? DisplayedInUI : InBackground

Determine Document State ? DisplayedInUI : InBackground

lwlXUTTT
Advocate Advocate
528 Views
4 Replies
Message 1 of 5

Determine Document State ? DisplayedInUI : InBackground

lwlXUTTT
Advocate
Advocate

Dear Community,

Is there any fast/clean method to determine whether the document has been opened and activated in UI oraz just runs in the background?

I used to check it this way:

doc.ActiveView != null

but I was wondering if there is any better way,

 

any help much appreciated

/Lukasz

0 Likes
Accepted solutions (1)
529 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni
Accepted solution

The approach you describe is exactly what came to mind. If it works, it sounds like a good one to me.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 5

floretti
Advocate
Advocate

Hi Lukasz, were you successful on your approach? I'm trying to do the same but via the Revit Lookup I found that only the active document has a not null active view. Thank you.

0 Likes
Message 4 of 5

lwlXUTTT
Advocate
Advocate

Hi @floretti ,

 

I was not aware of that...

But then another solution that comes to my mind is:

https://www.revitapidocs.com/2015/1ac8b262-9085-07e9-cef6-85377e8c70f3.htm

if list of ViewIds > 0 then

Document is opened and activated

 

please let me know whether it works for you,

Best, Lukasz

0 Likes
Message 5 of 5

floretti
Advocate
Advocate

I tried but in order to get the OpenUIViews you need to loop through each document making it active in the UI.

ActiveUIDocument.GetOpenUIViews();

 

After some research I found out that there are (still) no native ways to activate open documents (refer to this article) and the effort won't outweigh the benefits I'll get from this so I'm dropping it.

0 Likes