Viewport in the form

Hello ,

I need create a windows form with Rhino viewport, Any idea how I can make this ??

Thanks

Hi @MatrixRatrix,

RhinoCommon does not provide a way of embedding a full-featured viewport into a form or dialog.

However, Rhino.UI has a simple view-only control - 'Rhino.UI.Controls.ViewportControl`. Here is a simple example of how to use it.

– Dale

4 Likes

Hi @dale , and add layout viewport ? is possible ?

Thanks

Hi @MatrixRatrix,

Sure. To add a layout, you can either script the -Layout command, or use the ViewTable.AddPageView RhinoCommon method.

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_DocObjects_Tables_ViewTable_AddPageView_1.htm

– Dale

@dale ,

This Add layout on form?? if so, how?

No, this adds a layout to the document.

– Dale

Dale Fugier

Can I Shade or Render this viewport in the form?
How I do?

Thanks

Another feature that would solve the problem would be to be able to orbit the model in the main viewport.

Thanks

Sure, just do something like this:

m_viewport_control.Viewport.DisplayMode = mode;
m_viewport_control.Refresh();

where:

m_viewport_control = Rhino.UI.Controls.ViewportControl
mode = Rhino.Display.DisplayModeDescription

– Dale

Dale Fugier

I need the ETO dialog box to lose focus and let me zoom and rotate in Rhino’s main viewport.
It would be better than having the viewport inside the ETO.

Why the viewport control embed in plugin dialog display the same as model in Rhino Viewport?,is this a bug?

Hi @dale, is it possible to set the projection in the viewport, say Top?

I’m trying with

mode = Rhino.Display.DisplayModeDescription.FindByName('Shaded')
proj = Rhino.Display.DefinedViewportProjection.Top
        
viewport0 = Rhino.UI.Controls.ViewportControl(Size = drawing.Size(400, 400))
viewport0.Viewport.DisplayMode = mode
Rhino.UI.Controls.ViewportControl.Viewport.PropertyType.SetProjection(viewport0, proj,'viewname', False)
viewport0.Refresh()

to set the projection, but ViewportControl doesn’t like that, so I’m guessing if there is another way to set projection for ViewportControl

And I couldn’t find Rhino.UI.Controls.ViewportContrls in the namespace window to the left of the python editor screen

Thanks for the advice.

Actually, I think I stumbled across the solution…

SetProjection works for a Rhino Viewport, not ViewportControl

So I changed the code to this: (I used the 2 print statements to tell me the type of each)

        mode = Rhino.Display.DisplayModeDescription.FindByName('Shaded')
        proj = Rhino.Display.DefinedViewportProjection.Top
        
        viewport0 = Rhino.UI.Controls.ViewportControl(Size = drawing.Size(400, 400))
        viewport0.Viewport.DisplayMode = mode
        
        #print viewport0.Viewport.DisplayMode
        #print viewport0.Viewport
        viewport0.Viewport.SetProjection( proj, '', False)
1 Like