1) No need to think about a regex solution. Somewhere in your code (I don't see
it in this example), you are storing a string representation of a list, inside
your other list. I have a feeling it might be your self.stripPath() method.
Could you show that?
Also, for adding one list to another, you can do it even faster by using
`extend`:
new_ikfk_note_list.extend(self.okfk_stored_notes)
2) stringToStringArray is a mel method. You shouldn't need that in python.
You are correct about needing getattr to resolve an attribute from a string:
item.leg_ctl = getattr(self, 'leg_ctrl')
But I don't see you actually storing them as attributes. They are being stored
in a list, right?
If you post more of the complete code on pastebin or elsewhere, and point out
the lines, I can take a better look.
-- justin
On Nov 28, 2012, at 2:07 PM, Berg Jones wrote:
>
> Hi. I have two quick questions ; )
>
> Question #1) I'm saving out the names of my IKFK controlls to a node so I can
> use them again on open/close and also set the appropriate titles of their
> buttons. I'm getting poor results when trying to save and append them to a
> list. For example, when I make two ctrls I get this. This means the title of
> the button is now this.....[u"[u'legCtrl1'] instead of this.... legCtrl1. I
> dont know if regex is the way to go with this or if there is a deeper problem
> with this method. "
>
>
> // Result: legCtrl1 //
> [u'legCtrl1']
>
> // Result: legCtrl2 //
> [u"[u'legCtrl1']", u'legCtrl2']
>
> self.leg_ctrl = self.stripPath(self.leg_ctrl) ###method to strip '|'
>
> self.ikfk_stored_notes = cmds.getAttr('ikFk_status.notes') #string attr
> if self.ikfk_stored_notes != None:
> self.ikfk_stored_notes = self.ikfk_stored_notes.split(',')
> #KEEP WHATS ALREADY THERE
> new_ikfk_note_list = []
> for i in self.ikfk_stored_notes:
> new_ikfk_note_list.append(i)
>
> else:
> new_ikfk_note_list = []
>
> #ADD THE NEWLY CREATED LEG IKFK
> new_ikfk_note_list.append(self.leg_ctrl)
>
> print '*******************'
> print new_ikfk_note_list
>
>
>
> Question #2) I'm building a qTableWidget with the ikfk nodes from the
> previous ikFk_status.notes stringToStringArray. I'm connecting a cellWidget
> to a button in another class. Ive successfully done this before but it wont
> work now with the error "has no attribute self.leg_ctrl" on the first line in
> defining TX/TY/TZ. My feeling is that i need to GET ATTR self.leg_ctrl in the
> new class but this doesnt make sense since I already defined it in the loop.
> self.leg_ctrl is defined as leg_ctrl#
>
> # line 43, in __init__
> # self.leg_ctrl_tx = '%s%s' %(self.leg_ctrl, '.tx')
> # AttributeError: 'rigTable_ikfk' object has no attribute 'leg_ctrl'
>
>
> self.ikfk_stored_notes = cmds.getAttr('ikFk_status.notes')
> if self.ikfk_stored_notes != None:
> self.ikfk_stored_notes = self.ikfk_stored_notes.split(',')
>
> self.rigTable.setRowCount(len(self.ikfk_stored_notes))
> self.rigTable.setVerticalHeaderLabels(self.ikfk_stored_notes)
>
> for idx, i in enumerate(self.ikfk_stored_notes):
> item = rigTable_ikfk()
>
> item.leg_ctrl = self.leg_ctrl ##### ?????
>
> self.rigTable.setCellWidget(idx,0,item.toggleFKIK_Button)
>
>
>
> class rigTable_ikfk(QtGui.QMainWindow):
> def __init__(self, parent=getMayaWindow()):
> super(rigTable_ikfk, self).__init__(parent,
> QtCore.Qt.WindowStaysOnTopHint)
>
> self.leg_ctrl_tx = '%s%s' %(self.leg_ctrl, '.tx')
> self.leg_ctrl_ty = '%s%s' %(self.leg_ctrl, '.ty')
> self.leg_ctrl_tz = '%s%s' %(self.leg_ctrl, '.tz')
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe