I’m working on Cross Platform development for a new plugin and have no issue creating floating viewports on windows with some simple python code like this:
However, when ran on the MacOS via ScriptEditor I get a “RhinoView” but that RhinoView has a width and height of 0,0 respectively, regardless of what I set the “rect” variable to in the constructor.
Is this repeatable for anyone else? @wim@Gijs@eirannejad is this behavior present on your end with MacOS?
Result (Windows):
Floating viewport shows up maximized on main screen (if multiple monitors)
Print Statement (Windows):
NewView Size: {Width=1920, Height=1057}
Rect Size: {Width=600, Height=600}
Result (MacOS):
Floating viewport does not show up despite no errors being thrown
Print Statement (MacOS):
NewView Size: {Width=0, Height=0}
Rect Size: {Width=600, Height=600}
I have tested with IronPython2 as well and that seems to have the same issue.
The viewport DOES get added on to the view list on the bottom on mac, always, but it never floats. Likely the size is 0,0 because it’s not been opened yet and hasn’t ever rendered.
There is a command NewFloatingViewport that can create one, so it is possible.
Yes, I believe this makes a lot of sense. I’d expect it to make a floating frame, but it currently will not do anything. I’m having a crack at the code to see if I can make it do something.
I did some poking, but I haven’t fixed anything yet, I’m still a bit green on this low level part of Rhino.
You will likely need a proper fix from us on this one. That said, you can try and create a workaround using that command and then manipulating the floating view.
Thanks @CallumSykes , I appreciate the response and looking into it!
Unfortunately I’ll need the full argument logic outside of just the rhinoscriptsyntax commands so I will eagerly await a response/fix and occasionally “poke” and eagerly check in on the progress of that
By the way in case anyone needs a workaround, the following code will work on both windows and mac to create a floating viewport:
OS = "MacOS" if Rhino.Runtime.HostUtils.RunningOnOSX else "Windows"
view_rectangle = System.Drawing.Rectangle(self.Location.X, self.Location.Y,
self.Size.Width, self.Size.Height)
if OS == "Windows":
# print("Using Windows OS method of viewport creation")
# This doesn't work on Mac OS
self.viewport = Rhino.RhinoDoc.ActiveDoc.Views.Add(
"MyFloatingViewport",
Rhino.Display.DefinedViewportProjection.Perspective,
view_rectangle,
floating=True)
else:
# print("Using Mac OS method of viewport creation")
# Test work around for 0 height, 0 width Mac OS viewport bug
rs.Command("_NewFloatingViewport _Projection Perspective") # This works on Mac OS
viewport = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport
viewport.Name = "MyFloatingViewport"
viewport.ScreenRectangle = view_rectangle
self.viewport = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView