OK, clear, thx!
Posts made by jochemdk
-
Is it safe to change the timeline from the main function of a python tag?
Hi, I'm trying to code according to the treading manual..
But it's not clear to me if changing the timeline can be safely done from the main function of a python tag, or that that kind of functionality needs to be done from the "main tread".
Hope to hear from you, tia, Jochem
# some simplified script.. def set_timeline(): # at the moment this runs (without crashes) from the main function on a python tag.. startFrame = 0 endFrame = 123 # just some numbers.. doc = op.GetDocument() fps = doc.GetFps() minTime = c4d.BaseTime(startFrame,fps) doc.SetMinTime(minTime) doc.SetLoopMinTime(minTime) maxTime = c4d.BaseTime(endFrame, fps) doc.SetMaxTime(maxTime) doc.SetLoopMaxTime(maxTime) def message(msg_type, data): # simplified message function.. # .. if not c4d.threading.GeIsMainThread(): return # safer to call set_timeline() from here?..
-
RE: Axis lock/unlock in message function / UI update?
Yes, a question, where did the "mark as solved" button go
-
RE: Axis lock/unlock in message function / UI update?
Thx a lot @ferdinand !!!
Sorry, was a bit busy the last days, but I'll check asap. -
RE: Axis lock/unlock in message function / UI update?
Hi @i_mazlov
Thx for answering… I’ll try to be clearer - incl. screenshots next time :} & Yes, I was talking about the XYZ-axis mode buttons (and scaleTool).
Now I’m kind of confused, since I do try to stick to the threading rules. I can work around the axis modes, but my most important question is below:
One of the things mentioned on this forum by the devs was that the CallCommand should only be used from within the main thread.
That’s why I did put it in the message function, where I assume(d) it would be safe after:
“if c4d.threading.GeIsMainThread(): 'do some stuff..'”Isn't that kind of the same as from within a Python tag you can use CallCommands within a BUTTON function (where you can also use EventAdd()))?
-
Axis lock/unlock in message function / UI update?
Hi, I’m working with a Python Tag (not a plugin) attached to an object.
The goal is to only let the user scale the object if the document is in objectMode.So, I try setting the XYZ axis states accordingly within the message function.
This kind of works..
_ transformHandles are instantly updated
_ but the XYZ axis icons in the main UI ain't always updated..
_ hovering over the XYZ icons will update the state (which is far from ideal)So, how to update/redraw the generic C4D user interface?..
And is there a cleaner/better way to catch some messageType/Event to handle this?Tia, Jochem
import c4d doc: c4d.documents.BaseDocument op: c4d.BaseTag def message(msg_type, data): if msg_type == c4d.MSG_NOTIFY_EVENT: event_data = data['event_data'] ### ---------------------- the part reacting to UserData buttons ---------------------- ### if event_data['msg_id'] == c4d.MSG_DESCRIPTION_COMMAND: desc_id = event_data['msg_data']['id'] try: if desc_id[1].id == 18: print("some udButton press..") except (IndexError): pass ### ---------------- below: the part reacting to UserData changes ----------------- ### elif event_data['msg_id'] == c4d.MSG_DESCRIPTION_POSTSETPARAMETER and op.GetObject().GetUserDataContainer(): if not c4d.threading.GeIsMainThread(): return print("some udData change..") ### ------------------ which messageType/Event?.. now kind of hacky.. ----------------- ### if doc.GetAction() == 200000089 and c4d.threading.GeIsMainThread(): # scale/mainThread.. if doc.GetMode() == 1: # objMode.. for ax in [12153,12154,12155]: if c4d.IsCommandChecked(ax) == True: c4d.CallCommand(ax) #print("unLocked") elif doc.GetMode() != 1: for ax in [12153,12154,12155]: if c4d.IsCommandChecked(ax) == False: c4d.CallCommand(ax) #print("locked") # this kind of works.. # _ transformHandles are instantly updated # _ but the XYZ axis icons in the main UI ain't always updated.. # _ hovering over the XYZ icons will update the state # so, how to update/redraw the generic C4D user interface?.. # _ & is there a better solution for the above if-block.. def main(): # listen to buttonPresses on host if not op.GetObject().FindEventNotification(doc, op, c4d.NOTIFY_EVENT_MESSAGE) and op[c4d.EXPRESSION_ENABLE] == True: bc = c4d.BaseContainer() op.GetObject().AddEventNotification(op, c4d.NOTIFY_EVENT_MESSAGE, 0, bc) #...
-
RE: Character Defenition Tag - maxon.Id?
Thx Maxim, so I'll have to wait until the next version..
-
Character Defenition Tag - maxon.Id?
Hi,
Before release 2024, the Character Defenition Tag has always been a "Black Box" - at least for Python. I recently discovered that now there is/should be a way to get and set data. I tried to look in various .h-files, the C++ docs, Github etc. but I just can't find the corresponding maxon.InternedId to use.
# small non-working example.. import c4d, maxon def main() -> None: obj = op.GetObject() # from a pyTag.. csTag = None for tag in obj.GetTags(): if tag.GetType() == 1055068: csTag = tag # c4d.modules.character.MTCharacterDefinitionTag break print (csTag.GetExposedBodyPartSettings( > maxon.Id < ))
So, the base question is: what's the maxonId?
& the sub question: is there some python script to get the Ids?Thx in advance, Jochem
-
RE: Userdata not updating correctly on primitive splines & polygons in 2024..
Hi Ferdinand, thx for your answer - although I didn't expect this, considering I never ever had any trouble with the script..
But your point is clear. It means I've got to do some more investigation.. -
Userdata not updating correctly on primitive splines & polygons in 2024..
Hi, I’ve got a simple but strange case in 2024 (while it was working properly before..)
There’s a simple script to hide userData on a python tag.
Depending on the on/off state of the switchBoolean, 1 of the other 2 pieces of user data needs to be hidden.
This works fine on editable splines & polygons, but not on primitive versions - with the exact same tag..So, there must be something happening on the primitive splines and polygons, which I don’t understand..
The pyTags are set to “generators 499”, so that couldn’t be it.The issue is that on the primitives, when the switch says ON, the user date shown say OFF and visa versa..
And only after clicking the “wrong” boolean on the right, the other version will show up. So I need an extra click to get the right result.
(note: working on Mac right now, haven't tested it yet on PC..)Is there anything new to “updating/redrawing” the UI, or is this something to be fixed in a future update?
Kind regards, Jochem
-
What happened to AEC export / AE compositing file?
Hi, since I updated C4D to the latest version [2023.2.1] this morning a large script of mine stopped working.
Something happened to the way the AEC file is exported. My main concern is that some characters in my naming convention are replaced by underscores.For example a null exported as "AEC+,;M1" is now called "AEC___M1" when I read the aec as a simple text document.
This is just a simple example, but I've got lots of naming dependencies with an After Effects JSX script...
Can someone please check what happened, I would be very grateful, thx in advance, Jochem
-
RE: Slow MoGraph in 2023?!
Thx for updating.. 2023.1 seems to be working well again
-
RE: Slow MoGraph in 2023?!
Hi manuel,
Thx for answering. The first part of my previous reply was native C4D, so I'll send a simple file to regular support.
As stated in my initial question, I spent almost a day trying to isolate the issue which I thought was an issue within my script, which wasn't the case.
Seems I have to accept normal instances to be slow & adjust my scripts accordingly.. Thx, Jochem
Edit / fyi: Just got this back from support: "As I can reproduce your issue here, I reported it to our development."
-
RE: Slow MoGraph in 2023?!
Hi @iplai,
Thx for your answer. Changing the mode in 2023 to renderInstance gives me about 40 FPS & multiInstance about 54 FPS. This is still less on my machine, but better than the normal instance :}
For another script, I'm heavily relying on instances (not the other 2..). Is there anything I can change/adjust/script to make the normal instanceMode work decently? Or is that now something of the past?
Hope there's some info about it, thx, Jochem.
-
Slow MoGraph in 2023?!
Hi all,
Yesterday I was revisiting an old project of mine & spent almost the entire day figuring out why the hell it was so slow in R2023..
So this morning I made a simple setup, with just a basic cloner - with a plainEffector - who has a moWeight tag as a selection - and where the weightTag is driven by a randomField.. nothing special.
Running this simple thing in R26 vs 2023 gave an amazing speed reduction - see the image below (on the left)..
So, the issue was not my pyScript.. it has about 800 lines of checks & calculations so to me it's fine that it runs 6 FPS slower in R26 than the randomField example. (the image in the middle..)
Please note the FPS getting even slower when a pyTag is attached to the cloner in 2023. (image on the right)
Is there some temporary moGraph issue in 2023, or can this be something different?
Can't see any changes in the docs, Hope someone knows, tia, Jochem
-
RE: In-Exclusion in 2023 - no way to insert tags into an In-Exclusion list?
Done, didn't know I could do it myself :}
-
RE: In-Exclusion in 2023 - no way to insert tags into an In-Exclusion list?
Hi @manuel,
Thx for your reply. You might be surprised again... your code also works from the main func of a pyTag :} (But that's probably because of the buttons running in the mainThread..)
Consider it solved, Jochem
-
In-Exclusion in 2023 - no way to insert tags into an In-Exclusion list?
Hi,
I just installed 2023 and discovered parts of my scripts stopped functioning, because you can’t insert any tag into an In-Exclusion list anymore? :{
The In-ExclusionData is just a simple userData item on a pythonTag..
I included a simple script below, which works in previous versions of C4D - Just a pyTag (on a Null) with 3 pieces of user data (2 buttons and an inex List..)So, A - I’m hoping this is a temporary bug.
or B - There’s a new way to automatically insert (especially python)Tags in some sort of list. (couldn’t find any changes in de docs..)Please let me know, really need a solution.
tia, Jochemimport c4d # just a simple example.. def add(): inexList = op[c4d.ID_USERDATA,3] item = op # <<< can't insert "op" or other pyTags anymore?.. item = op.GetObject().GetTag(5698) # e.g. vibrationTag, seems I can't insert any tag.. item = op.GetObject() # this works.. inexList.InsertObject(item, 0) op[c4d.ID_USERDATA,3] = inexList def rem(): op[c4d.ID_USERDATA,3] = c4d.InExcludeData() 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: add() if userDataId == 2: rem() def main(): pass
-
RE: Ensuring only 1 specific pyTag in a document?
Hi @ferdinand, Learned a couple of new tricks, almost had a good solution, but in the end it still wasn't 100% safe.. So I decided to just disable the pyTags in such a way they never would be able to initialize again. Not the nicest solution, but anyhow.. Thx for your input - consider the topic closed.
-
RE: Ensuring only 1 specific pyTag in a document?
Thx @ferdinand for the input, I'll look at it as soon as I can!