[PD-dev] need to find symbol of current patch (from code)

Mike Wozniewski mike at ozmediasolutions.com
Tue Sep 6 01:22:35 CEST 2005


Hi Tim,

Thanks for that info - it works now! ...though I had to make one
addition. I needed to use canvas_makebindsym() to allow sending messages
to the canvas symbol (see #3 in code below).

I have just one last clarification... I don't quite understand what you
meant when you said:

> but be aware that you are not allowed to include g_canvas.h, since it's
> a private header... so your binaries will only work with different
> versions of pd

It seems to work great for me (standard Pd version 0.38.4)... I suppose
this is because I compiled my external with the headers from my current
Pd version. Do you mean that the binary will not work if I give it to
someone with another version of Pd? Why would g_canvas.h change that
much?

----------

Anyway... I will recap for those who want to dynamically generate
objects on the same patch that your external resides on:

1) include g_canvas.h:

  #include "g_canvas.h"

2) In the struct for your object, hold a t_symbol for the canvas:

  typedef struct _externName
  {
    t_object x_obj;
    t_symbol *canvasSymbol;
    ...
  } t_externName}

3) In the constructor:

  canvasSymbol = canvas_makebindsym(canvas_getcurrent()->gl_name);

4) Then in any method, generate a new object on the canvas with:

  typedmess(x->canvasSymbol->s_thing, gensym("obj"), ... );



That's it.

-Mike


On Mon, 2005-05-09 at 22:00 +0000, Tim Blechmann wrote:
> >   t_canvas *z = canvas_getcurrent();
> 
> iirc, it's only allowed to call this in the constructor ...
> 
> a t_canvas is a _glist possibly you can access it with z->gl_name ...
> (have a look at g_canvas.h for implementation details)
> but be aware that you are not allowed to include g_canvas.h, since it's
> a private header... so your binaries will only work with different
> versions of pd
> 
> hth .... tim
> 





More information about the Pd-dev mailing list