Hey,
I think subject says it all.
Can one delete an object in a similar manner to creating an object using dynamic patching?
delete object using dynamic patching?
Hey,
I think subject says it all.
Can one delete an object in a similar manner to creating an object using dynamic patching?
@raynovich Yes, using the [find( and [findagain( messages and then [cut(
The right hand side of this......... dynamic-delete.pd ...... shows usage.
I made it for someone to add copies of the same object and then remove them, so it will probably not do what you want but you will get the idea.
Sending in an integer on the Left side creates an object...... sending in the same number deletes it...... if I remember correctly.
David.
Or you can send a "clear" message to clear a whole subpatch.
Thank you all. I am looking to try to delete just one object. I am working on an additive synthesis object that can create and delete object dynamically.
@raynovich So if your object is [osc~ 440] for example the message to the patch [find osc~ 0( will select it and [cut( will remove it....... cut.zip
If for some reason you need to exit editmode afterwards...... for the container patch...... then that can be done in the message as I have shown in the "all at once" message in the screenshot below....... but not in the zip above.
David.
What does the "0" stand for when finding the object? Is it possible to find different ones and delete them or ONLY the last one created?
William
PS I am so close to being able to implement this well!
@raynovich The zero has no meaning. [findagain( will find more objects. You still need the count to know what object you want to find.
@raynovich As @ingox says [findagain( and a counter.
The patch dynamic-delete.pd that I posted above is supposed to do that but I am not sure that it was implemented absolutely correctly.
Give me the name of your object and I will try to refine it.
David.
you can also use iemguts library for different approaches, so for example, an abstraction can "self-destruct" if you create [canvasdelete 1] and send it a bang. no need to find it, just add the logic to bang it when necessary (check canvasdelete helpfile for examples)
iemguts also adds a "delete" message that works with the id of the object in a patch, so if i created for example, an [osc~] and an [*~] in a new patch, i know that osc~ has id 0 and *~ has id 1, if i send the message [delete 0( to this patch it will delete only the osc~ (and afterwards the objects will reorder, so *~ will receive the id 0)
(and you can also send messages to the patch using [sendcanvas], which i think it is easier than using namecanvas and a send)
the documentation about the delete message also lives on the canvasdelete helpfile, btw
Is there a way to delete a floatatom? I tried find |floatatom 0(
@raynovich No. But you could have an abstraction [floatatom] which just contains an inlet a floatatom and an outlet. Set its GOP to be on so you can see the value onscreen.
Bizarre as it is.......... you can hide its name in its properties and [find floatatom 0( will still find it.
So GOP set on, hide the name, and make the GOP window as small as possible with it still showing the actual floatatom through the window....... so that it looks more or less like a real floatatom.
Of course you will have to put it into the patch with obj x y floatatom ...... instead of floatatom x y etc.
David.
Whoa!!!! OK, I do not "need" that number. I could try that though.
Though what is a "GOP?"
@raynovich Graph on Parent.....
It allows you to see part of what is inside an abstraction through a "window" when you place that abstraction in your patch.
I had right-clicked the object floatatom]...... the fake one I talked about above.
Then I opened [floatatom] and ticked graph on parent and dragged the real floatatom into the red box in the astraction (and saved the properties. Now the number box appears in a window.
Cords do not show through the window.
David.
Ok, so, I do not know if I did something wrong to make this happen, but I am getting an error when trying to find.
Here is the patch. I think it should work and has nothing special.
Here are some of the errors. Any ideas?
@raynovich Just for fun this is as far as I got.......... dynamic2.pd ..... but I was trying for a universal solution...... being able to put any combination of objects and delete exactly eg the 4th [osc~] that had been put. It is possible but a nightmare.
Anyway, I think your errors in the console just mean it cannot find the object...... Pd doesn't like a "cut" of a non-existent object.
Maybe you had already deleted it.
If I click your "put" [souncard2~] message at bottom left and then the bang at the top it deletes it without errors....... so it works (if that is what you intended) and I cannot reproduce the error.
But I don't have [soundcard2~] so......
What does [soundcard2~] actually do?
David.
@whale-av
Hey,
So, I replaced soundcard2~ with int to try it with a common object that is easy.
The errors still happen.
Maybe I need to restart my computer. I am using Pd-0.51-4.
@raynovich Oh!......... I see. It still works though......... but a lot of red in the console.
David.
Exactly!!! And that makes other problems. When doing this, it slows down the program and keeps things visible that should not be visible. And makes things stuck, visually at least.
And nearly freezes Pd.
Thoughts? Is this an error in the Pd?
@raynovich It has certainly changed. But whether it is a bug I don't know.
Fortunately none of my patches rely on deletion, but some really heavy ones that I use for work rely on dynamic creation. I hope that never gets broken.
Out of interest what are you trying to do?...... what happens when [soundcard2~] is created or deleted?
David.
@raynovich Just as a prove of concept, here is another way to do it, using mouse commands. The created objects are kept in a [text], so it is also possible to find specific objects and only delete them.
Hello,
Thanks for all of the dialogue.
So, I am considering using some additive synthesis. Think every soundcard is an osc with ramps for pitch, amplitude, panning, and anything else I might be interested in using.
So, I got this idea that my program will get unwieldy if I keep on adding more and more osc~ objects without deleting some.
Now, I could instead send "soundcards" to various soundcards, but that limits the number of osc~ I can use and make the program run slower?
Make sense? Thoughts?
I have never sent a notice of an error. How does that get "registered?"
Oops! Looks like something went wrong!