Import USD-Assets with a button in a custom extension

Hello,
I want to load files with a button in my Omniverse Isaac extension but I can’t find any examples or any possible function. I already created the button in my extension window, but I don’t know which function to use. If I click the button in my extension I want to open a classic folder window to choose my asset from and use the chosen folder in my extension.py. Right now I can only use a static folder+asset name in the extension but since I want this extension to be easy to use it would be better to simply choose it by selecting it in the right folder so I don’t need to put it in the right static folder I am using to import my assets and rename it so it fits the import process.

I hope you get what my problem is here.

Thank you for your help!

Okay I was just too stupid to read the stringfield builder API :smh:. Here is how I’ve done it if someone wants to do the same:

def build_settings_ui(self, frame):
        with frame:
            with ui.VStack(spacing=5):
                # Update the Frame Title
                frame.title = "Settings"
                frame.visible = True
                dict = {
                    "label": "Filepath",
                    "type": "stringfield",
                    "default_val" : "/home/",
                    "tooltip": "Choose the box to let parts fall into",
                    "use_folder_picker" : True,
                }
                self.settings_elements["Filepath"] = str_builder(**dict)

                dict = {
                    "label" : "Load Box",
                    "type" : "button",
                    "text" : "Load Box Sample",
                    "tooltip" : "",
                    "on_clicked_fn" : self._on_load_box_event
                }
                self.settings_elements["Load Box"] = btn_builder(**dict)
                self.settings_elements["Load Box"] = True

    def _on_load_box_event(self):
        _filepath = self.settings_elements["Filepath"].get_value_as_string()
        self.sample._on_load_box_event(_filepath)
        return
1 Like

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