Python Tag not updating (The Sequel)
-
Further to this post:
https://developers.maxon.net/forum/topic/12559/python-tag-not-updatingWhere to I pass the str variable in the code? I do not see the place for it. Thanks.
-
Hi @Swinn could you post your code?
-
import c4d import maxon 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 == 2398: # The ID of the User Data txt = "Swinn" 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) 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()) if __name__=='__main__': main()
-
Here in the latest S22 it's working as it should, and print Swinn to the console, on which version are you?
Moreover what I was referring to is the LogerInterface.Write require a maxon.String, by convenience, if the passed data is a str (python Type) it will create on the fly a maxon.String, but if you pass another kind of data type, this will not be converted to a string even if there is a possible string representation, so you need to transform your datatype to a str the usual way is by doing str(YourData) so in our example, it will give us
txt = c4d.Vector() pythonLogger = maxon.Loggers.Python() pythonLogger.Write(maxon.TARGETAUDIENCE.ALL, str(txt), maxon.MAXON_SOURCE_LOCATION(1), maxon.WRITEMETA.UI_SYNC_DRAW)
Cheers,
Maxime. -
I am on R20.
-
Sorry, I should have spotted it earlier, this issue is solved in R21.
So, unfortunately, I don't have any workaround for you.
Cheers,
Maxime -
Ah! Okay. Thanks.