Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Independent View with Preview Control

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
1277 Views, 9 Replies

Independent View with Preview Control

Hi everyone,

 

At work, I am working on 2 screens at the same time.
To radically utilize the screen space, I had intention of creating an independent view which can be previewed on the second screen while the main interface is still able to work normally on the main screen.
I am attempting to implement this intention with the below code fragment. In my code, I invoked the form using form.Show() method (instead of form.ShowDialog()). However, after the form is shown, other views seem to be disabled, I could not do anything with them except zooming.

 

Anybody with any idea?

 

My code

 

ElementId currentViewId = Doc.ActiveView.Id;
PreviewControlForm frm = new PreviewControlForm(commandData.Application.Application,currentViewId);
PreviewControl vc = frm.elementHost1.Child as PreviewControl;
if (vc != null) {vc.Dispose();}            
frm.elementHost1.Child = new PreviewControl(Doc, currentViewId);
frm.Show();
frm.TopMost = true;

 

Thank you

Nguyen Duy Hoa

 

 

 

9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

Hi,

there is a limitation in the PreviewControl that it must be placed in a modal view.
I have not yet used this functionality, but that is most likely why you are seeing this problem.

I do not think one can achieve what you want at the moment.

 

/Erik

Message 3 of 10
Anonymous
in reply to: Anonymous

Hi  Erik,

 

Thanks for your reply

 

I used to thought that this problem is caused of multi-thread issue since I showed the form with form.show() method. But when I implemented the form in the same way with the modeless sample in SDK samples, it also came with same failure.

 

If the cause is as you stated, this is the significant limitation and thus what I am trying may be impossible.

 

Hope someone can have some tricks to pass over this issue as I bet that this is not only my need.

 

Thank you

Nguyen Duy Hoa

Message 4 of 10
Anonymous
in reply to: Anonymous

Yup, Id say file a request for a new feature if you really want it. This is a direct quote from the api reference about the previewcontrol class: "The dialog or form or window host this preview control must be modal."


Just a tip along the way though: did you try moving the properties and project browser out of the Revit window?
Alot of our staff do that since many of us have two screens and they want to utilize it better, or you could just manually stretch the window when its not maximized.

 

/Erik

Message 5 of 10
Anonymous
in reply to: Anonymous

Yes indeed,

 

As your suggestion, I can manually move the properties palette and the project browser out of the Revit window or stretch the Revit window over 2 screens. However, while it is more convenient and programmatic, I prefer doing this with Revit API

 

Please file a request for a new feature if you would not mind

 

Thanks a lot for your consultation

 

Nguyen Duy Hoa

Message 6 of 10
Revitalizer
in reply to: Anonymous

Hi Mr. Hoa,

 

you could do that without Revit API.

Just use plain Windows API to move or re-arrange the project browser and properties palette.

 

http://www.pinvoke.net/default.aspx/user32.movewindow

You need to find the correct window handles to move them.

To get their names and other properties, use Spy++.

 

 

Revitalizer

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 10
Anonymous
in reply to: Revitalizer

Hi Revitalizer,

 

Thank you for providing me another option

 

Although with your suggestion, I can programmatically adjust the Revit window as I wish. However, by this way, the views are still inside of the main Revit Window, it means I still have to deal with the below troubles:


1. Views are partly covered by the top ribbons. This does not radically utilized screen space as I desired
2. I need to re-arrange the views inside the main Revit window everytime I open more views or circle through existing views. It is a bit annoying and time consuming

 

If the Preview Control can be shown in modeless form, the above two points are completely satisfied

 

Thank you

Nguyen Duy Hoa

Message 8 of 10
Anonymous
in reply to: Anonymous

Have you tried using an external event to run your code could be worth a try...
Message 9 of 10
Anonymous
in reply to: Anonymous

Hi,

 

A trial was made in the way of external event (same way with the ModelessDialog in SDK samples), but same failure came up

Either the Preview Control or native views in the Revit window can be enabled at a time

 

Thank you

Nguyen Duy Hoa

Message 10 of 10
FrankHolidaytoiling
in reply to: Anonymous

I found this code on the spiderinet website
Does anyone know how I can achieve a preview that changes on clicking rows of views on a winform?

• Expose the ElementHost controls of the form to the outside world through adding the following property to the form class.
public System.Windows.Forms.Integration.ElementHost PreviewHost
{
get
{
return elementHost1;
}
}
• Add the following code to the Execute() this time.
Form1 form = new Form1();
form.PreviewHost.Child = new PreviewControl(CachedDoc, CachedDoc.ActiveView.Id);
form.ShowDialog();

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community