Create Pattern Projector in Replicator

Hello,

I tried to create a pattern projector by building a rectangular light (which works fine, and the texture.png is loaded), but when I want to set the “.isProjector” Boolean to “True” nothing happens, I don’t get an error message either. Is there a possibility to either set the value to True while creating or another way. Or can you check my function to see if I did something wrong?

def pattern_projector(self,pattern):
        #pattern in "name.png" format
        prim_path = "/Replicator/Projector_Xform/Projector"
        pos_off_proj = np.asarray([0.0115,0,0])
        rep.create.light(
                light_type = "Rect",
                temperature = 6500,
                intensity = 2,     
                position = self.pos_center[0]+pos_off_proj,
                rotation = self.pos_center[1][1:],
                scale = 1,
                texture = self.base_path + "Pattern_Projector/" + pattern,
                name = "Projector",
        )
        omni.kit.commands.execute("ChangeProperty",
            prop_path=Sdf.Path(prim_path + ".isProjector"),
            value=True,
            prev=False)

Also another question: Is it possible to set the prim path in the creation process? I want to change it to another path.

Hi there,

sorry for the late reply. It seems the isProjector attribute is not created yet, here is a script which checks for this first and creates a new attribute if not there:

import omni.replicator.core as rep
import omni
from pxr import Sdf

TEXTURE = "omniverse://localhost/NVIDIA/Assets/ArchVis/Commercial/Tables/Textures/WillowTable_Wood_A.png"
rep.create.light(light_type="Rect", name="Projector", texture=TEXTURE)

stage = omni.usd.get_context().get_stage()

light_path = "/Replicator/Projector_Xform/Projector"
light_prim = stage.GetPrimAtPath(light_path)
attr_name = "isProjector"
is_projector_attr = light_prim.GetAttribute(attr_name)

if not is_projector_attr:
    print("is_projector_attr is None, creating a new one..")
    omni.kit.commands.execute(
        "CreateUsdAttribute",
        prim=light_prim,
        attr_name=attr_name,
        attr_type=Sdf.ValueTypeNames.Bool,
        attr_value=True
    )
else:
    print(f"is_projector_attr={is_projector_attr}")
    omni.kit.commands.execute(
        "ChangePropertyCommand",
        prop_path=is_projector_attr.GetPath(),
        value=True,
        prev=is_projector_attr.Get()
    )

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