I am editing this file where it has 2 files - one for UI and the other (lets call it the Function script, not sure what is the correct term is) is the functions that process the user selections etc.
Currently in this UI, there is this text field in which I am trying to pass its string values to the other script.
However, the only way I can think of is creating another file with this attribute called itemName and import into this Function script and called it but sometimes it seems to and seems not to work..
All in all, what it does is upon the user selection, when running this particular function, the object created should be parented under the object's/node's name which is reflected in this text field.
This is the main UI code
import meshPaintCon as meshPaintCon
class meshPaintWin (object):
...
self.uitxtField = mc.textFieldButtonGrp( label='Parent to Group', text='', buttonLabel='SELECT', bc=lambda * args:self.uiButtonCallback("uitxtField", args))
...
def uiButtonCallback(self, *args):
button = args[0]
if (button == 'uitxtField'):
import foo as foo
foo.itemName =
mc.ls(l=True, sl=True);
print(foo.itemName)
print(foo.itemName[0])
mc.textFieldButtonGrp(self.uitxtField, edit=True, text=str(foo.itemName[0]) )
...
This is the portion that executes the parenting.. (From the Function script)
class paintSur(object):
...
...
def fetchObject(self):
...
if(mc.nodeType(sourceDAG) != 'transform'):
tempDAG = mc.listRelatives(sourceDAG, parent=True)
sourceDAG = tempDAG[0]
print(sourceDAG)
newObjectDAG = None
if (self.uiValues.instance):
newObjectDAG = mc.instance(sourceDAG)
# string for self.tempgroup is : newItemCreation
import foo as foo
if (foo.itemName != ""):
newObjectDAG = mc.parent(newObjectDAG[0], foo.itemName, relative=True)
else:
newObjectDAG = mc.parent(newObjectDAG[0], self.tempgroup, relative=True)
return sourceDAG, newObjectDAG[0]
In case if you are curious about how i run my code:
import sys
sys.path.insert(0, '/Desktop/paintMesh')
import paintMeshTool
reload(paintMeshTool)
paintMeshTool.meshPaintWin()
Any help is greatly appreciated!