If I am reading your examples correct, it would appear you are using your foo module as a kind of global scratch pad for storing and sharing data between unrelated function calls in your UI and your business logic modules. You might try making your business logic capable of storing everything it needs to do its work. Your UI should be creating an instance of it and managing it over time. That is, setting item name should be something you do on an instance of your business logic class. Not a global in a module.
Justin On Thu, Jul 7, 2016 at 1:10 PM yann19 <[email protected]> wrote: > 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! > > -- > 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/9a9f33b6-2b32-42c8-8a95-3feb94b23420%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/9a9f33b6-2b32-42c8-8a95-3feb94b23420%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/CAPGFgA27-hkzGf8dhjmF3g5RK8UDwnYVsiGeQZkGXs4xDvytxA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
