How to programmatically create MeshCube using omni.isaac class like FixedCuboid?

Please provide all relevant details below before submitting your post. This will help the community provide more accurate and timely assistance. After submitting, you can check the appropriate boxes. Remember, you can always edit your post later to include additional information if needed.

Isaac Sim Version

4.2.0
4.1.0
4.0.0
2023.1.1
2023.1.0-hotfix.1
Other (please specify):

Isaac Lab Version (if applicable)

1.2
1.1
1.0
Other (please specify):

Operating System

Ubuntu 22.04
Ubuntu 20.04
Windows 11
Windows 10
Other (please specify):

GPU Information

  • Model: RTX 4090
  • Driver Version: 560.94

Topic Description

Detailed Description

I want to apply a texture to a cube.
From my testing, I see that textures are only correctly applied to MeshCubes.

If you create a ShapeCube (seen as 2 in image above) or use one of the python classes FixedCuboid, or VisualCuboid the resulting primitive does not have the FaceAPI or the Normals attribute set on the mesh.

The only way I have found to programmatically create a MeshCube is using the Command

omni.kit.commands.execute(
    "CreateMeshPrimWithDefaultXform",
    prim_type="Cube",
    prim_path=cube_prim_path,
    select_new_prim=True,
    prepend_default_prim=True,
    above_ground=True,
)

Ideally, I would be able to use MeshCuboid class similar to FixedCuboid
If this class does not exist, what is the next best alternative?

Could I create a FixedCuboid and then manually apply the Face API and Normals attributes to the primitive?
If so, how can that be done?

Steps to Reproduce

N/A

Error Messages

N/A

Screenshots or Videos

See Above

Additional Information

What I’ve Tried

N/A

Related Issues

N/A

Additional Context

N/A

Hi there,

would wrapping the mesh in a GeometryPrim API work for you?

import omni.kit.commands
import omni.usd
from omni.isaac.core.prims.geometry_prim import GeometryPrim

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

omni.kit.commands.execute(
    "CreateMeshPrimWithDefaultXform",
    prim_type="Cube",
    prim_path="/World/MyCube",
    select_new_prim=True,
    prepend_default_prim=True,
    above_ground=True,
)

# Get the cube mesh prim
cube_mesh_prim = stage.GetPrimAtPath("/World/MyCube")
print(f"cube_mesh_prim type: {cube_mesh_prim.GetTypeName()}")

# Wrap the cube mesh prim as a GeometryPrim object
cube_geom_prim = GeometryPrim("/World/MyCube")
print(f"cube_geom_prim type: {type(cube_geom_prim)}")

The code you showed is still using the command to create the Mesh

omni.kit.commands.execute(
    "CreateMeshPrimWithDefaultXform",

The goal was to avoid that.
If we use the command, further modification to apply FaceAPI, Normals, Points. etc is not needed.

I think we would need to fine the appropriate USD Documentation for the Mesh API

OR perhaps something like this: CuboidMeshGenerator

In that case I think you would need to use vanilla USD code to create your desired mesh, or import an existing one from USD, then you wan wrap the prim into the desired isaac sim APIs.

Note that there is difference between primitive cube and mesh cube.

you would need to use vanilla USD code to create your desired mesh

Given word “need”, I assume this is an indirect answer to the question about a MeshCuboid helper class and you are confirming: It does not exist.

And the answer to next question

what is the next best alternative?

is to use vanilla USD code to create your desired mesh

Is there an example of this somewhere?
Perhaps I can modify it to my needs.

I see code like this which may be related

mesh = UsdGeom.Mesh.Define(stage, path)
mesh.CreateSubdivisionSchemeAttr().Set(UsdGeom.Tokens.bilinear)

USD Terms and Concepts — Universal Scene Description 24.11 documentation

there is difference between primitive cube and mesh cube

Yes, I showed this in the picture with Mesh cube on left and Shape cube on right. This difference is why textures do not render on primitives that despite having Mesh API, do NOT have (full) Mesh. Knowing what precisely the difference is would be helpful