AddTargets() in Sdf API?

   221   0   1
User Avatar
Member
103 posts
Joined: Nov. 2019
Offline
Given: A primitive lop that creates an over of a renderproduct prim. It generates it with the orderedVars relationship. Later down the stream in a different layer, in a python lop I set the targets of the orderedVars rel via AddTargets(). The usd looks something like this:

over "Render"
{
    over "Products"
    {
        over "data"
        {
            append rel orderedVars = [
                </Render/Products/Vars/rv0>,
                </Render/Products/Vars/rv1>,
            ]
        }
    }
}


How could I do this with the Sdf API with editableLayer()? I would go on to do something like:

productprim_spec = Sdf.CreatePrimInLayer(layer, Sdf.Path(product_path))
orderedVars_spec = Sdf.RelationshipSpec(productprim_spec, 'orderedVars')
orderedVars_spec.targetPathList.Append(Sdf.Path(var_path))

But the moment you use Sdf.RelationshipSpec the resulting usd will have this extra line: "custom rel orderedVars"

over "Render"
{
    over "Products"
    {
        over "data"
        {
            custom rel orderedVars
            append rel orderedVars = [
                </Render/Products/Vars/rv0>,
                </Render/Products/Vars/rv1>,
            ]
        }
    }
}

I don't know how AddTargets() is doing it, but I would like to know how to achieve the same thing with the Sdf. API.

Thanks in advance!
Edited by Cicuta - Aug. 27, 2025 06:00:39
  • Quick Links