How to know when PreviewControl is ready?

How to know when PreviewControl is ready?

Anonymous
Not applicable
433 Views
3 Replies
Message 1 of 4

How to know when PreviewControl is ready?

Anonymous
Not applicable

Hello!

I would like to process multiple files and using a PreviewControl. So I would like to ask that how can I know when a document is opened and ready to work with? I would like to repeatedly open a documents in that PreviewControl.

 

Thanks for any help in advance!

0 Likes
434 Views
3 Replies
Replies (3)
Message 2 of 4

arnostlobel
Alumni
Alumni

For every Revit document that is opened and ready to be worked with, Revit application raises a DocumentOpened event. Subscribe to that event from your external application's OnStartup routine.

Arnošt Löbel
0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you very much for your reply!

 

What I'm doing is that I open a document, initialize the PreviewControl with a view, set the parameters and call the ZoomToFit method which is belonging to the UIView class. When I try to get the current uiview from the PreviewControl object is when I get the error.

I think the program executes the line: UIView uiview = previewcontrol.UIView; too soon. Error says: "Can't get the the preview view"

 

Is it because the view is not ready yet? How can I start processing when view is ready?

 

 

0 Likes
Message 4 of 4

arnostlobel
Alumni
Alumni

I do not think it is about a document’s readiness, per se. If “you” open a document via the DB API method (OpenDocumentFile of the Application class), the document will not be visible and I suspect that it will not have a UI view. That is probably why you cannot get it. I also assume that if you use the OpenAndActivateDocument method (of UIApplication), then you should be able to get the UIView all right. 

Arnošt Löbel
0 Likes