CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-07-2013, 06:08 AM   #1
ruffwmyafropuff
New Member
portfolio
Chris
Previsualization Artist
MPC Santa Monica
Glendale, USA
 
Join Date: Jan 2009
Posts: 20
Python loop question

Hey guys got a noob question.

Why won't my loop work?

Code:
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-07-2013, 07:00 AM   #2
kosingcg
Tatlong Dimension
 
kosingcg's Avatar
portfolio
Oliver Magno
Render TD
MPC - Montreal
Canada
 
Join Date: Feb 2013
Posts: 88
your loop should be like this:

Code:
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-07-2013, 07:01 AM   #3
Borgfriend
Veteran
portfolio
Neal Bürger
Ludwigs Maximilians Universität
Munich, Germany
 
Join Date: Jul 2004
Posts: 51
Don't really understand what you are doing...
Maybe this helps:

Code:
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-07-2013, 07:55 PM   #4
ruffwmyafropuff
New Member
portfolio
Chris
Previsualization Artist
MPC Santa Monica
Glendale, USA
 
Join Date: Jan 2009
Posts: 20
Thanks

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

Borg - thanks man i'll check that out!
 
Old 05-07-2013, 10:07 PM   #5
ruffwmyafropuff
New Member
portfolio
Chris
Previsualization Artist
MPC Santa Monica
Glendale, USA
 
Join Date: Jan 2009
Posts: 20
Stuck

deleted - see message below

Last edited by ruffwmyafropuff : 05-08-2013 at 01:26 AM.
 
Old 05-07-2013, 11:53 PM   #6
ruffwmyafropuff
New Member
portfolio
Chris
Previsualization Artist
MPC Santa Monica
Glendale, USA
 
Join Date: Jan 2009
Posts: 20
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*')

Code:
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:

Code:
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-08-2013 at 02:03 AM.
 
Old 05-07-2013, 11:53 PM   #7
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:21 PM.


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