@ferdinand Wow, thanks a ton for that! Our workflow was working just fine without c4dpy, so I didn't get to check the forum again, but this is very nice.
Happy new year!
@ferdinand Wow, thanks a ton for that! Our workflow was working just fine without c4dpy, so I didn't get to check the forum again, but this is very nice.
Happy new year!
@ferdinand Oh I was just making a parallel, how Cinema 4D supports more audio nicely by default (compared to Maya), so I can generally expect Cinema 4D supports a lot more media compared to Maya (which I had experience developing a plugin on before moving to C4D).
@ferdinand Thanks a lot on the feedbacks! Yeah I was thinking of using external library coz I was used to Maya, and the media support in that app was horrendous. I guess even Audio support-wise, Cinema 4D is miles better out-of-the-box. Hopefully c4d fits with our usecase.
Ahhh I see, good point on the Python & GUI limitations. Thinking back, it makes sense that high-performance GUI rarely rendered/looped for each frame. Our use case was more like generating some kind of animation based on a video. The video is there for just for side-by-side preview.
So all in all, we don't really need highly accurate playback. By using the time delta instead of raw timer and skipping frames here and there, overall I presume it'll be fine (say, even 10 FPS out of a 30 FPS video). But those are something I hadn't thought about, thanks a ton once again!
Hi, I was wondering if anyone ever tried embedding a video into the GUI via Python?
One method I was thinking of was to use OpenCV for the video backend, while getting the frames one-by-one and draw it into an UserArea.
@baca Nope, not working. It's worse now coz the error doesn't show up, but it's also not encrypted. So silent error.
@ferdinand I guess still no luck on this, and it's officially a bug? Would be interested too if you managed to find a temporary workaround.
@ferdinand Good to know it's not just myself. I tried restarting just now and the problem still persists. Looking forward for an update, thanks!
Hi, I just found out that you can use the c4dpy -g_encryptPypFile <file.pyp>
to encrypt a file without opening up the GUI. But every time I tried it, c4dpy just throws an error, even with the official plugin sample:
> c4dpy -g_encryptPypFile py-commanddata_dialog_r13.pyp
(null)Traceback (most recent call last):
(null) File "C:\Users\USER\AppData\Roaming\Maxon\Maxon Cinema 4D 2024_0CCAE811\plugins\py-commanddata_dialog_r13\py-commanddata_dialog_r13.pyp", line 101, in <module>
(null) c4d.plugins.RegisterCommandPlugin(id=PLUGIN_ID,
(null)OSError: cannot find pyp file - plugin registration failed
You can see that the it reads the file just fine, as they printed some lines from the script (for some reason).
Also, I completely confirms that the source protector in GUI works perfectly. And calling just c4dpy
works fine, spawning the c4d python interpreter. Tried using Admin, no luck.
@ferdinand Thanks a ton again! Yeah that dynamic UI is indeed something that fits perfectly with my current case, and possibly some other features I want to implement. Tho, I will revisit it later once I get to creating an MVP for my plugin. So I will use FreeChildren()
for now.
I want to use dropdown to select an object from a list of children from the targeted object. I managed to populate it just fine, but the issue is, how do you clear it so that I can repopulate the list when a different object is targeted later?
# Initialize dropdown for each parameter
for i, param in enumerate(self.params):
self.AddComboBox(ID_DROPDOWN + i)
# Once a target is selected
for i in range(len(self.params)):
for j, child in enumerate(self.children):
self.AddChild(ID_DROPDOWN + i, j+1, child)
My current idea is to remove the dropdown element entirely, but then I would have a hard time putting the dropdowns back in their respective layout positions like before.
@ferdinand Thanks a lot for the reply (and all of your example codes throughout the years)! Yeah I managed to make one using UserArea, I def think this is a crucial feature to be added in the sample code in GitHub (tbh a ton of your codes are just too useful to be left alone in forums). Especially since it's a multi-step process unlike PySide (used by Maya plugin), for example.
@Dunhou Thanks a lot! I checked a bit more after that and I also found out that you are indeed able to put custom image, using GeUserArea
:
https://developers.maxon.net/forum/topic/7155/8153_bitmap-in-userarea/22?_=1721638654806
Btw, checked out your plugins, and it made me realize I can do a lot more on the GUI side using C4D Python API.
Is it possible to add image to the dialog/window from python plugin/script?
The closest thing I find is Bitmap button, but you can only use pre-defined icons: https://developers.maxon.net/forum/topic/15365/gui-bitmap-button-properties/4
Turns out it's really simple, the documentation using ID
instead of DescID
creates unnecessary confusion. I thought they meant to insert c4d.CTsound
directly to CTrack
, but you need to follow the previous examples to use DescID
.
In any case, here you go:
def create_audio_track(self, path):
"""Add an audio track to the selected object"""
# Define a new audio track (following the documentation)
descId = c4d.DescID(c4d.DescLevel(c4d.CTsound, c4d.CTsound, 0))
track = c4d.CTrack(op, descId)
track[c4d.CID_SOUND_NAME] = path
op.InsertTrackSorted(track)
I managed to search a bit more, so turns out everything related to keyframe is defined as CTrack
. It's just a matter of determining the type/attribute.
I will try to adapt the solution from this topic (it was about keyframing visibility): https://developers.maxon.net/forum/topic/13686/python-script-to-keyframe-visibility-of-object/3?_=1721442329144
With the new information regarding CTsound
to refer to the sound special track: https://developers.maxon.net/docs/py/2024_0_0a/modules/c4d/C4DAtom/GeListNode/BaseList2D/CTrack/index.html?highlight=ctrack#c4d.CTrack
And maybe post the result once I figure it out.
Hi everyone, pretty new here. I got to read the documentation and honestly amazed at how well-documented everything is.
Tho, despite of that, I'm still unable to find a way to import sound/audio file. I guess it's due to the fact that in the GUI itself, adding sound is a multi-steps process, so I'm unable to directly find the relevant method.
If anyone got any tips, it'll be appreciated, thanks!