>From the looks of this code, it a pretty flimsy way to manage the list of
buttons, by trying to iterate from 0-(nLights-1), and deleting a bunch of
controls in each window with dynamically generated names. What happens if
you previously had 10 lights and now you have 8? Does it leave behind a
window/controls?
How do you create your window? Are you sure you want to create a
dynamically named window, as opposed to having a static name that you can
always look for, and update the light count? If you pick something unique,
you should be able to keep dealing with it ("fooTools_lightManager_window").
Another suggestion is to delete a single layout in the window, instead of a
bunch of named controls. Why can't the controls all be named statically, as
opposed to a number based on the last light count? If you are trying to
update a window (windows?) with the new current list of lights, why not
just have one window, with a set of controls that can change? If you delete
a layout with an expected name, it will clear the controls in it, and you
can just create a new layout with new controls under the parent you want.
You are referring to relative control names. This means you may have naming
conflicts when you try to operate on them. Your window elements actually
look more like this:
textName8
textName8|someLayout
textName8|someLayout|textName8
textName8|someLayout|btnName8
textName8|someLayout|btnNameS8
If you make sure to deal with full names, it would be safer.
Also, is it a typo that in your updateList(), you save the solo button to
self.button, replacing the previous button reference?
If you can't get the bug resolved, you may need to provide a small,
complete example that shows the problem, so that we can give it a test and
pin-point the actual location of the bug. But the best I can say right now
is that you have an issue in managing your dynamically named controls,
using relative control names.
Justin
On Sun, Sep 6, 2015 at 4:26 AM Maria Jesus Penella <[email protected]>
wrote:
>
> I'm trying to update a list of lights on the scene. For this I keep the
> last list and delete all the elements, and create new ones based on the new
> list... It deletes all the elements just fine, but when I try to update
> with the new ones.. it just crashes and says:
>
> RuntimeError: Object's name 'textName1' is not unique. #
>
> It's suposed to be deleted, isn't it??
>
> this is the code of this part..
>
>
> def updateList(self, name, totalLgt, *args):
> print "update %s" % name
> #create new buttons
>
> self.text = pm.text('textName'+str(totalLgt), label="Name: %s" %name)
> self.button = pm.button('btnName'+str(totalLgt), label="ON" ,command =
> lambda *args: self.turnOn(totalLgt, name))
> self.button = pm.button('btnNameS'+str(totalLgt), label="SOLO", command =
> lambda *args: self.turnSolo(totalLgt, name))
> def update(self, totalLgt,lis, *args):
> totalLgt = 0
> for lgt in lis:
> totalLgt += 1
>
> i = 1
> print "updatea"
> print lis
> for i in range(totalLgt):
> if (pm.window('textName'+str(i+1), exists=True)):
> pm.deleteUI('textName'+str(i+1), control = True)
> pm.deleteUI('btnName'+str(i+1), control = True )
> pm.deleteUI('btnNameS'+str(i+1), control = True )
>
> lisN = pm.ls(type='light')
> totalLgt = 0
> #list all lights in scene
> for lgt in lisN:
> totalLgt += 1
> nameLgt = lgt.longName()
> name = nameLgt.split("|")[1]
> self.updateList(name, totalLgt)
>
>
> How should I do it so pressing update button I can get the new lights of
> the scene??
>
> Thanks 1
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/a6036cfe-30e3-4b2a-9b5f-1bbd35bb6450%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/a6036cfe-30e3-4b2a-9b5f-1bbd35bb6450%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1BN%3DtPWh3cDz-c%3DQv6vHhSnCmLcNoaU%3D2qe1VN%3DqsvyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.