How to make the current viewport GetFocus and scene pane LostFocus

crosswindcrosswind Posts: 4,727

Heya,

I wrote script to switch the cameras by pressing shortcut key - Shift + Arrows (Up/Down). However, while pressing the shortcut to have camera switched, if the scene pane is focused or a node is selected, there'll be a multiple nodes selection at the same time. Such a 'side effect' is annyoing~

So I wanna make the scene pane LostFocus and current viewport GetFocus before or after the camera switches. How to do that?

Thanks in advance~

Post edited by crosswind on

Comments

  • I'm not sure what you mean - is this about switching the view for the active 3D viewport or selecting nodes?

  • crosswindcrosswind Posts: 4,727
    edited March 2023

    Richard Haseltine said:

    I'm not sure what you mean - is this about switching the view for the active 3D viewport or selecting nodes?

    It's just about switching cameras ONLY by pressing a keyboard shortcut, not related to other views. Normally I have lots of cameras in the scene, I wanna use keyboard to quickly switch to each cameara in order (back & forth) other than selecting them from the View dropdown list. I've got everthing done but just would like to know a script of making the viewport get focused , just like the effect of using LMB to click on the area of Viewport...

    Post edited by crosswind on
  • DaremoK3DaremoK3 Posts: 798

    @crosswind :

    I don't have an answer for your focus issue, but it sounds like you are going through an object forLoop selection state for all scene objects (without exclusions), and selecting the cameras via the Scene (heirarchy) Pane (back-end) while cycling through your shortcut keys which is selecting all objects (even if one at a time, then deselecting) in your scene.

    Just an observation, I don't WANT TO assume anything, but you do know the difference between camera 'selection', and camera 'assignment' (we'll call it this for lack of a better word [gurus; Correction wanted/needed...]) for the 3D Viewport, right?

    For those who don't know (not necessarily you), selection gets you control of your camera, but assignment tells Studio which camera to view/use/render from.

    I believe (and I can be very wrong, so correct me if I am) you are cycling through selecting your cameras, and not cycling through the camera assignments (as you would with 3D Viewport drop-down camera view selections).

    If you need the camera controls for each cycle through, then you are fine and just need to add object exclusions (everything not a DzCamera) to your object selections/deselections in your forLoop.

    If you need just the camera assignments, then you need to ditch the object selections forLoop, and concentrate on DzCamera assignment selection.

    If you need both, then you are half way there, and you just need to add code for the camera assignment selections as well.

    Check the DzCamera and inherited code API in the Object Index for the correct syntax for getting the camera assignments and setting up your shortcut keys with those as opposed to cycling through the heirarchy selections.

    I hope this helps, and if not, please disregard and carry on...

  • This is a simple script for stepping through cameras https://www.dropbox.com/s/gxvyefaoptw701e/Camera steppers.zip?dl=0

    As for setting focus, I think DzViewportMgr is what you need - http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/viewportmgr_dz#a_1a0c4c287a364de06481bf91d91ed0484b to do the setting, though you would need to get the available Viewports first.

  • crosswindcrosswind Posts: 4,727

    DaremoK3 said:

    @crosswind :

    I don't have an answer for your focus issue, but it sounds like you are going through an object forLoop selection state for all scene objects (without exclusions), and selecting the cameras via the Scene (heirarchy) Pane (back-end) while cycling through your shortcut keys which is selecting all objects (even if one at a time, then deselecting) in your scene.

    Just an observation, I don't WANT TO assume anything, but you do know the difference between camera 'selection', and camera 'assignment' (we'll call it this for lack of a better word [gurus; Correction wanted/needed...]) for the 3D Viewport, right?

    For those who don't know (not necessarily you), selection gets you control of your camera, but assignment tells Studio which camera to view/use/render from.

    I believe (and I can be very wrong, so correct me if I am) you are cycling through selecting your cameras, and not cycling through the camera assignments (as you would with 3D Viewport drop-down camera view selections).

    If you need the camera controls for each cycle through, then you are fine and just need to add object exclusions (everything not a DzCamera) to your object selections/deselections in your forLoop.

    If you need just the camera assignments, then you need to ditch the object selections forLoop, and concentrate on DzCamera assignment selection.

    If you need both, then you are half way there, and you just need to add code for the camera assignment selections as well.

    Check the DzCamera and inherited code API in the Object Index for the correct syntax for getting the camera assignments and setting up your shortcut keys with those as opposed to cycling through the heirarchy selections.

    I hope this helps, and if not, please disregard and carry on...

    Thanks a lot! Still very useful~ I'll learn and test~enlightened

  • crosswindcrosswind Posts: 4,727

    Richard Haseltine said:

    This is a simple script for stepping through cameras https://www.dropbox.com/s/gxvyefaoptw701e/Camera steppers.zip?dl=0

    As for setting focus, I think DzViewportMgr is what you need - http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/viewportmgr_dz#a_1a0c4c287a364de06481bf91d91ed0484b to do the setting, though you would need to get the available Viewports first.

    Richard, many thanks! I'll check and learn~

Sign In or Register to comment.