Re: [Maya-Python] Finding a Specific Node

2013-02-08 Thread Marcus Ottosson
Nice one. Never knew you would wildcard in ls, especially not with attribute 
names. I'll give this a go. Thanks!

On Thursday, 7 February 2013 20:45:59 UTC, Carlos Rico  wrote:
 You may add an attribute to the required nodes and list objects that have 
 this attribute only. Add yourCustomAttribute  to the required nodes and 
 list only objects that have that attribute. Could be a possible solution I 
 think. Cheers.
 
 
 
 ex:
 
 import maya.cmds as cmd
 specific_nodes = cmd.ls('*.yourCustomAttribute',objectsOnly=True)
 cmd.select(specific_nodes)
 
 
 
 2013/2/7 Marcus Ottosson konstr...@gmail.com
 
 
 import maya.cmds as cmd
 
 specific_nodes = cmd.ls(et='objectSet')
 
 
 
 That command would list all objectSets in the scene and it would do so very 
 quickly compared to the time it would take to do this in a scene with 
 hundreds of thousands of nodes: (psuedo-code)
 
 
 
 specific_nodes = []
 
 for node in cmd.ls():
 
     if isinstance(node, objectSet):
 
         specific_nodes.append(node)
 
 
 
 So, the question. Is there a way to tag or otherwise specify that certain 
 nodes are different that would allow such a quick search to take place? Other 
 than creating a new nodetype via the api.
 
 
 
 Best,
 
 Marcus
 
 
 
 --
 
 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 python_inside_maya+unsubscr...@googlegroups.com.
 
 To post to this group, send email to python_in...@googlegroups.com.
 
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 
 
 
 
 
 -- 
 Carlos Rico Adega
 Maya Generalist
 
 
 -
  LinkedIn
 
 
 carlos@gmail.com

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To post to this group, send email to python_inside_maya@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Maya-Python] multiprocessing opening up output window GUI

2013-02-08 Thread Justin Israel
I am not sure what platform you are running, but on OSX this is even more 
problematic. It creates orphaned processes that don't close and keep spinning 
the cpus.

The problem, as I understand it, is that the multiprocessing module needs to be 
able to fork, copy the memory, and start up the same interpreter again. But 
Maya is using an embedded python interpreter and it thinks it needs to start up 
Maya in the new processes, which crashes. On windows, the multiprocessing 
module has the .set_executable() function:
http://docs.python.org/2/library/multiprocessing.html#multiprocessing.set_executable
But I don't have windows to test trying to set this to a valid python 
interpreter, and it is not even platform independent as a solution. 

What I have gotten to work just fine is the workflow of running your script in 
a subprocess, and communicating the results back over the pipe. This allows 
multiprocessing to run under whatever standard python interpreter you want, and 
is independent of Maya.

There are two files here:
https://gist.github.com/justinfx/4741527

The first one is a modified version of your original code.
The second is the snippet to launch the subprocess from Maya and read the 
results.

-- justin



On Feb 8, 2013, at 6:04 AM, Jan: wrote:

 Hi,
 
 i'm trying to use the python multiprocessing module to make my script 
 multi-threaded.
 
 However every time it tries to start a new process it loads up the output 
 window with command line on how to load the maya batch process.
 When I close the window the process closes as well and the function is never 
 called or it locks up.
 Unfortunately I have no idea how I can pass command line info from the 
 multiprocessing function.
 
 So my question is: 
 How can I load a multiprocessing process without having the output window pop 
 up and the process running properly. 
 
 Any help would be much appreciated. 
 (I was thinking of running my code inside of a different interpreter but I 
 have no idea on how to go at it)
 
 
 Example function: (it works fine in any other standard python (2.6) 
 interpreter ).
 
 
 
 from multiprocessing import Pool
 from time import time
 
 ## Simple func to eat up cpu power.
 def whileFunc(z):
 while z  100:
 z += 1 
 return z
 
 ## We have to work in __main__ else in some os versions the threads become 
 unsafe
 if __name__ == __main__:
 ## Get current time 
 currtime = time()
 
 ## How often to run (just a test value)
 N = 1000
 ## Just a list with 1s 
 myList = [1]*N
 
 nrOfProcessors = 8 #16
 
 ## Set our pool of processors 
 po = Pool(nrOfProcessors)
 
 ## create the threads 
 res = po.map_async(whileFunc, myList)
 
 
 print 'This value below should be a 1000:'
 
 ## The res.get() getting of the result actually starts the threads 
 (surprisingly enough.) 
 ## This is also where maya will open up the Output Window and in some 
 cases lock up. 
 print len(res.get())
 
 print 'time elapsed:', time() - currtime
 
 -- 
 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 python_inside_maya+unsubscr...@googlegroups.com.
 To post to this group, send email to python_inside_maya@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To post to this group, send email to python_inside_maya@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.