Op.destroy operator in multiple containers

Hi there,

I’m trying to make a little patch to control DMX lights with TD.
In this patch I’ve made a container for each cue, called: cue0, cue1 etc.
Now I made a little system that lets you create a new fixture and automatically copy this to all the cue containers using a CHOP execute. The cue containers are automatically listed with an opfind DAT and a for loop runs to copy the new fixture to each individual cue container.

The script for this is the following:

def onOffToOn(channel, sampleIndex, val, prev):
	n = op(‘opfind1’)[1,0]
	name = parent().par.Name
	i = op(‘numCues’).col(0, val=True)
	numCues = op(‘numCues’).numRows - 1

	op(n).name = name
	op(n).par.Footprint = parent().par.Footprints

	for copy in i:
		w = op('../../'+ (copy)).copy(op(n))
		w.nodeY = w.nodeY - int((op('listFixtures').numRows - 1) * 150 - 150)

	return

that’s finally working! hoooray!

Now I want to make the same construction, but to be able to delete a specific fixture.
So I used an opfind DAT again to list all the fixtures, with a dropdown menu you can select the desired fixture and a button triggers a CHOP execute to delete the selected fixture from all cue containers. the problem now is that it only deletes the fixture from cue0 and not the other cue containers. With the system to create new fixtures I solved this by using a for loop. But now that doesn’t seem to work… Hopefully and very likely I’m making a silly mistake, but could really use some help trying to work this out!

The script for deleting a fixture is:

def onOffToOn(channel, sampleIndex, val, prev):
	n = op(‘null2’)[1,0]
	i = op(‘../numCues’).col(0, val=True)

	for delete in i:
		OP.destroy(op('../../../' + (delete) + '/' + (n)))

	return

Thanks!

Can’t tell for sure without running this but my guess is that you want:

op('../../../' + (delete) + '/' + (n)).destroy()

You have to call the destroy function of the operator you want to destroy.

Thank you for your reply!
I solved it. I reference to the existing fixtures from the container called cue0. these are listed and in a dropdown menu you can select which one to remove. But cue0 is also the first container it removes the fixture from, thus removing the selected reference. So there was no name to reference to, to delete the fixture in the other cue containers. I now swapped the order in which the script deletes the fixture beginning with the last cue and ending with cue0. This works. But I think I have to rethink how I want to reference to all existing fixtures a bit, because this might cause some trouble later on…

Cheers!