Two simple questions:
- Is there an easy way to find out the id of the last object created in a patch?
- Can I stop subpatches from opening on creation? If so, how do you do that?
Object ID and Hiding Subpatches when using Broadcast Messages
Two simple questions:
I'm glad it helps!
Here's a tedious way of finding the ID number: open the pd file in a text editor and count the number of objects prior to the one you're looking for. Ie, if you see:
#X obj 30 369 phasor~;
#X obj 30 308 random 100;
#X obj 30 280 metro 30;
then metro is the third object. Remember to start from the very top of the list. If you have trouble finding the right object, then you could add a unique creation argument to it in the GUI, even if it temporarily breaks the object (ie, rename it [metro foo] and then search for "foo" in the text editor).
Another technique is to ensure that any new object you create is in a special subpatch. Inside the subpatch, ID numbering is restarted, so you can be sure that the first object you create is 1, etc.
Somewhat off-topic, but reading this post I've found that I can open a .pd patch with my browser (Firefox).
And, once it's there, I can right click onto it and select "View page source". A little window opens and, when I click onto any line (of the Pure data text), the status bar indicates line and column, for example: Line 6 Col 2.
It's an useful way of counting. But text editors have this counting functionality too. So I don't know how useful this is, but there it is.
I live and love in Argentina
Hey! All great ideas. Thanks folks.
Is there a broadcast message for removing an object from a patch?
Haha, don't think so. This is a serious limitation. The closest thing is the [clear( message, but that destroys everything. It's conceivable that you could direct it towards a specific subpatch and then rebuild the whole thing up until the object you want removed, but this would be tedious.
@ricky said
Is there a broadcast message for removing an object from a patch?
I'm non-dynamic. However, I'm pretty sure you can benefit from...
[cut(
Read the file 3.2.cut_paste.pd
Have a nice day!
I live and love in Argentina
Lovely! Thanks.
@ricky Here's a patch I made that will do this. Give it the name of your patch and it will give you the ID of each object, which you can use to connect/disconnect them:
@ricky And there is a technique you can use for deleting objects in a patch, but it's kind of hacky. You can use [find <object_identifier> 1, cut( if the object has something in its name that is guaranteed to be unique. This usually isn't the case, but you can design your dynamic patch with this in mind.
Here's an example where I do this:
Thanks, Chris. Nice approach.
...I see you're at Tufts (I know Paul) :o)
I've been bumming around in the iemguts library, and it looks like there are some really useful objects there for this kind of dynamic patching, including [canvasdelete]. I don't understand them well yet, but there are several other objects here which might be what you're looking for.
@ricky said:
- Is there an easy way to find out the id of the last object created in a patch?
You can use [iemguts/canvasindex] - its right outlet outputs total number of objects in the patch (so subtract 1 to get last object's index, because indices are zero-based).
_xb
@ricky Cool! Small world I guess. I'm working with him right now on using Pd for a Music Apps for the iPad course — it's really fun.
Oops! Looks like something went wrong!