Hi @m_adam ,
of course, stupid me. I knew it was something simple I’m missing here. Seems I didn’t see the elephant in the room. :D
This works like a charm now. Thank you!
Allow one follow up question though. If I now want to translate this code to a TagData Plugin I’m pretty sure I don’t wanna use a global variable, do I? Would it be sufficient to make that variable a member variable inside of def __init__(self) of the Tag Plugin class?
@m_adam alrighty got it working.
Thanks again. You can close this thread if you like.
I have a problem with filling a dropdown cycle dynamically with options. Right now I’m doing this with userdata for the sake of simplicity. But in the end I want to use it in a Tag Plugin…
So, the setup is as follows. I have a cube (just to have a dummy host object to test the code with) that holds a python tag. The python tag holds the userdata dropdown cycle with the options I want to choose from. Inside the code I swap out the entries of the dropdown cycle based on the condition whether the fillet switch of the cube is active.
So the endgame here is to react to changes of the host object.
While this is all nice and dandy I encounter a problem I can’t seem to resolve. When ever I switch the fillet of the cube the dropdown cycle entries are changed accordingly BUT after the switch the dropdown cycle somehow seems to remember the last selected index and tries to set an entry with this remembered index as the "selected" one. This obviously fails if the entries being switched are of different length. So the entries are there but the dropdown cycle appears so to speak blank.
So question here is, how can I tell the dropdown cycle after the switch to select from the "new" indices. I’m probably missing something simple here.
#Welcome to the world of Python
options1 = [
options2 = [
cube = op.GetObject()
fillet = cube[c4d.PRIM_CUBE_DOFILLET]
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_LONG)
cycle = c4d.BaseContainer()
if not fillet:
for i, option in enumerate(options1):
for i, option in enumerate(options2):
op.SetUserDataContainer([c4d.ID_USERDATA, 1], bc)
I tried your code as well but still no luck…
However in R20 it is working as expected. So maybe after all it is R18 related?
I’m sorry, but nope that doesn’t change anything. I mean you’re right Python 2.7 is doing integer division by default but forcing a float division doesn’t do it for me here. As you can see in my screencast the UI is kind of blocked when I hit the button for „do something longer“. The progress bar only shows up if I comment self.StopProgress(). BUT it is then showing up completely full and not constantly updating like in Manuels example.
By now I slowly get the feeling that it is simply not working this way. To me it looks like the UI is blocking the update process. But then again I don’t understand why it is working in Manuels example. Since he is clearly executing the code on macOS as I do.
hmm… that’s weird. Tried that code as well but the progress bar is still not showing up.
I recorded a small screen capture for you to see what i meant by saying: “…I don’t even get a bar to see…“
Maybe this will make things clearer.
thanks for your the time and the example code. :-)
I’m aware that depending on the time the execution of my action takes, the process of updating the progress bar can take more or less time. Just to be sure I didn’t overlook some fundamental things, I gave your code a shot and well what can I say – it doesn’t work.
I try to explain more clearly whats happening. If I run it as is I don’t even get a bar to see. I have to comment the self.StopProgress() method to actually see a bar at all. (This is maybe what you were referring to by saying: „… don’t really have time to see the progess bar…“
I then increased the count in your example to 100.000 and all I’m getting is a sort of freezing Cinema and a beachball of death (macOS mouse cursor) while it is running. When it’s done the progress bar is updated up to 100% in one go. When really what I want is an real time updating progress bar that has a 1:1 relationship with my selected objects/materials, etc…
Is this maybe a macOS related problem (as the examples in my first post didn’t work as well and the guy in the video was clearly running Windows)? Or do I have to this kind of progress bar updating from another thread? And if so – how would I go about it?
BTW I dont’t want to mix up things here, but the same goes for c4d.StatusSetBar(). Setting the percentage in a loop doesn’t incrementally update the bar.
I’m fiddling around with the c4d.CUSTOMGUI_PROGRESSBAR and c4d.SetStatusBar in Python for quite a while now but can’t get it to work correctly. I’m trying to e.g rename a bunch of objects from a Dialog Plugin and set the progress bar accordingly.
When I use the code from the example of this thread the bar is update accordingly to the Timer BUT the moment I put in my code to act on the selected objects, the objects get renamed and the bar immediately gets updated to 100% AFTER the renaming action. So no incremental update… Why is that? Is there any way to simultaneously do the work on the objects and have to bar update properly?
I also found this code example where in a video is shown how its supposed to work. However when I use this I get the same behavior as described above. BTW it does make NO difference if I execute this code from the Script Manager or as a Plugin.
I hope I could explained the problem well enough to follow. If not just let me know.
Ah, before I forget I’m doing all this weirdness on macOS with R18.