Managing Custom Attributes for USD Import

Hi,

I’m using blender to process geometry for an upcoming project. I’d like to be able to store contextual data to drive some procedural effects in my geometry. My current idea is to use USD since the custom attributes are immediately attached to the importselectSOP.

It’s going mostly well. The only issue that I’m having is that the attribute name formatting has the string ‘primvars:’ appended to the attribute Id. So for example, an Attribute ‘Foo’ will be imported as ‘primvars:Foo’. The semicolon is kind of a paper cut when working in GLSL. I don’t know if it’s being added by blender on export or TD on import.

My current approach for getting rid of it is to use the callbacks on the USD importer to procedurally generate attributeSOPs to handle and convert these. Ie:

def onImport(comp, allOps, newOps):

    for c in allOps:
        if c.OPType == 'importselectSOP':

            # make list of primvar attribs
            primvars = []
            for p in c.pointAttribs:
                if p.name[:9] == 'primvars:':
                    primvars.append(p.name)

            # add an attributeSOP
            a = c.parent().create(attributeSOP)

            # populate attribute conversion pars
            for v in range(len(primvars)):
                a.par['pt'+str(v)+'from'] = primvars[v]
                a.par['pt'+str(v)+'to'] = primvars[v].split(':')[1]

            # connect the importselectSOP to the attributeSOP
            c.outputConnectors[0].connect(a)

            # update render and display flags
            c.render = c.display = False
            a.render = a.display = True

    return

This is generally just fine, but since I’m looking into USD I wanted to check in to see if anyone knew of a smarter way to handle this.

Thank you for any advice :slight_smile:

Hi!
I’m facing the same problem, but I can’t find how to export attributes from Blender to Touchdesigner pointAttribs. I filled the custom properties field at object and data tabs, but only N and v showed at pointAttr in TD, could you send me one small properly filled .blend or .usdc file , that work in TD?
Thanks!

Sure thing :slight_smile:

I was using geometry nodes to create named attributes like so:

When the .usd is exported from blender the custom attributes appear on the Import Select SOP at the bottom of the .usd network:

example files attached
blender_usd_td.zip (119.1 KB)

1 Like

Thanks for the reply!
I try to use this feature to store some string info in USD,
like given name of the object with utf8 enabled but no luck.
Thanks again!