Next camera/previous camera script
Richard Haseltine
Posts: 101,030
https://www.dropbox.com/s/gxvyefaoptw701e/Camera steppers.zip?dl=0
Scripts with icons to step through the scene's cameras, forwards or backwards.
Comments
Thanks for these, Richard. I've popped them on a toolbar.
Thanks!!
Thanks .... very useful to have in Daz studio!!! ;)
Would it be possible have a render performed through a specific camera no matter which viewport was selected?
I think only if you had a custom action to launch your render, which changed the current camera first (and of course you'd need to tell it whichc amera somehow - perhaps a node tag).
Yeah, in Daz Studio there seems to be no predefined Render Camera like in other 3D applications. From what I've read it all depends on the selected preview pane and the currently selected view. Would be cool to have a script that looks out for some definition on a Camera in the scene to set the desiered rendering perspective and then triggers the selected rendering engine. Maybe detect it by node label including "[Render]", so the user can easily define and switch the render camera by renaming. Such a script could become a replacement of the default Ctrl+R action. If no Render Camera is found fall back to default behaviour. If more than one [Render] Camera is found its user fail and the script picks up the first found. Just some of my scripting suggestions.
Multible render cameras possibel just by renaming the camera nodes the scene hierarchy changes I think?
By iterating over the scene nodes the first found in the alphabetic order would be picked, right?
Camera [Render] 01 my first Render
Camera [Render] 02 my second Render
I thought we could assign tags to nodes, but apaprently not. We could, however, assign a new property, such as a boolean "Render camera", via script and then use that to identify the camera(s) to use. Then you could use the methods in this scriptt o assign the camea to the view, and you just need to trigger a rnder (for which I think Rob has a sample script).
The tricky part would be to only allow one camera at a time to be switched On as Render Camera, while the others have to be set Off in the same moment. If the properties are hidden from user view and you only allow your script to change the Render Camera that could possibly work.
In my Precise Eye - Point At Null-Target.. project I had linked the Node Visible Boolean Properties of different Props and Nulls in the scene to a new Boolean controler with ERC-Freeze to have new Visibility properties VCTRL_ERC_...
However if its possible to trigger your script by switching On the Render Camera Boolean Property it could hunt down all other cameras in the scene with the same Boolean switch and turn them Off.
Hello Richard,
Very useful indeed!
Funny though, that nobody has noted so far: both scripts actually *increment* the Camera counter, meaning that they perform the same operation (Next camera).
I have edited the script in MS Visual Code and changed lines 83ff of "Prev camera.dsa" to the following:
// If we have any cameras set the next camera to view
// by *subtracting* one *from* the camera number
if (cams.length > 0) {
if ( curCamNo == 0 ) {
curCamNo = cams.length;
}
setCurrentCamera( cams[ curCamNo - 1 ] );
}
There are potentially more elegant ways to code this, but it did the trick ;-)
Best regards,
Guido
Thank you, and sorry for the error.
OK, I think that is fixed and the zip updated. It as fidly as I expected the % to act as a "clock arithmetic" operator, and take 0-1%n back to n-1, but in fact it allows negative values. My recollection is that that threw me at the time, but that doesn't explain how the wrong version of the backstep script ended up in the zip.)
No worries! It gave me the opportunity to take a look at DAZ Scripting in real life for the first time and luckily the syntax was kind of "straightforward" to follow.
Glad to have been able to make a contribution to the forums.
I just installed it and... both scripts does cause for me the same result, it goes to the next camera, I mean that is already nice, that I can skip through them. But why does it not go back only forward?
Edit: You did not update the zip, so the script is still wrong, but I got it now.
And thanks for coding it!
I use Daz 4.20
Edit: One more question, is it possible to change the script, that the selected camera get then also selected in my scene? I have 2 buttons to lock/unlock my camera, then can I jump from camera to camera, move it slightly and lock it, without going to the scene tab and selecting it.
I'll look at it in the morning, and try to figure out why dropbox isn't updated as I thought I had copied the new version across.
Cann you also try to make it work, that the camera then is selected when I press the hotkey? switch+select in scene List.
That was what I meant - I do havea script that will select the active camera, it's just a question of stealing some of its code.
OK, that should have updated them for real thjis time, and I have added a new version in a sub-folder (since I suspect it will be less used) that adds the camera to the selected nodes in the scene - so to lock all of them just click as often as needed and then hit the lock button.
Thank you, it is sadly not correct, it will keep selecting the last one, so
It will select the next but also keep selecting the previous.
Can you make, that it does ONLY select the current? "switch + select this" not "switch + also select this" so remove the "also".
Written in language :D
That would be more complex as there isn't, that I can see, a select none command - so it would have to go through each node in turn, deselecting it, which would eb a lot of overhead for a simple script like this.
I think you are looking for DzScene::selectAllNodes(false)
That sounds... correct, I am not a coder, but when it is inserted between the other lines, it could make this:
unselect all nodes
go to next camera in viewport
select the current camera.
Ah, I was looking for a specific command. Thank you.
OK, in that case it si trivial to do this yourself - open in a text editor and at the end of the script it says
if ( cams.length > 0 ) {
setCurrentCamera( cams[ ( curCamNo + 1 ) % cams.length ] );
// Select the camera too
cams[ ( curCamNo + 1 ) % cams.length ].select( true );
}
insert the bit from Miniflux, slightly adjusted to be a script command Scene.selectAllNodes(false); so you get
if ( cams.length > 0 ) {
setCurrentCamera( cams[ ( curCamNo + 1 ) % cams.length ] );
Scene.selectAllNodes(false);
// Select the camera too
cams[ ( curCamNo + 1 ) % cams.length ].select( true );
}
and the equivalent for the previous script and it should do what you want.
Can you build a script out of it, I can use?