Search code examples
puredata

Can I adjust the graph-on-parent dimensions of a pd subpatch by sending messages to it (dynamic patching)


I'm currently building an abstraction which creates its parts dynamically based on the argument to the abstraction. There is one main element and several of another type of element (as many as the argument dictates) that will be attached to that main element. All need to be visible in the host patch. I know that this in itself will work fine, but I need to be able to expand the graph-on-parent frame dynamically according to how many of the varying number of elements should be created.

I have looked here: https://puredata.info/docs/tutorials/TipsAndTricks#undocumented-pd-internal-messages but this is notoriously undocumented and I wonder which of these messages work and are appropriate...mycnv perhaps?


Solution

  • you are looking for the donecanvasdialog message to the subpatch

    donecanvasdialog  <xunit>  <yunits>  <gopmode>  <xfrom>  <yfrom>  <xto>  <yto>  <width>  <height>  <xoffset>  <yoffset> 1
    

    usually you'll leave most elements at their default values and only change width and height:

    donecanvasdialog  0  0  1  0  -1  1  1  $1 $2  100  100 1
    

    to find out these things yourself, you can always run Pd in debug mode to intercept the Pd <-> Pd-Gui communication and see how Pd does it internally (2 shows the GUI->Pd messages, and 1 hows the Pd->GUI messages):

    $ pd -nrt -d 2
    

    And of course, all this requires a disclaimer: these messages are internal messages. There are not promises that this message will work in the next bugfix release. (Unlike the object-creation messages which are engraved in the Pd-patch format, these messages only ever occur within a running Pd and are therefore indeed considered private and can change if need ever arises)