How to set "single side" using API

Hi, I wanted to use the Python API to set “single side” to True in Isaac sim, but this was not successful.
attr = prim.GetAttribute(“singleSided”)
attr.Set(True)

But strangely, I succeeded in setting “double side” with this API.
attr = prim.GetAttribute(“doubleSided”)
attr.Set(True)

Does anyone know what I should do? Thank you very much!

@1297691410 i am just another user, but your python snippet would work in other OV apps like Composer. the reason why it’s not working in Isaac Sim is because that attribute isn’t defined whilst doubleSided is. it’s actually something i didn’t realize until attempting to troubleshoot your question. i’ll defer to the mods/devs on why it’s excluded; but, for now, i could offer two options that will allow you to create the singleSided attribute:

  • manually - go to your prim property, and choose + Add > Attribute. then follow the Add Attribute window (see images below). once this flag has been added to the prim, your original snippet should work without throwing an error.
    image
    image

  • programmatically - use the snippet below to create and set the attribute. feel free to consult the doc on creating an attribute as well - Create an Attribute — Omniverse Developer Guide latest documentation

import omni.kit.commands
import omni.usd

from pxr import Gf, Sdf, Usd, UsdGeom

def create_bool_attribute(prim: Usd.Prim, attribute_name: str) -> Usd.Attribute:
	omni.kit.commands.execute("CreateUsdAttributeCommand",
		prim=prim,
		attr_name=attribute_name,
		attr_type=Sdf.ValueTypeNames.Bool)
	attr: Usd.Attribute = prim.GetAttribute(attribute_name)
	return attr

# get stage
stage: Usd.Stage = omni.usd.get_context().get_stage()

# get prim
prim: Usd.Prim = stage.GetPrimAtPath("/World/Plane")

# create and set singleSided attribute to true
bool_attr: Usd.Attribute = create_bool_attribute(prim, "singleSided")
bool_attr.Set(True)

Thank you very much for your response! It resolved my issue in my code.

1 Like

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