It took me a while to figure out which part caused the problem converting a scripting tag from py2 to py3...
The console printed the following errors (multiple times at a time):
TypeError: Expected PyCapsule, not None
The above exception was the direct cause of the following exception:
SystemError: PyEval_EvalFrameEx returned a result with an error set
The problem was the message function (I think..). Did a simple test with a pyTag containing only 1 userData button and the following script:
import c4d
def main(): pass
def message(id, data):
if id == c4d.MSG_DESCRIPTION_COMMAND:
id2 = data['id'][0].id
if id2 == c4d.ID_USERDATA:
userDataId = data['id'][1].id
if userDataId == 1: tst()
def tst(): print ("tst")
_Copying an object with the pyTag - no problem.
_Yes, the button just prints “tst” in python2 & 3 :}
_Dragging in python2 - no problem.
_Dragging the pyTag to another object (or a duplicate onto itself) in R23 - gives 2 errors
How can I solve this? I guess it's not the wisest idea in the world to put a SystemError in a try-except block...
Tia, Jochem
I saw the following code in the “python3_migration” in the SDK mentioning the "PyCapsule", but It doesn’t make much sense to me :{
PyCObject_AsVoidPtr is replaced by PyCapsule_GetPointer
_next code is only compatible in Python 2.7
P1MSG_UN = msg.GetVoid(c4d.BFM_CORE_PAR1)
pythonapi.PyCObject_AsVoidPtr.restype = c_int
pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]
P1MSG_EN = pythonapi.PyCObject_AsVoidPtr(P1MSG_UN)
_next code is only compatible in 3.7
P1MSG_UN = msg.GetVoid(c4d.BFM_CORE_PAR1)
P1MSG_EN = pythonapi.PyCapsule_GetPointer(P1MSG_UN, None)