Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi, I have a null with some User Data on it and a Python tag attached to it. When I make changes in the User Data, the Python tag does not seem to see them. If I make a slight change to the Python tag, then it does. Is there a way to get the Python tag to react to User Data changes without modifying it? Thanks.
Hi @Swinn, thanks for reaching out us.
With regard to your issue, please have a look at this thread where it was discussed how to have a python tag reacting to a button userdata assigned to the tag's parent. In your case you might be more interested in parsing the events stream until you encounter a MSG_DESCRIPTION_POSTSETPARAMETER .
MSG_DESCRIPTION_POSTSETPARAMETER
import c4d def message(msg_type, data): if msg_type == c4d.MSG_NOTIFY_EVENT: event_data = data['event_data'] msg_id = event_data['msg_id'] if msg_id == c4d.MSG_DESCRIPTION_POSTSETPARAMETER: desc_id = event_data['msg_data']['descid'] if desc_id[1].id == 1: # The ID of the User Data print "A little bit more off" mtx = op.GetObject().GetMg() mtx.off = mtx.off + c4d.Vector(10,0,0) op.GetObject().SetMg(mtx) def main(): obj = op.GetObject() # Check if we already listen for message if not obj.FindEventNotification(doc, op, c4d.NOTIFY_EVENT_MESSAGE): obj.AddEventNotification(op, c4d.NOTIFY_EVENT_MESSAGE, 0, c4d.BaseContainer())
Rest to be told that, for some yet-to-understand reason, the Python console doesn't print the text A little bit more off on the user changing the userdata, but this is neglectable if you're interested in the real action that the Python tag executes.
Best, R
With regard to logging-lagging @m_adam has pointed me to this other thread. If you rewrite my code as
... if desc_id[1].id == 1: # The ID of the User Data txt = "A little bit more off" pythonLogger = maxon.Loggers.Python() pythonLogger.Write(maxon.TARGETAUDIENCE.ALL, txt, maxon.MAXON_SOURCE_LOCATION(1), maxon.WRITEMETA.UI_SYNC_DRAW) mtx = op.GetObject().GetMg() mtx.off = mtx.off + c4d.Vector(10,0,0) op.GetObject().SetMg(mtx)
you'll be fine to go
Cheers, R
Thanks! I will test this out.
@r_gigante said in Python Tag not updating:
if desc_id[1].id == 1: # The ID of the User Data txt = "A little bit more off" pythonLogger = maxon.Loggers.Python() pythonLogger.Write(maxon.TARGETAUDIENCE.ALL, txt, maxon.MAXON_SOURCE_LOCATION(1), maxon.WRITEMETA.UI_SYNC_DRAW) mtx = op.GetObject().GetMg() mtx.off = mtx.off + c4d.Vector(10,0,0) op.GetObject().SetMg(mtx)
I get an error message Traceback (most recent call last): File "Python UD Integration Test", line 11, in message NameError: global name 'maxon' is not defined
import maxon
Done. Fixed. Duh on my part. Thanks!
Now getting this error:
Traceback (most recent call last): File "Python UD Integration Test", line 13, in message File "/Applications/MAXON/Cinema 4D R20/resource/modules/python/libs/python27/maxon/interface.py", line 287, in MAXON_SOURCE_LOCATION return SourceLocation(loc[0], loc[1]) File "/Applications/MAXON/Cinema 4D R20/resource/modules/python/libs/python27/maxon/interface.py", line 274, in init Data.init(self, self._dt) File "/Applications/MAXON/Cinema 4D R20/resource/modules/python/libs/python27/maxon/data.py", line 104, in init self._data = Data_Create(self._dt._data, C) TypeError: failed to set member 'file', caused by (exceptions.TypeError: unable to convert maxon.datatype.DataType to @char)
make sure to pass a str value aka str(yourMessage)
if this doesn't solve the issue open a new topic
Cheers, Maxime