PDA

View Full Version : Printing Nodes into a window


gunner89
11-22-2010, 11:16 AM
Hey, i am new to python programming and need some help. I have been asked to create a window which will contain a list of all the objects, cameras and lights in maya. I have done thos but the nodes print out in the script editor and not in the window that i have created. I need them to be in a clolumn view. I also need to specifiy next to its node name what type of object it is. Any help will be greatly appreciated. Thanks

p, li { white-space: pre-wrap; } import maya.cmds as cmds
window = cmds.window( title="Objects, Cameras and Lights")
cmds.columnLayout()
cmds.showWindow(window)
lights = cmds.ls(lt=True)
print lights, cmds.listRelatives(object, p=True)
cameras = cmds.ls(ca=True)
print cameras, cmds.listRelatives(Object, p=True)
objects = cmds.ls(o=True)
print objects, cmds.listRelatives(Object, p=True)

bowly
11-22-2010, 04:40 PM
You want to show window after finding your objects, you are displaying your window then looking for objects. To show your objects in the window try something like:


lights = cmds.ls( l = True )

then,

window = cmds.window ( title = "")
cmds.columnLayout( columnWidth = 2 )
cmds.text (l = 'lights:')
for light in lights:
cmds.text( l = light )
cmds.text(l = `cmds.objectType( light)` )

cmds.showWindow(window)

Pyrokinesis
11-27-2010, 08:43 AM
Here is a super simple example of using a textScrollList. (much better if you have lots of items)

import maya.cmds as mc
nodes = mc.ls()

window = mc.window(title='Scrollable List Of Selected Nodes')
nodePaneLayout = mc.paneLayout()
nodeScrollList = mc.textScrollList()

for node in nodes:
mc.textScrollList(nodeScrollList, edit=True, append=node)
mc.showWindow(window)

Again this is very simple, and doesn't address many of the problems you may encounter when writing ui's.

Good Luck.

CGTalk Moderation
11-27-2010, 08:43 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.