AttributeError: 'NoneType' object has no attribute 'get_attribute_exists'

I’m trying to import a random selection of usd’s into an omniverse scene from a folder on my computer. I’ve tried the example code that uses assets from Nucleus, and I’m able to call assets for dome light textures. I’m not sure what going wrong or why I’m getting this error. Here’s the code as well as the log.
kit_20221206_152022.log (3.0 MB)

import omni.replicator.core as rep

with rep.new_layer():
camera = rep.create.camera(position=(0, 0, 1300), focal_length = 18.14756)
render_product = rep.create.render_product(camera, (1920, 1200))

bottles = '/home/ubuntu/Documents/AIM/Bottles/USD/middle'
theCone = rep.create.cone(semantics=[('class', 'cone')], position=(0, 0, -201), rotation=(90,0,0), scale=(21.4, 29.9, 12), visible=False)

def dome_light():
    dome = rep.create.light(
        light_type="Dome",
        rotation=(270,0,0),
        texture=rep.distribution.choice([
            '/home/ubuntu/Documents/AIM/EXR/belfast_sunset_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/belfast_sunset_puresky_4k.hdr', 
            '/home/ubuntu/Documents/AIM/EXR/castel_st_angelo_roof_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/clarens_midday_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/garden_nook_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/golf_course_sunrise_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/lythwood_field_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/noon_grass_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/pretville_cinema_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/rainforest_trail_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/rustig_koppie_puresky_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/snowy_field_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/sunflowers_4k.hdr',
            '/home/ubuntu/Documents/AIM/EXR/wide_street_01_4k.hdr'
            ])
        )
    return dome.node
rep.randomizer.register(dome_light)

def distant_light():
    sun = rep.create.light(
        light_type = "Distant",
        position = rep.distribution.uniform((-3000, -3000, -3000), (3000, 3000, 3000)), 
        intensity = rep.distribution.uniform(3000, 7000), 
        look_at = (0, 0, 0)
        )
    return sun.node
rep.randomizer.register(distant_light)

def move_shapes(size=14):
    instances = rep.randomizer.instantiate(rep.utils.get_usd_files(bottles), size=size, mode='point_instance')
    with instances:
        rep.modify.pose(
            rep.modify.pose(rotation = rep.distribution.uniform((0, 0, 0), (360, 360, 360))),
            rep.randomizer.scatter_3d(volume_prims=theCone, check_for_collisions=True)
        )
    return instances.node
rep.randomizer.register(move_shapes)

with rep.trigger.on_time(interval=1, num=51):
    rep.randomizer.move_shapes()
    rep.randomizer.dome_light()
    rep.randomizer.distant_light()

writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(
    output_dir="BottleStorm4.0500", 
    rgb=True, 
    bounding_box_2d_loose=True, 
    instance_segmentation=True
)
writer.attach([render_product])

Hello @jonathan.meitzler! I’ve reached out to the dev team for some help!

@jonathan.meitzler

Not sure if this is it but I see a possible syntax error in your code.

In your code you have

with instances:
        rep.modify.pose(
            rep.modify.pose(rotation = rep.distribution.uniform((0, 0, 0), (360, 360, 360))),
            rep.randomizer.scatter_3d(volume_prims=theCone, check_for_collisions=True)
        )

I don’t think you want rep.modify.pose(rotation = rep.distribution.uniform((0, 0, 0), (360, 360, 360))) as your first arg.
For rep.modify.pose:

  • The first arg is position, (actually a kwarg position=)
  • The second arg is the rotation, (actually a kwarg rotation=)
    rep.randomizer.scatter_3d(volume_prims=theCone, check_for_collisions=True) should be on the next line outside of the brackets as I don’t believe that rep.randomizer.scatter_3d can be used as a rotation.

It seems like you should have this instead:

with instances:
        rep.modify.pose(
            rotation = rep.distribution.uniform((0, 0, 0), (360, 360, 360))
        )
        rep.randomizer.scatter_3d(volume_prims=theCone, check_for_collisions=True)

Try that and see if you get the same error

It fixed the syntax error, but there’s another problem. The items aren’t moving around but are still rotating, and they’re all the same item even though I set with_replacements to false.

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