Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.

Commit ba20067

Browse files
committed
ISIM-1493 update frame imported asset
1 parent 8af9bab commit ba20067

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ PACKAGE-DEPS.yaml
1919
# Internal CI/CD files.
2020
/.teamcity
2121
/tools/ci
22+
.lastformat

.lastformat

Lines changed: 0 additions & 1 deletion
This file was deleted.

source/extensions/omni.importer.mjcf/config/extension.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ reloadable = true
33
order = 0
44

55
[package]
6-
version = "1.1.0"
6+
version = "1.1.1"
77
category = "Simulation"
88
title = "Omniverse MJCF Importer"
99
description = "MJCF Importer"
@@ -25,6 +25,7 @@ preview_image = "data/preview.png"
2525
"omni.kit.commands" = {}
2626
"omni.kit.window.extensions" = {}
2727
"omni.kit.window.property" = {}
28+
"omni.kit.viewport.utility" = {}
2829

2930
[[python.module]]
3031
name = "omni.importer.mjcf"

source/extensions/omni.importer.mjcf/docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [1.1.1] - 2024-07-10
4+
### Changed
5+
- Importer frames on imported asset when done through GUI.
6+
37
## [1.1.0] - 2023-10-03
48
### Changed
59
- Structural and packaging changes

source/extensions/omni.importer.mjcf/python/scripts/extension.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from omni.client._omniclient import Result
2020
from omni.importer.mjcf import _mjcf
2121
from omni.kit.menu.utils import MenuItemDescription, add_menu_items, remove_menu_items
22+
from omni.kit.viewport.utility import get_active_viewport
2223
from omni.kit.window.filepicker import FilePickerDialog
2324
from pxr import Sdf, Usd, UsdGeom, UsdPhysics
2425

@@ -335,14 +336,29 @@ async def import_with_clean_stage():
335336
if upAxis == "Y":
336337
carb.log_error("The stage Up-Axis must be Z to use the MJCF importer")
337338
add_reference_to_stage()
339+
return prim_path
338340

339341
def _select_picked_file_callback(self, dialog: FilePickerDialog, filename=None, path=None):
340342
if not path.startswith("omniverse://"):
341343
self.root_path = path
342344
self.filename = filename
343345
if path and filename:
344346
self._last_folder = path
345-
self._load_robot(path + "/" + filename)
347+
prim_path = self._load_robot(path + "/" + filename)
348+
task = asyncio.ensure_future(omni.kit.app.get_app().next_update_async())
349+
asyncio.ensure_future(task)
350+
print("update")
351+
viewport_api = get_active_viewport()
352+
stage = viewport_api.stage
353+
mpu = UsdGeom.GetStageMetersPerUnit(stage)
354+
cam_path = viewport_api.camera_path
355+
omni.kit.commands.execute(
356+
"FramePrimsCommand",
357+
prim_to_move=cam_path,
358+
prims_to_frame=[prim_path],
359+
aspect_ratio=1,
360+
zoom=0.05 * (self._models["scale"].get_value_as_float()),
361+
)
346362
else:
347363
carb.log_error("path and filename not specified")
348364
else:

0 commit comments

Comments
 (0)