Skip to content

Commit

Permalink
Add Save Carb Settings action to CesiumPowerTools
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Jul 11, 2023
1 parent 284c531 commit 255a5f6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ _testoutput

# Tracing files
cesium-trace-*.json

# Carb settings from Cesium Power Tools extensions
carb_settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from typing import Callable, Optional, List
from cesium.omniverse.ui import CesiumOmniverseDebugWindow
from .georefhelper.georef_helper_window import CesiumGeorefHelperWindow
from .utils import extend_far_plane
from .utils import extend_far_plane, save_carb_settings
import os
from functools import partial

powertools_extension_location = os.path.join(os.path.dirname(__file__), "../../")


class PowertoolsAction:
Expand Down Expand Up @@ -39,6 +43,7 @@ def __init__(self, **kwargs):
PowertoolsAction("Open Cesium Debugging Window", CesiumOmniverseDebugWindow.show_window),
PowertoolsAction("Open Cesium Georeference Helper Window", CesiumGeorefHelperWindow.create_window),
PowertoolsAction("Extend Far Plane", extend_far_plane),
PowertoolsAction("Save Carb Settings", partial(save_carb_settings, powertools_extension_location)),
]

self.frame.set_build_fn(self._build_fn)
Expand Down
9 changes: 9 additions & 0 deletions exts/cesium.powertools/cesium/powertools/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import omni.usd
from omni.kit.viewport.utility import get_active_viewport
from pxr import Gf, UsdGeom
import json
import carb.settings
import os


# Modified version of ScopedEdit in _build_viewport_cameras in omni.kit.widget.viewport
Expand Down Expand Up @@ -38,3 +41,9 @@ def extend_far_plane():

scoped_edit = ScopedEdit(stage) # noqa: F841
camera.GetClippingRangeAttr().Set(Gf.Vec2f(1.0, 10000000000.0))


def save_carb_settings(powertools_extension_location: str):
carb_settings_path = os.path.join(powertools_extension_location, "carb_settings.txt")
with open(carb_settings_path, "w") as fh:
fh.write(json.dumps(carb.settings.get_settings().get("/"), indent=2))

0 comments on commit 255a5f6

Please sign in to comment.