External Relationships on Materials?

Still new to USD.

I was looking at Relationships but didn’t see anything in the documentation that stated you could/couldn’t have an external relationship?

I was setting up some material export and trying to do something like:

material_bind = UsdShade.MaterialBindingAPI.Apply(geom_prim)
material_bind.GetDirectBindingRel().SetTargets(["@myusdfile.usda@</test/myMaterial>"])

But it wasn’t working. Is this just not something you can do?

I’d like to have a bunch of separate usd files for my materials. Should I just add a normal reference instead of a relationship?

What I ended up doing was:

def "root"
{
  def Mesh "myMesh" (prepend apiSchemas = ["MaterialBindingAPI"])
  {
    rel material:binding = </root/MyMaterial>
  }

  def Material "MyMaterial" (prepend references = ["@myusdfile.usda@</test/myMaterial>"]) { }
}

Still seems a bit weird I can’t just do:

def "root"
{
  def Mesh "myMesh" (prepend apiSchemas = ["MaterialBindingAPI"])
  {
    rel material:binding = @myusdfile.usda@</test/myMaterial>
  }
}

That’s exactly right, @Andaharoo ! referencing causes “stage population”, and so must be specified on a prim in namespace - other prims are going to come into existence below it. It;s important that the Material actually bring its prims onto the Stage, so that you can see what it is and does, and so that you can override values on it.

A relationship does not provide an “anchor point” for stage-population - it’s just a “pointer” i nthe scenegraph, so the two concepts remain separated.

Cheers,
–spiff