[PD-dev] Help with class_setsavefn

IOhannes m zmölnig zmoelnig at iem.at
Thu Apr 27 17:38:49 CEST 2023


Am 27. April 2023 01:25:06 MESZ schrieb "Charles K. Neimog" <charlesneimog at outlook.com>:
>Hi,
>
>
> I have one problem with class_setsavefn, because I need something similar to #X declare -lib mylibrary (an extra line in a specific place in the PureData Patch file) to load the Python functions before pd tries to load the Python objects that are added by the Python module (called pd).

[...]
>
>
>Question:
>
>      Someone already had to add some extra lines in the pd patch in some specific order?
>
>      What is the right way to do it?
>
>
>One observation:
>      I am adding one new canvas_class method called py4pdLibrary, it loads the Python Library (the objects).


That sounds all wrong.
I'm not exactly sure what you are trying to achieve, but most likely fiddling with the internals of the patch representation and adding methods to the canvas is not a good idea (for starters it will create very weird errors if your library cannot be loaded).

Here's what I would do
- check whether the relevant Phyton code has been loaded before instantiating the new object ( in the object's constructor (the C-wrapper part thereof)
- create a loader with `sys_register_loader`


mfg.sfg.jfd
IOhannes




More information about the Pd-dev mailing list