Python loop question

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 05 May 2013   #1
Python loop question

Hey guys got a noob question.

Why won't my loop work?

import maya.cmds as cmds

#grab all the geo in the scene
getGeometry = cmds.ls( type=['mesh','nurbsSurface'] )

getSamplerInfo = cmds.ls('samplerInfo*')
getSetRange = cmds.ls('setRange*')

for x in getSamplerInfo:
    samplerCameraNearClipPlane = cmds.getAttr(getSamplerInfo.cameraNearClipPlane, type = True)
    print samplerCameraNearClipPlane
 
Old 05 May 2013   #2
your loop should be like this:

for x in getSamplerInfo:
 	samplerCameraNearClipPlane = cmds.getAttr("%s.cameraNearClipPlane" % x, type = True)
 	print samplerCameraNearClipPlane
__________________
We are the captives of our own identities,
living in the prisons of our own creations.
 
Old 05 May 2013   #3
Don't really understand what you are doing...
Maybe this helps:

import maya.cmds as cmds

#grab all the geo in the scene
getGeometry = cmds.ls( type=['mesh','nurbsSurface'] )

getSamplerInfo = cmds.ls('samplerInfo*')
getSetRange = cmds.ls('setRange*')

if len(getSamplerInfo) is not 0:
    for x in getSamplerInfo:
        samplerCameraNearClipPlane = cmds.getAttr("%s.cameraNearClipPlane" % x, type = True)
        print samplerCameraNearClipPlane
else:
    print "No Samplerinfo found"
__________________
www.nealbuerger.com
 
Old 05 May 2013   #4
Thanks

Thanks guys! I didn't convert it to a string - good to know =)

Borg - thanks man i'll check that out!
 
Old 05 May 2013   #5
Stuck

deleted - see message below

Last edited by ruffwmyafropuff : 05 May 2013 at 01:26 AM.
 
Old 05 May 2013   #6
I got my main intent working but i'm having trouble making a loop that will go through each of the nodes

I've tried looping it several different ways but it's not working out. Here's something that looked promising but failed. It only goes through the first iteration.

import maya.cmds as cmds

#grab all the geo in the scene
getGeometry = cmds.ls( type=['mesh','nurbsSurface'] )

getSamplerInfo = cmds.ls('samplerInfo*')
getSetRange = cmds.ls('setRange*')

def kill_samplerInfoNEAR_setRangeMIN():
    if len(getSamplerInfo) is not 0:
        for x in getSamplerInfo:
            getSamplerString = '%s.cameraNearClipPlane' % x
            for y in getSetRange:
                getSetRangeString = '%s.oldMinX' % y
                cmds.disconnectAttr( getSamplerString, getSetRangeString)
                
def kill_samplerInfoFAR_setRangeMAX():
    if len(getSamplerInfo) is not 0:
        for x in getSamplerInfo:
            getSamplerString = '%s.cameraFarClipPlane' % x
            for y in getSetRange:
                getSetRangeString = '%s.oldMaxX' % y
                cmds.disconnectAttr( getSamplerString, getSetRangeString)
                                
kill_samplerInfoNEAR_setRangeMIN()
kill_samplerInfoFAR_setRangeMAX()



Here's my basic code that I want to loop:

import maya.cmds as cmds

#grab all the geo in the scene
getGeometry = cmds.ls( type=['mesh','nurbsSurface'] )

getSamplerInfo = cmds.ls('samplerInfo*')
getSetRange = cmds.ls('setRange*')

print getSamplerInfo
print getSetRange

getSamplerString = '%s.cameraNearClipPlane' % getSamplerInfo[0]
getSetRangeString = '%s.oldMinX' % getSetRange[0]

print getSamplerString
print getSetRangeString

#getSamplerInfoString = cmds.getAttr("%s.cameraFarClipPlane" % getSamplerInfo[0])
cmds.disconnectAttr( getSamplerString, getSetRangeString)

Last edited by ruffwmyafropuff : 05 May 2013 at 02:03 AM.
 
Old 05 May 2013   #7
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:51 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.