Script to toggle "Visible in Viewport" for all lights/cameras?
Martirilla
Posts: 181
From DAZ Studio 4.11.0.36 (2017) and higher there is an on/off setting in Parameters called "Visible in Viewport". This removes the wireframe of a light and a light's ray-indicators in the Viewport, but does not turn off the light in the scene. This also works the same for cameras.
I now wish to bodge together a script that toggles this visibility on-and-off, for all lights and cameras in a scene, with one click.
But I am a Python and not a Daz scripter. So initially I'm asking: is the official template script for 'node visibility toggle' (linked below) a good starting point for this? Also, does "Visible in Viewport" need to be referenced in any special way or have a special name in a Daz script?
Post edited by Martirilla on
Comments
DzNode has setVisibleInViewport(bool) and bool isVisibleInViewport() methods if you go diving. These are not documented in the current docs, so subject to change, but I think they have been in the relevant change logs so should be fairly safe.
To make sure you target the right things add a check that oNode.inherits( "DzCamera" ) - scene lights are all a special kind of camera.
Thanks. Here is the working script. It does what's needed without errors. But as I said... it's probably a bodge in several respects.
Oh great... code insertion no longer displays the code properly. How to view as a script, and not as one single long and thoroughly garbled line?
Ok, I'm now seeing if a DSA file attachment will work better, if the code can't display properly in the post itself.
Here's how to de-mangle the one-line code-posting, which the Daz forum's scripting sub-forum seems to have adopted since I was last here.
1. Click on the "Quote" button, on such a post.
2. The code and script now displays as it should.
3. Right-click on the code. "Copy". Exit and don't post the quote in the forum.
4. Paste what you copied to Notepad++ or Visual Studio Code or some other other useful free code editor. The basic Windows Notepad works, keeping the required indenting.
5. Top-and-tail the script. Because you will likely have a blank line that needs to be removed at the start of the script, and also a line reading "Click and drag to move" at the bottom.
Please make sure you obey the CC 3 by attribution terms for the use of sample scripts - I thought you had, but that must have been another script. You can most readily do this by downloading the code from the sample page (link above the code on the page) which will include the necessary sections in the opening header, then make your changes.
Attribution is given in the script header, on both posted versions of the script: "Derived from Daz's official Node_Visibility_Toggle.dsa script".
The link and license type are not given, though