Making a custom PrimUpdater in python - editAsMaya is not triggered #4293
-
|
Hello, I have a custom I thought the right way to do this was to implement a new Here’s the basic implementation: import mayaUsd.lib as mayaUsdLib
from maya import cmds
class LodPrimUpdater(mayaUsdLib.PrimUpdater):
@classmethod
def sRegister(cls):
print(f'Registering {cls.__qualname__}')
mayaUsdLib.PrimUpdater.Register(
cls, "MyLodGroup", "lodGroup", LodPrimUpdater.Supports.All.value
)
@classmethod
def sUnregister(cls):
print(f'Un-registering {cls.__qualname__}')
mayaUsdLib.PrimUpdater.Unregister(
cls, "MyLodGroup", "lodGroup", LodPrimUpdater.Supports.All.value
)
def canEditAsMaya(self):
print('canEditAsMaya', self.__class__.__name__)
return True
def editAsMaya(self):
print('editAsMaya')
cmds.createNode("transform", name="myCustomNode")
return TrueHere’s a simple USD file you can use for testing: The interesting part is that after registering This means the class is registered and recognizes my custom prim. However, when I try to convert it, nothing happens, and Maya simply prints: It seems Maya never even calls my What am I missing? What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
|
You could try to use a prim reader instead of updater, The problem right now with your example is that Maya does not even know what to do with the LodGroup prim. Here is an example PrimReader that does read your prim (can currently creates a Maya sphere). The updater is still not called though, but I suppose you an do what you can in the reader? |
Beta Was this translation helpful? Give feedback.
-
|
Hi, and thanks for the reply. Yes, using that approach I can create a sphere (or whatever object I want), but that’s essentially all the
Without those steps, I don’t end up with a proper working setup that’s indistinguishable from the other prims supported by MayaUSD. Even if I tried to manually implement them, any changes in MayaUSD’s internal implementation could easily break my work. Also, even when using a I can see how It’s really not clear to me how all these components are supposed to work together. Honestly, it feels incomplete. |
Beta Was this translation helpful? Give feedback.
-
|
No doubt there is a mystery why the PrimUpdater is not being called. I was presenting this as a work-around to get the data into Maya. It did work for me when I edited-as-Maya the parent scope, so that could be a work-around. You would also need to also implement a PrimWriter to do the conversion back to USD. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I just stumbled on this discussion while researching the same topic... Following along the example above (and looking at the test suite), the PrimReader was erroring before completing until I parented the sphere directly: class LodGroupReader(mayaUsdLib.PrimReader):
def Read(self, context):
usdPrim = self._GetArgs().GetUsdPrim()
print(f'Read {usdPrim.GetName()}')
sphere = cmds.polySphere(r=7, name=usdPrim.GetName())[0]
parent = context.GetMayaNode(usdPrim.GetPath().GetParentPath(), True)
parentDagPath = OpenMaya.MFnDagNode(parent).fullPathName()
cmds.parent(sphere, parentDagPath)
# ...The reader seems to produce the expected result: set membership, hierarchy under I am still wrapping my head around this and have the same follow-up questions about the prim updater... |
Beta Was this translation helpful? Give feedback.


Hi, I just stumbled on this discussion while researching the same topic... Following along the example above (and looking at the test suite), the PrimReader was erroring before completing until I parented the sphere directly:
The reader seems to produce the expected …