Rotating a prim around the center (0,0,0) or another prim using an Action Graph

Hi, here’s my Action Graph that rotates my cube around its Y axis. How do I alter it to make the cube rotate around another prim/or a center point at (0,0,0)?

The easiest method is to just parent that cube to an xform and offset it from the xform some amount. Then rotate the xform instead.

Hi Richard3D, thanks for your reply. I’d like the cube to rotate around another prim regardless of either hierarchy, eg. if either hierarchy changes in any way, the prims become re-parented or moved to separate hierarchies etc.

I’m trying to script constraints using the UsdGeomConstraintTarget class: Universal Scene Description: UsdGeomConstraintTarget Class Reference

Here’s my .usd scene in which I’d like to create a constraint between my cube and cylinder, so that when cylinder rotates around it’s Y axis for example, the cube rotates around it. I’m looking into contraints bc the prims’ hierarchy will change:


the constraintTarget gets added to Cube, but when I rotate the Cylinder which I’d like to be cube’s pivot, the cube doesn’t rotate.

Here’s the code:

context = omni.usd.get_context()
    context.open_stage('C:/adding_constraints.usd')
    stage = context.get_stage() 
    
    cube_prim = stage.GetPrimAtPath("/World/Cube")
    cylinder_prim = stage.GetPrimAtPath("/World/Cylinder")
    current_frame = Usd.TimeCode.Default()
    xform_cache = UsdGeom.XformCache(current_frame)

    cube_prim.SetMetadata('kind', 'component')
    
    cube_matrix4d = UsdGeom.XformCache.GetLocalToWorldTransform(xform_cache, cube_prim)
    cylinder_matrix4d = UsdGeom.XformCache.GetLocalToWorldTransform(xform_cache, cylinder_prim)
    cube_prim_ModelAPI = UsdGeom.ModelAPI(cube_prim) 
    
    root_xformable = UsdGeom.Xform.Define(stage, '/World/Cylinder') 
    root_xformable.MakeMatrixXform().Set(cylinder_matrix4d)  

    constraint_target = cube_prim_ModelAPI.CreateConstraintTarget("Cylinder") 
    constraint_target.SetIdentifier('Cylinder')

    localConstraintSpace = cube_matrix4d.SetRotate(
            Gf.Rotation(Gf.Vec3d(0, 1, 0), 45)) 
    
    result_matrix = localConstraintSpace * cube_matrix4d

    stage.GetRootLayer().Save()

I’ve used unittest script for UsdGeomConstraintTarget as a template: https://github.com/sideeffects/USD/blob/29ffeac008c089b5b0c6a66cd668b3c709a07a2a/pxr/usd/usdGeom/testenv/testUsdGeomConstraintTarget.py

The ConstraintTarget I create here isn’t valid (constraint_target.IsValid() results in False):
constraint_target = cube_prim_ModelAPI.CreateConstraintTarget("Cylinder")
The “Cylinder” argument has got to be the problem.