Steven_Nie
(Steven Nie)
October 15, 2024, 4:48am
1
Hey all, I don’t understand why the following code below will not turn off the ground plane for my rendering. Let me know if I miss anything. Thanks!
settings = self.document.RenderSettings
prev_ground_plane_enabled = settings.GroundPlane.Enabled
settings.GroundPlane.Enabled = False
self.document.RenderSettings = settings
temp_dir = tempfile.gettempdir()
random_filename = str(uuid.uuid4()) + '.png'
file_path = os.path.join(temp_dir, random_filename)
Rhino.RhinoApp.RunScript("_Render", True)
rhinoscriptsyntax.Command("-_SaveRenderWindowAs \"{}\"".format(file_path))
Rhino.RhinoApp.RunScript('_CloseRenderWindow', True)
nathanletwory
(Nathan 'jesterKing' Letwory)
October 15, 2024, 5:12am
2
You don’t need to do self.document.RenderSettings = settings
. Instead you need to bracket the place where you change the status with BeginChange
and EndChange
method calls:
settings.GroundPlane.BeginChange(Rhino.Render.RenderContent.ChangeContexts.Program)
settings.GroundPlane.Enabled = False
settings.GroundPlane.EndChange()
2 Likes
Steven_Nie
(Steven Nie)
October 15, 2024, 5:16am
3
Thank you Nathan, is BeginChange/EndChange only required for GroundPlane settings? I also changed the following settings and they seem to work.
settings.ImageSize = ...
settings.UseViewportSize = False
settings.TransparentBackground = True
settings.SpecificViewport = viewport_name
nathanletwory
(Nathan 'jesterKing' Letwory)
October 15, 2024, 5:18am
4
Not all data requires that. You can always refer to the documentation to see if a class you are accessing has BeginChange
/ EndChange
. If it does you know it needs that:
1 Like
Steven_Nie
(Steven Nie)
October 16, 2024, 4:30am
5
I just realized this property does not exists for Rhino 7. Is the anyway to do this for Rhino 7? Thanks!
Steven_Nie
(Steven Nie)
October 16, 2024, 5:10am
6
nathanletwory
(Nathan 'jesterKing' Letwory)
October 16, 2024, 5:46am
7
That is the way for older versions since Rhino 5.
1 Like