Omniverse Code Extension: Spawn prim with non standard height, width and depth

Hi interwebs,

I’m writing my first Omni Code extension and am struggling with the function arguments. I have an extension working with a button that spawns a cube prim. I’d like to modify it to spawn a cube that doesn’t have a scale: [1, 1, 1]. This is what I’m currently using.

            def generate_random_algorithm_cube():

                omni.kit.commands.execute('CreateMeshPrimWithDefaultXform',
                    prim_type='Cube')
                

                omni.kit.commands.execute('TransformMultiPrimsSRTCpp',
                    count=1,
                    paths=['/World/Cube'],
                    new_translations=[0.0, 0.0, 0.0],
                    new_rotation_eulers=[0.0, 0.0, 0.0],
                    new_rotation_orders=[0, 1, 2],
                    new_scales=[(random.uniform(0.05, 3)), (random.uniform(0.05, 3)), (random.uniform(0.05, 3))],
                    old_translations=[0.0, 0.0, 0.0],
                    old_rotation_eulers=[0.0, 0.0, 0.0],
                    old_rotation_orders=[0, 1, 2],
                    old_scales=[1.0, 1.0, 1.0],
                    usd_context_name='',
                    time_code=0.0)

Hi @austencabret. I know we connected earlier on Discord, have you had any luck since?

Hi again Mati!

I’m able to scale the cubes! Thank you! I’m actually now trying to make a function that deletes all prims in a scene but it seems like wildcards (the * symbol) don’t work. When i do something, like select the prims by path ./World/Cube_* to choose all. I can delete a single prim. Do you know of a way to delete multiple?

            def delete():
                omni.kit.commands.execute('DeletePrims',
                                          paths=['/World/Cube',
                                                 '/World/Cube_01',
                                                 '/World/Cube_02',
                                                 '/World/Cube_03',
                                                 '/World/Cube_04',
                                                 '/World/Cube_05',
                                                 '/World/Cube_06',
                                                 '/World/Cube_07',
                                                 '/World/Cube_08',
                                                 '/World/Cube_09',
                                                 '/World/Cube_10'],
                                          destructive=False)