Why are layout changes not reflecting when i change default.json file dynamically?

Subject: why are layout changes not reflecting when i change default.json file dynamically??

Description:
I am trying to implement functionality where some windows show/hide when i click on show/hide buttons. So i am changing default.json file dynamically(example setting “width”: 0.0 to hide and “width”: 181 to show again). But it is not reflecting changes until i restart the application. I want to see changes dynamically on click of buttons. Please help, thanks.

Below is my json file.

default.json

[

{

"children": [

  {

    "children": [

      {

        "dock_id": 1,

        "dock_tab_bar_enabled": false,

        "dock_tab_bar_visible": false,

        "height": 41.0,

        "position_x": 0.0,

        "position_y": 22.0,

        "selected_in_dock": true,

        "title": "Toolbar 1",

        "visible": true,

        "width": 1500.0

      }

    ],

    "dock_id": 1,

    "position": "TOP"

  },

  {

    "children": [

      {

        "children": [

          {

            "dock_id": 3,

            "dock_tab_bar_enabled": false,

            "dock_tab_bar_visible": false,

            "height": 889.0,

            "position_x": 0.0,

            "position_y": 84.0,

            "selected_in_dock": true,

            "title": "Menu 1",

            "visible": true,

            "width": 181.0

          }

        ],

        "dock_id": 3,

        "position": "LEFT"

      },

      {

        "children": [

          {

            "children": [

              {

                "dock_id": 5,

                "dock_tab_bar_enabled": false,

                "dock_tab_bar_visible": false,

                "height": 891.0,

                "position_x": 194.0,

                "position_y": 83.0,

                "selected_in_dock": true,

                "title": "Viewport Scene",

                "visible": true,

                "width": 1232.0

              }

            ],

            "dock_id": 5,

            "position": "LEFT"

          },

          {

            "children": [

              {

                "children": [

                  {

                    "dock_id": 7,

                    "dock_tab_bar_enabled": false,

                    "dock_tab_bar_visible": false,

                    "height": 845.0,

                    "position_x": 1416.0,

                    "position_y": 95.0,

                    "selected_in_dock": true,

                    "title": "Color Properties",

                    "visible": true,

                    "width": 255.0

                  }

                ],

                "dock_id": 7,

                "position": "TOP"

              },

              {

                "children": [

                  {

                    "dock_id": 8,

                    "dock_tab_bar_enabled": false,

                    "dock_tab_bar_visible": false,

                    "height": 59.0,

                    "position_x": 1346.0,

                    "position_y": 937.0,

                    "selected_in_dock": true,

                    "title": "Color Producer",

                    "visible": false,

                    "width": 260.0

                  }

                ],

                "dock_id": 8,

                "position": "BOTTOM"

              }

            ],

            "dock_id": 6,

            "position": "RIGHT"

          }

        ],

        "dock_id": 4,

        "position": "RIGHT"

      }

    ],

    "dock_id": 2,

    "position": "BOTTOM"

  }

],

"dock_id": 3351234147

},

{

"dock_id": 0,

"height": 0.0,

"position_x": 3.2211111663852886e+38,

"position_y": 3.6666666663852886e+38,

"selected_in_dock": false,

"title": "Options",

"visible": false,

"width": 230.0

}

]

You may well be changing the json file dynamically, but you will need to tell Composer or whatever kit file you are using to reload the json file from disk. It is not continuous or automatic. The fastest way, the way I do it, is to do a “Quick Save” of your layout file and then a “Quick Load” of it back again. The keyboard shortcut is just CTRL + 8, and it loads instantly. That would be my suggestion.

I don’t want to use manually; I want to hide panels through python code so that’s why I am using .Json file so do we have any in built function where we can use for by default restart as per starting phase.

If you want to do this automatically through code you can create a custom extension that loads your quickload json file on startup.

from omni.kit.quicklayout import QuickLayout

async def _load_layout(layout_file: str):
    """Loads a provided layout file and ensures the viewport is set to FILL."""
    await omni.kit.app.get_app().next_update_async()
    QuickLayout.load_file(layout_file)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.