Re: [Maya-Python] [maya-pymel] variable error when casting python variable to mel

2010-08-05 Thread Jan:
Thank you ! that did the trick !


2010/8/5 damon shelton damondshel...@gmail.com

 mel.eval('filetest -d '+var1 + ';')

 you have to put  around your path in the eval statement



 On Wed, Aug 4, 2010 at 6:15 AM, Red jan@gmail.com wrote:

 Hello all,

 can anyone explain why this does not work ?

 def melVarTest():

var1 = C:/Program Files/Autodesk/Maya2011/bin/plug-ins/
result = mel.eval(string $var1Mel = `python var1`;)
print result

 melVarTest()

 # MelError: Error during execution of MEL script: line 1: name 'var1'
 is not defined

 The reason for doing this is because I want to use the mel filetest
 command and this seemed to me to be the best option.

 I have also tried:

 mel.eval(filetest -d +var1)

 But that instantly crashes maya. (fatal error)


 And when writing it the pymel way it gives me a syntax error that I
 can not figure out

 mel.filetest(var1, d=True)

 # MelError: Error during execution of MEL script: line 1: Invalid call
 to filetest.  Check number and types of arguments expected by the
 procedure.
 # Calling Procedure: filetest, in Command
 #   filetest(var1, d=True) #

 Would anyone be so kind to help me out :)

 Thanks,
 Red

 --
 http://groups.google.com/group/python_inside_maya


  --
 http://groups.google.com/group/python_inside_maya


-- 
http://groups.google.com/group/python_inside_maya

Re: [Maya-Python] [Maya-Pymel] parent to world comand results in error if object is already in world.

2010-08-25 Thread Jan:
Tank you for the explanation.

Yes I do agree to leave it like it is. But it striked me as odd.
A simple 'If parent is not none' check solved the problem.

Thank you again for the explanation. I'm starting to understand more and
more of the inner workings of pymel :)



2010/8/25 Paul Molodowitch elron...@gmail.com

 Well, first of all, comparing gui 'buttons' are not a direct / fair
 comparison to pymel commands, since they are almost always calling a mel
 script, which does some other stuff as well.

 For instance, in this case, it calls the 'Unparent' runtime command, which
 in turn calls scripts/others/performUnparent.mel

 A better comparison would be the maya.cmds.parent - which also throws an
 error in this situation:

 import maya.cmds

 cube = maya.cmds.polyCube()[0]

 maya.cmds.parent(cube, world = True)


 # Warning: Object, 'pCube1', skipped. It is already a child of the parent,
 'world'. #

 # Error: Maya command error

 # Traceback (most recent call last):

 # File maya console, line 3, in module

 # RuntimeError: Maya command error #


 However... having said that, I also tried the mel command (since it seemed
 odd that it would throw a warning AND an error), and that did NOT error - it
 only gave the warning.  So my guess is that there's an error in Autodesk's
 implementation of the python maya.cmds.parent cmd, which pymel relies on.


 Of course, it would be possible to make pymel behave like the mel command,
 and not throw an error in this situation.  However, I'm not sure it's clear
 in which manner it SHOULD behave in this case (ie, should it emulate the
 behavior of the python or mel command?)... so I'd lean towards leaving it
 the way it is, since that won't break anyone's existing code...


 - Paul



 On Wed, Aug 25, 2010 at 7:18 AM, Red jan@gmail.com wrote:

 Hello all,

 If I try to unparent an object but the object is already part of the
 world then the following command results in an error:

  parent(anyObject, world = True)
 # Error: Maya command error
 # Traceback (most recent call last):
 #   File maya console, line 1, in module
 #   File C:\Program Files\Autodesk\Maya2011\Python\lib\site-packages
 \pymel\internal\pmcmds.py, line 98, in wrappedCmd
 # res = new_cmd(*new_args, **new_kwargs)
 # RuntimeError: Maya command error #

 However if I do the same from within maya with the unparent 'buton'
 only get a warning message saying:

 # Warning: line 0: Object, 'myObject', skipped. It is already a child
 of the parent, 'world'. #

 Is this just a bug within pymel ?
 Or am I missing something here?

 Greets
 Red

 --
 http://groups.google.com/group/python_inside_maya


  --
 http://groups.google.com/group/python_inside_maya


-- 
http://groups.google.com/group/python_inside_maya

Re: [Maya-Python] Making_the_Script_Editor_spit_back_Python_code_instead_of_MEL

2011-10-21 Thread Jan:
For pymel you can use the tools provided with it.
Maya2012\Python\lib\site-packages\pymel\tools\scriptEditor

Put the pymelScrollFieldReporter into the plugins dir

Replace the original scriptEditorPanel.mel file inside:
Maya2012\scripts\startup
with the one from the pymel tools folder

you need to change a few lines though in the py file to make it work with
maya 2011 and 2012:
add:
from pymel.tools.mel2py import melparse

change :
mparser = mel2py.MelParser()
to:
mparser = melparse.MelParser()

As for maya python itself there should be a simmilar way but i have not
looked into it.
Note though that using the pymel script editor panel slows down your code
quite a lot especially when printing.
and some features are disabled in the script editor!!!


2011/10/21 Sahak Sahakian loves2anim...@gmail.com

 Hi guys.

 How wold one go about making ScriptEditor spit back its history in Python?

 cheers


 --
 view archives: http://groups.google.com/group/python_inside_maya
 change your subscription settings:
 http://groups.google.com/group/python_inside_maya/subscribe


-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Re: [Maya-Python] Re: Making_the_Script_Editor_spit_back_Python_code_instead_of_MEL

2011-10-21 Thread Jan:
oh sorry forgot to mention one thing.
in the script editor goto:
History - HistoryOutput - Convert mel to Python.

That should do the trick.


2011/10/21 Eric Nersesian eric.nerses...@my3dti.com

 Hi Jan,

 I followed your instructions but my script editor is still spitting
 out MEL. I made sure that pymelScrollFieldReporter.py is both loaded
 and auto loaded in Maya's Plug-in Manager but its still showing MEL.
 When I start up Maya these warnings are shown in the Output Window:

 WARNING: No t_error rule is defined
 WARNING: Token 'COMMENT_BLOCK' defined, but not used
 WARNING: Token 'COMMENT' defined, but not used
 WARNING: There are 2 unused tokens
 WARNING: no p_error() function is defined
 WARNING: Symbol 'element_list' is unreachable

 Also, let me walk you through what I did to see if I followed your
 instructions correctly:

 1. Copy Maya2012\Python\lib\site-packages\pymel\tools\scriptEditor
 \pymelScrollFieldReporter.py to Maya2012\bin\plug-ins

 2. Replace Maya2012\scripts\startup\scriptEditorPanel.mel with
 Maya2012\Python\lib\site-packages\pymel\tools\scriptEditor
 \scriptEditorPanel.mel

 3. Within Maya2012\bin\plug-ins\pymelScrollFieldReporter.py:
add: from pymel.tools.mel2py import melparse
   change: mparser = mel2py.MelParser() to mparser =
 melparse.MelParser()

 Thanks for any help you can provide,
 Eric

 On Oct 21, 8:00 am, Jan:  jan@gmail.com wrote:
  For pymel you can use the tools provided with it.
  Maya2012\Python\lib\site-packages\pymel\tools\scriptEditor
 
  Put the pymelScrollFieldReporter into the plugins dir
 
  Replace the original scriptEditorPanel.mel file inside:
  Maya2012\scripts\startup
  with the one from the pymel tools folder
 
  you need to change a few lines though in the py file to make it work with
  maya 2011 and 2012:
  add:
  from pymel.tools.mel2py import melparse
 
  change :
  mparser = mel2py.MelParser()
  to:
  mparser = melparse.MelParser()
 
  As for maya python itself there should be a simmilar way but i have not
  looked into it.
  Note though that using the pymel script editor panel slows down your code
  quite a lot especially when printing.
  and some features are disabled in the script editor!!!
 
  2011/10/21 Sahak Sahakian loves2anim...@gmail.com
 
 
 
 
 
 
 
   Hi guys.
 
   How wold one go about making ScriptEditor spit back its history in
 Python?
 
   cheers
 
   --
   view archives:http://groups.google.com/group/python_inside_maya
   change your subscription settings:
  http://groups.google.com/group/python_inside_maya/subscribe

 --
 view archives: http://groups.google.com/group/python_inside_maya
 change your subscription settings:
 http://groups.google.com/group/python_inside_maya/subscribe


-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Re: [Maya-Python] Re: Which editor do you use?

2011-10-25 Thread Jan:
Hi Yury,

I do not think there is mel syntax available for VS 2010 but here is an
explanation for pymel.
https://pytools.codeplex.com/discussions/276754

If it does not work give VS 2010 a restart. that should do the trick.

Hope that helps!
Jan

2011/10/25 ynedelin ynede...@gmail.com


 Hi Mike

 I am staring to use VS as well I am on VS 2010. Do you know of a way
 to get MEL syntax for VS?

 thanks

 Yury


 On Oct 21, 5:27 am, Mike Malinowski (LIONHEAD)
 mich...@microsoft.com wrote:
  As with Jan, I also use Visual Studio with the PTVS integration.
 Generally I find it much cleaner and organised than eclipse.
 
  From: python_inside_maya@googlegroups.com [mailto:
 python_inside_maya@googlegroups.com] On Behalf Of Jan:
  Sent: 21 October 2011 13:05
  To: python_inside_maya@googlegroups.com
  Subject: Re: [Maya-Python] Re: Which editor do you use?
 
  I just started to use visual studio with the python implementation that
 has been released recently.
  I must say its quite good. Just need to get the hang of using visual
 studio.
 
  Before that Eclipse/Pydev which worked really well.
 
  2011/10/6 PixelMuncher pixeldr...@gmail.commailto:pixeldr...@gmail.com
 
  I'll put in my 2 cents for Eclipse/Pydev.  Works great for me.
  I have the creative crash plugin working as far as communicating w/
  Maya, but I don't think autocomplete will work with straight Python
  (ie cmds.command...).
 
  --
  view archives:http://groups.google.com/group/python_inside_maya
  change your subscription settings:
 http://groups.google.com/group/python_inside_maya/subscribe
 
  --
  view archives:http://groups.google.com/group/python_inside_maya
  change your subscription settings:
 http://groups.google.com/group/python_inside_maya/subscribe

 --
 view archives: http://groups.google.com/group/python_inside_maya
 change your subscription settings:
 http://groups.google.com/group/python_inside_maya/subscribe


-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


[Maya-Python] getUV and getUVAtPoint returning wierd results.

2013-01-15 Thread Jan:
1)
I ran into a wierd problem in maya 2013. (maya2012 seems to be fine)

if you grab any polygon object and run:

for x in range(0, 10):
print  pm.selected()[0].getUVAtPoint(1)

I seem to get on average a
75% chance of getting [0.0, 0.0]
and 25% of the time the correct result.

I've tested this on several machines. Now I presume this is a bug somewhere
in pymel.

2)
Does anyone know of another way of getting the vertex Coordinates in a
reliable way?!

Thanks!
Jan

-- 
You received this message because you are subscribed to the Google Groups 
Python Programming for Autodesk Maya group.
To post to this group, send email to python_inside_maya@googlegroups.com.
To unsubscribe from this group, send email to 
python_inside_maya+unsubscr...@googlegroups.com.




Re: [Maya-Python] getUV and getUVAtPoint returning wierd results.

2013-01-15 Thread Jan:
Found a workaround.
Just kept it all in cmds:

vtxNumber = 1

sel = cmds.ls(sl = True)
## Get uvMap uv nrs
uvMap = cmds.polyListComponentConversion(sel[0]+'.vtx[%s]' %vtxNumber,
fromVertex = True, toUV = True)
## get uv coordinates (one of the uvMaps is enough.
uvCoords = cmds.polyEditUV(uvMap[1] , query = True)



2013/1/15 Jan: jan@gmail.com

 1)
 I ran into a wierd problem in maya 2013. (maya2012 seems to be fine)

 if you grab any polygon object and run:

 for x in range(0, 10):
 print  pm.selected()[0].getUVAtPoint(1)

 I seem to get on average a
 75% chance of getting [0.0, 0.0]
 and 25% of the time the correct result.

 I've tested this on several machines. Now I presume this is a bug
 somewhere in pymel.

 2)
 Does anyone know of another way of getting the vertex Coordinates in a
 reliable way?!

 Thanks!
 Jan


-- 
You received this message because you are subscribed to the Google Groups 
Python Programming for Autodesk Maya group.
To post to this group, send email to python_inside_maya@googlegroups.com.
To unsubscribe from this group, send email to 
python_inside_maya+unsubscr...@googlegroups.com.




Re: [Maya-Python] getUV and getUVAtPoint returning wierd results.

2013-01-15 Thread Jan:
make that
uvMap[0] instead of 1 (typo)

2013/1/15 Jan: jan@gmail.com

 Found a workaround.
 Just kept it all in cmds:

 vtxNumber = 1

 sel = cmds.ls(sl = True)
 ## Get uvMap uv nrs
 uvMap = cmds.polyListComponentConversion(sel[0]+'.vtx[%s]' %vtxNumber,
 fromVertex = True, toUV = True)
 ## get uv coordinates (one of the uvMaps is enough.
 uvCoords = cmds.polyEditUV(uvMap[1] , query = True)



 2013/1/15 Jan: jan@gmail.com

 1)
 I ran into a wierd problem in maya 2013. (maya2012 seems to be fine)

 if you grab any polygon object and run:

 for x in range(0, 10):
 print  pm.selected()[0].getUVAtPoint(1)

 I seem to get on average a
 75% chance of getting [0.0, 0.0]
 and 25% of the time the correct result.

 I've tested this on several machines. Now I presume this is a bug
 somewhere in pymel.

 2)
 Does anyone know of another way of getting the vertex Coordinates in a
 reliable way?!

 Thanks!
 Jan




-- 
You received this message because you are subscribed to the Google Groups 
Python Programming for Autodesk Maya group.
To post to this group, send email to python_inside_maya@googlegroups.com.
To unsubscribe from this group, send email to 
python_inside_maya+unsubscr...@googlegroups.com.




Re: [Maya-Python] Multi level undo in one go

2013-01-23 Thread Jan:
Hi,

What you can try is an open and close chunk of your undo queue.

## Opens a new undo chunk
cmds.undoInfo(openChunk = True)

## Closes the chunk again
cmds.undoInfo(closeChunk = True)


Keep in mind though that if you have an error in your script halfway you
might lose your entire undo stack.
Maybe make a button that closes the undo chunk. so you can always preserve
your undo stack.

if you really want to make your life easy make a decorator function out of
it.
That way you can use it for every function you want to wrap in one undo
call.

Hope that helps.

2013/1/23 blindtresddd blindtres...@gmail.com

 Blue pencil plug? Anyone?
 El 23/01/2013 15:08, DayDreamer day.dreamer.m...@gmail.com escribió:

  Hi, I am changing the values of attributes on multiple objects in the
 maya scene. Now, if I have to go to the previous state(before the setting
 of the attributes), it takes lots of Undo.

 Is thee is a way to undone all the changes at once.

 Also, if I run the setting of the attributes from a function or
 procedure, all the changes get undone at once.

 But, I am not able to attain the same functionality from my script.

 Thanks.


 --
 You received this message because you are subscribed to the Google Groups
 Python Programming for Autodesk Maya group.
 To post to this group, send email to python_inside_maya@googlegroups.com.
 To unsubscribe from this group, send email to
 python_inside_maya+unsubscr...@googlegroups.com.


  --
 You received this message because you are subscribed to the Google Groups
 Python Programming for Autodesk Maya group.
 To post to this group, send email to python_inside_maya@googlegroups.com.
 To unsubscribe from this group, send email to
 python_inside_maya+unsubscr...@googlegroups.com.




-- 
You received this message because you are subscribed to the Google Groups 
Python Programming for Autodesk Maya group.
To post to this group, send email to python_inside_maya@googlegroups.com.
To unsubscribe from this group, send email to 
python_inside_maya+unsubscr...@googlegroups.com.




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

2013-02-09 Thread Jan:
Hi Justin,

Thanks a million !
I will try this as soon as I have access to maya again.
Its a shame that the .set_executable() function is windows only. As that
would have been a great solution. However being able to use the standard
interpreter is a great alternative!.

I will get back to you asap with the test results.

Jan



2013/2/8 Justin Israel justinisr...@gmail.com

 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.




-- 
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] Closing PySide windows in Maya

2013-07-10 Thread Jan:
Hi Mike,

I ran into the same problem and the easiest way I came up with was just by
forcing the window to be destroyed every time the script ran.
Just like you would do in the old days with mel :)

if pm.window( 'testWindow', query = True, exists = True ) :
pm.deleteUI( 'testWindow' )

So add those lines to your script and that deletes the old window.

Jan


2013/7/10 Mike Malinowski (LIONHEAD) mich...@microsoft.com

  Hey All,

 ** **

 I’m getting an issue whereby my PySide windows are not being properly
 destroyed when they’re closed.

 ** **

 ** **

 code

 import pymel.core as pm

 ** **

 from PySide.QtCore import *

 from PySide.QtGui  import *

 import shiboken

 import maya.OpenMayaUI as mui

 ** **

 def getMayaWindow():

 ptr = mui.MQtUtil.mainWindow()

 return shiboken.wrapInstance(long(ptr), QWidget)

 ** **

 class testWindow( QMainWindow ) :

 

 def __init__ ( self, parent=getMayaWindow() ) : 

 QMainWindow.__init__( self, parent=parent )

 self.setObjectName(testWindow)

 self.layout = QHBoxLayout()

 self.label  = QLabel(test panel)

 self.layout.addWidget(self.label)

 self.setLayout(self.layout)

 

 window = testWindow()

 window.show()

 ** **

 /code

 ** **

 Run the code above a couple of times, and close the window each time. Now
 run this :

 ** **

 code

 from PySide.QtCore import *

 from PySide.QtGui import *

 import shiboken

 ** **

 import pymel.core  as pm

 import maya.OpenMayaUI as mui

 ** **

 def getMayaWindow():

 ptr = mui.MQtUtil.mainWindow()

 return shiboken.wrapInstance(long(ptr), QWidget)

 

 for child in getMayaWindow().children() :

 

 objName = child.objectName()

 if objName ==  : print -+str(child)

 else : print - + objName

 print len(getMayaWindow().children())

 /code

 ** **

 Notice that there are multiple instances of the window still there. The
 only way I can currently clean it up is to add this to the QMainWindow
 class :

 ** **

 code

 def closeEvent( self, event ) :

 QMainWindow.closeEvent( self, event )

 shiboken.delete(self)

 /code

 ** **

 However, some of my dynamic UI’s cause a crash with this override, and it
 feels a little heavy handed to have to override the closeEvent. Has anyone
 else hit this issue?

 ** **

 Mike

 --
 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.




Re: [Maya-Python] Closing PySide windows in Maya

2013-07-10 Thread Jan:
Oh you can also add a check for visibility so it doesn't destroy any
windows that are still in the users view.
i.e.
if pm.window( 'testWindow', query = True, exists = True ) :
print 'exists'
if not pm.window( 'testWindow', query = True, visible = True ) :
print 'not visible'
pm.deleteUI( 'testWindow' )



2013/7/10 Jan: jan@gmail.com

 Hi Mike,

 I ran into the same problem and the easiest way I came up with was just by
 forcing the window to be destroyed every time the script ran.
 Just like you would do in the old days with mel :)

 if pm.window( 'testWindow', query = True, exists = True ) :
 pm.deleteUI( 'testWindow' )

 So add those lines to your script and that deletes the old window.

 Jan


 2013/7/10 Mike Malinowski (LIONHEAD) mich...@microsoft.com

  Hey All,

 ** **

 I’m getting an issue whereby my PySide windows are not being properly
 destroyed when they’re closed.

 ** **

 ** **

 code

 import pymel.core as pm

 ** **

 from PySide.QtCore import *

 from PySide.QtGui  import *

 import shiboken

 import maya.OpenMayaUI as mui

 ** **

 def getMayaWindow():

 ptr = mui.MQtUtil.mainWindow()

 return shiboken.wrapInstance(long(ptr), QWidget)

 ** **

 class testWindow( QMainWindow ) :

 

 def __init__ ( self, parent=getMayaWindow() ) : 

 QMainWindow.__init__( self, parent=parent )

 self.setObjectName(testWindow)

 self.layout = QHBoxLayout()

 self.label  = QLabel(test panel)

 self.layout.addWidget(self.label)

 self.setLayout(self.layout)

 

 window = testWindow()

 window.show()

 ** **

 /code

 ** **

 Run the code above a couple of times, and close the window each time. Now
 run this :

 ** **

 code

 from PySide.QtCore import *

 from PySide.QtGui import *

 import shiboken

 ** **

 import pymel.core  as pm

 import maya.OpenMayaUI as mui

 ** **

 def getMayaWindow():

 ptr = mui.MQtUtil.mainWindow()

 return shiboken.wrapInstance(long(ptr), QWidget)

 

 for child in getMayaWindow().children() :

 

 objName = child.objectName()

 if objName ==  : print -+str(child)

 else : print - + objName

 print len(getMayaWindow().children())

 /code

 ** **

 Notice that there are multiple instances of the window still there. The
 only way I can currently clean it up is to add this to the QMainWindow
 class :

 ** **

 code

 def closeEvent( self, event ) :

 QMainWindow.closeEvent( self, event )

 shiboken.delete(self)

 /code

 ** **

 However, some of my dynamic UI’s cause a crash with this override, and it
 feels a little heavy handed to have to override the closeEvent. Has anyone
 else hit this issue?

 ** **

 Mike

 --
 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.




Re: [Maya-Python] MEL Autocompletion for Sublime and MayaSublime

2014-04-03 Thread Jan:
Ah yes good point. I'll modify the script to only take global procs.

Also ill add an argument to just do the commands that maya returns with its
help function. This should create a file that resembles the commands that
are listed in the documentation.

Cheers for the feedback!
Jan.
On 3 Apr 2014 21:00, Justin Israel justinisr...@gmail.com wrote:

 Hey Jan,

 Thanks for working on that. I would be inclined to add the completion file
 if it only contained the commands API. It appears there may be a lot of
 extra cruft in the way you have generated it so far. Are you grabbing all
 procs, regardless of whether they are global or not?

 -- justin



 On Fri, Apr 4, 2014 at 8:20 AM, Jan: jan@gmail.com wrote:

 note* by default this file should live here:

 C:\Users\userName\AppData\Roaming\Sublime Text 3\Packages\MayaSublime


 2014-04-03 20:12 GMT+01:00 Jan: jan@gmail.com:

 Hi All,

 Justin Israel made an awesome extension for the Sublime Text editor
 called MayaSublime.
 https://github.com/justinfx/MayaSublime

 But I noticed there is no auto completion file for the MEL syntax so I
 descided to generate one.

 This contains all MEL commands that I can find. Half of these are
 generated by the help of the maya help command:
 help -list *

 The rest is generated by parsing all the mel scripts in the maya
 instalation scripts folder.

 Hope this is of some help to people still having to manage legacy MEL
 scripts ^^.

 I also added the script that I wrote to generate this which might be
 usefull if you are working in a different version of Maya than this file is
 generated from. (Maya 2014)

 Feel free use edit and or modify these files in any way you see fit.

 Justin: In case you read this feel free to add and these files to the
 MayaSublime package.

 ( zipped the sublime completions as its a 5 meg json text file )


  --
 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 view this discussion on the web visit
 https://groups.google.com/d/msgid/python_inside_maya/CAC_0f0-1F%3DdR6dr2NS8vn%3DD2_-xHxJNgimsUa_azhg_ouW9OKA%40mail.gmail.comhttps://groups.google.com/d/msgid/python_inside_maya/CAC_0f0-1F%3DdR6dr2NS8vn%3DD2_-xHxJNgimsUa_azhg_ouW9OKA%40mail.gmail.com?utm_medium=emailutm_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 python_inside_maya+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3UCsmTcP6QEkd607VZzC%3Dy79x%3D2%2Batnvx_Hp%3D-RQW0Bw%40mail.gmail.comhttps://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3UCsmTcP6QEkd607VZzC%3Dy79x%3D2%2Batnvx_Hp%3D-RQW0Bw%40mail.gmail.com?utm_medium=emailutm_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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAC_0f08nH3t9jpq8Br6wBJj%2B1uG%2BsJv4sQB1_Y6KTtkO09r5vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] MEL Autocompletion for Sublime and MayaSublime

2014-04-04 Thread Jan:
*noticed that the attachments dont show up on the online archive so added
them to my website.
Description:
http://www.janpijpers.com/mel-autocompletion-for-sublime-and-mayasublime/
Files:
http://www.janpijpers.com/wp-content/uploads/2014/04/SublimeAutoComplete.zip



2014-04-04 12:52 GMT+01:00 Jan: jan@gmail.com:

 So I updated the script to only take global procs. (still a big file with
 a lot of commands tho)
 So this auto completion file contains global procs only which should be
 more accurate. I decided to still add all scripts global procs  as that
 way you would still get the commands like stringArrayRemoveDuplicates
 which are not listed in the standard maya documentation.

 At the moment sublime does not have a way (that I know of ) to add
 comments inside the text editor. However if you are curious where the
 commands come from, I added the scripts path as a comment in the json
 MEL.sublime-completions file.

 Also the script now has an additional argument (apiOnly : bool)  to only
 list the maya commands that can be found in the documentation.

 Justin: Unfortunately I do not have a way to test this on Maya 2015 yet.
 As soon as I do I will generate a file for that and compare it for
 consistency.




 2014-04-03 21:36 GMT+01:00 Fredrik Averpil fredrik.aver...@gmail.com:

 Awesome!

 This definitively should get merged with the repo!

 // F

 --
 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 view this discussion on the web visit
 https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWPG_%2B0wbfgXsSWFSKcoJWkkHxp8ZJXMHk4xwRpNM1cE0w%40mail.gmail.comhttps://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWPG_%2B0wbfgXsSWFSKcoJWkkHxp8ZJXMHk4xwRpNM1cE0w%40mail.gmail.com?utm_medium=emailutm_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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAC_0f0-UTOu9A7ES080Og4_kvJ%2Bx6VNf3N%2BsNaUKXO-d5dzRHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: GetPointAtUV problem

2014-08-03 Thread Jan
Hi,

although this is quite an old thread, I wanted to post a work around for 
the sake of completeness 
http://www.dict.cc/englisch-deutsch/for+the+sake+of+completeness.html:

import maya.OpenMaya as om
import maya.cmds as cmds

def GetDagPath(nodeName):
sel = om.MSelectionList()
om.MGlobal.getSelectionListByName(nodeName, sel)

dp = om.MDagPath()
sel.getDagPath(0,dp)
return dp


def UvCoordToWorld(U, V, mesh):
mfnMesh = om.MFnMesh(GetDagPath(mesh))
numFaces = mfnMesh.numPolygons()

WSpoint = om.MPoint(0.0,0.0,0.0)

util2 = om.MScriptUtil()   
util2.createFromList ((U, V),2)   
float2ParamUV = util2.asFloat2Ptr()

for i in range(numFaces):
try:
mfnMesh.getPointAtUV(i,WSpoint, float2ParamUV, om.MSpace.kWorld) 
break; #point is in poly
except:
continue #point not found!

return WSpoint

f = UvCoordToWorld (0.5, 0.5, 'pSphereShape1')
print [f[0], f[1], f[2]]

Cheers!


On Monday, 16 March 2009 19:35:30 UTC+1, LeonTheProfessional wrote:

 Hi all, 

 I am trying to use the getPointAtUV function from python, but get this 
 error: 

 Code: 

 # Error: (kFailure): Object does not exist 
 # Traceback (most recent call last): 
 #   File maya console, line 23, in module 
 #   File maya console, line 20, in UvCoordToWorld 
 # RuntimeError: (kFailure): Object does not exist # 

 The code is this: 

 Code: 

 import maya.OpenMaya as mayaSDK 
 import maya.cmds as maya 

 def GetDagPath(nodeName): 
 sel = mayaSDK.MSelectionList() 
 mayaSDK.MGlobal.getSelectionListByName(nodeName, sel) 
 dp = mayaSDK.MDagPath() 
 sel.getDagPath(0,dp) 
 return dp 

 def UvCoordToWorld(U, V, mesh): 
 mfnMesh = mayaSDK.MFnMesh(GetDagPath(mesh)) 
 numFaces = mfnMesh.numPolygons() 
 WSpoint = mayaSDK.MPoint(0.0,0.0) 

 util2 = mayaSDK.MScriptUtil() 
 util2.createFromList ((U, V),2) 
 float2ParamUV = util2.asFloat2Ptr() 

 mfnMesh.getPointAtUV(0, WSpoint, float2ParamUV, 
 mayaSDK.MSpace.kWorld) 

 return WSpoint 

 f = UvCoordToWorld (0.5, 0.5, 'lowreshead') 
 print [f[0], f[1]] 


 Anyone knows how to do this properly. Maya python is very annoying. 




 Thanks, 
 Light

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/e2df332a-0edc-4e24-ad4c-232dd0a91dba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Get point position using Uv map

2014-10-31 Thread Jan
The following script gets you the world position from a random uv-coordinate of 
the selected object.
I affraid I don't know what you mean with symmetry line.


import maya.OpenMaya as om
import maya.cmds as cmds
import random

def GetDagPath(nodeName):
sel = om.MSelectionList()
om.MGlobal.getSelectionListByName(nodeName, sel)

dp = om.MDagPath()

sel.getDagPath(0,dp)
return dp


def UvCoordToWorld(U, V, mesh):

mfnMesh = om.MFnMesh(GetDagPath(mesh))
numFaces = mfnMesh.numPolygons()

WSpoint = om.MPoint(0.0,0.0,0.0)

util2 = om.MScriptUtil()   
util2.createFromList ((U, V),2)   
float2ParamUV = util2.asFloat2Ptr()

for i in range(numFaces):
try:
mfnMesh.getPointAtUV(i,WSpoint, float2ParamUV, om.MSpace.kWorld) 
break; #point is in poly
except:
continue #point not found!

return WSpoint

f = UvCoordToWorld (random.random(), random.random(), 
cmds.ls(sl=True,type='shape'))
print [f[0], f[1], f[2]]

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/76460376-4fc1-4266-a3ed-420e2e0ab816%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Get point position using Uv map

2014-11-01 Thread Jan
I don't think there is an API function for that. You could write your own 
function to find the closest UV based on the mesh's UV list. 
However it might be a lot easier to just skip the results that are not within 
the coverage (ie. sorting out each result that is 0.0,0.0)

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/d59cd4aa-2e49-45b8-a0d4-44729b5ea369%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] MItMeshPolygon.reset() problem

2015-08-28 Thread Jan
Hi,

I'm working on a custom mesh exporter on the basis of this one: 
https://github.com/Volodymyrk/pbrtMayaPy/blob/master/PBRT/ExportModules/MeshOpt.py

However Maya crashes when I reset the MItMeshPolygon to cache out the same 
geometry on each frame. Somewhere in the back of my head I remember that 
there was a bug around resetting the Iterator.
Does anybody know how to work around that Iterator bug without switching to 
MFnMesh completely (which is very unhandy to retrieve UV and triangle lists)

Thanks!
J

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/9e6b0639-8d4c-4c01-8dcd-a79277038475%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] MNurbsIntersector

2009-09-01 Thread Jan Lachauer

Hello Everybody,

First: thank you for this very usefull mailinglist!!

Second: i want to work with the MNurbsIntersector class but I don't 
manage to get it right.

nurbIntersect = OpenMaya.MNurbsIntersector()

gives me the error:

# AttributeError: 'module' object has no attribute 'MNurbsIntersector' #

In C++ its just: MNurbsIntersector nurbIntersect;
(see: closestPointOnNurbsSurfaceCmd.cpp, and 
intersectOnNurbsSurfaceCmd.cpp)

Does anyone know how i can use it in the Python API?

Thank you.

All the best,
delaque


--~--~-~--~~~---~--~~
http://groups.google.com/group/python_inside_maya
-~--~~~~--~~--~--~---



Re: [Maya-Python] getting a node's typeID

2010-09-22 Thread Jan Berger


there is MFnDependencyNode::typeId()
to get it for a specific node type I guess one would need to use the 
create function beforehand



At 08:26 PM 9/22/2010, you wrote:
i've searched for this before without avail, but it's biting me 
again in a different context, so i thought i'd check:


is there a way to get the typeId of a node without having an 
existing instance of the node?


i would expect a static method on MFnDependencyNode, like the following:

MFnDependencyNode.getTypeId('transform')

but i can't find anything

-chad


--
http://groups.google.com/group/python_inside_maya


Jan Berger
j...@janberger.de :: www.janberger.de  


--
http://groups.google.com/group/python_inside_maya

Re: [Maya-Python] getting a node's typeID

2010-09-24 Thread Jan Berger


I`m not sure I have enough info to give specific advice, I presume 
the node may not exist that you want to get the typeId for?
If MDGModifier does not do the job how about just creating one and 
then use MGlobal::deleteNode() to get rid of it?

Just a thought...

At 09:56 PM 9/22/2010, you wrote:


On Sep 22, 2010, at 9:39 PM, Jan Berger wrote:



there is MFnDependencyNode::typeId()
to get it for a specific node type I guess one would need to use 
the create function beforehand


yes, it's not a static/class method so the MFnDependencyNode class 
needs to be instantiated to use that method... meaning you need an 
existing node.  i've done some very nasty things using dg modifiers 
to create ghosedt nodes that do not yet exist to find out their 
type, the revert the dgmod, but i'd rather not have to do that.


-chad






At 08:26 PM 9/22/2010, you wrote:
i've searched for this before without avail, but it's biting me 
again in a different context, so i thought i'd check:


is there a way to get the typeId of a node without having an 
existing instance of the node?


i would expect a static method on MFnDependencyNode, like the following:

MFnDependencyNode.getTypeId('transform')

but i can't find anything

-chad


--
http://groups.google.com/group/python_inside_maya


Jan Berger
mailto:j...@janberger.dej...@janberger.de :: www.janberger.de

--
http://groups.google.com/group/python_inside_mayahttp://groups.google.com/group/python_inside_maya


--
http://groups.google.com/group/python_inside_maya


Jan Berger
j...@janberger.de :: www.janberger.de  


--
http://groups.google.com/group/python_inside_maya

Re: [Maya-Python] Re: object matrix

2011-01-22 Thread Jan Berger


Have you tried using 
MScriptUtil.http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.html#891ecce0036c4ca210c39b27b1ead805asDouble3Ptr 
?



From the docs:
Utility class for working with pointers and references.

Utility class for working with pointers to basic types such as int, 
float and arrays of these types. Class is more applicable for script 
programming rather than C++. C++ pointers and references have no 
equivalent in script so this class provides utility methods for 
working with these type of parameters and return values.


References are treated as pointers in script. This class allows 
creating data and then acquiring a pointer to the data so that 
information can be passed to class methods requiring references.


Common scenarios:

   * A reference to an integer is required for a parameter: create 
the 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.htmlMScriptUtil 
object with the integer create() method, acquire a pointer using 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.html#d9ea6a06354c1e489730649a2d9bf1edasIntPtr(), 
pass that pointer to the method requiring the reference, create 
another 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.htmlMScriptUtil 
object using the int pointer that was returned, query the integer 
return value using 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.html#e42e1236dd42fccf9f98516deebcbe24asInt().
   * A pointer to a list of floats are required for a parameter: 
create the 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.htmlMScriptUtil 
object with createFromList(), call asFloatPointer() and pass that to 
the method.
   * Several static methods are available for converting python 
lists to matrices and integer/float arrays.


This class is cumbersome to use but it provides a way of building 
parameters and accessing return values for methods which would 
normally not be scriptable.




At 05:44 AM 1/22/2011, you wrote:

hi,
i would love to get the worldspace scales but can get the getScale
arguments right. What did you use?
I end up with

tMatrix.getScale(ptr, om.MSpace.kWorld)
# Error: line 1: in method 'MTransformationMatrix_getScale', argument
2 of type 'double [3]'
# Traceback (most recent call last):
#   File maya console, line 1, in module
# TypeError: in method 'MTransformationMatrix_getScale', argument 2 of
type 'double [3]' #

Best Regards,
katrin
--
NEU: FreePhone - kostenlos mobil telefonieren und 
surfen!

Jetzt informieren: http://www.gmx.net/de/go/freephone

--
http://groups.google.com/group/python_inside_maya


Jan Berger
j...@janberger.de :: www.janberger.de  


--
http://groups.google.com/group/python_inside_maya


Re: [Maya-Python] Re: object matrix

2011-01-22 Thread Jan Berger


If you have the worldMatrix the scale is in matrix[0][0] matrix[1][1] 
and matrix[2][2]



At 01:17 PM 1/22/2011, you wrote:

hi,
yes, i did as described here 
http://groups.google.com/group/python_inside_maya/browse_thread/thread/1b0eae1c73c93042/ebbf7af9b00a26e4?hl=deq=#ebbf7af9b00a26e4

but couls figure out th emissing argument...
I only need worldspace scale from marix, maybe there is an easyer 
way after all?

Thanks,
katrin


 Original-Nachricht 
 Datum: Sat, 22 Jan 2011 12:08:16 +0100
 Von: Jan Berger j...@janberger.de
 An: python_inside_maya@googlegroups.com
 Betreff: Re: [Maya-Python] Re: object matrix


 Have you tried using
 
MScriptUtil.http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.html#891ecce0036c4ca210c39b27b1ead805asDouble3Ptr

 ?


  From the docs:
 Utility class for working with pointers and references.

 Utility class for working with pointers to basic types such as int,
 float and arrays of these types. Class is more applicable for script
 programming rather than C++. C++ pointers and references have no
 equivalent in script so this class provides utility methods for
 working with these type of parameters and return values.

 References are treated as pointers in script. This class allows
 creating data and then acquiring a pointer to the data so that
 information can be passed to class methods requiring references.

 Common scenarios:

 * A reference to an integer is required for a parameter: create
 the
 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.htmlMScriptUtil

 object with the integer create() method, acquire a pointer using
 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.html#d9ea6a06354c1e489730649a2d9bf1edasIntPtr(),

 pass that pointer to the method requiring the reference, create
 another
 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.htmlMScriptUtil

 object using the int pointer that was returned, query the integer
 return value using
 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.html#e42e1236dd42fccf9f98516deebcbe24asInt().

 * A pointer to a list of floats are required for a parameter:
 create the
 
http://download.autodesk.com/us/maya/2010help/API/class_m_script_util.htmlMScriptUtil

 object with createFromList(), call asFloatPointer() and pass that to
 the method.
 * Several static methods are available for converting python
 lists to matrices and integer/float arrays.

 This class is cumbersome to use but it provides a way of building
 parameters and accessing return values for methods which would
 normally not be scriptable.



 At 05:44 AM 1/22/2011, you wrote:
 hi,
 i would love to get the worldspace scales but can get the getScale
 arguments right. What did you use?
 I end up with
 
 tMatrix.getScale(ptr, om.MSpace.kWorld)
 # Error: line 1: in method 'MTransformationMatrix_getScale', argument
 2 of type 'double [3]'
 # Traceback (most recent call last):
 #   File maya console, line 1, in module
 # TypeError: in method 'MTransformationMatrix_getScale', argument 2 of
 type 'double [3]' #
 
 Best Regards,
 katrin
 --
 NEU: FreePhone - kostenlos mobil telefonieren und
 surfen!
 Jetzt informieren: http://www.gmx.net/de/go/freephone
 
 --
 http://groups.google.com/group/python_inside_maya

 Jan Berger
 j...@janberger.de :: www.janberger.de

 --
 http://groups.google.com/group/python_inside_maya

--
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl

--
http://groups.google.com/group/python_inside_maya


Jan Berger
j...@janberger.de :: www.janberger.de  


--
http://groups.google.com/group/python_inside_maya


Re: [Maya-Python] Re: Adding up child rotations

2011-03-21 Thread Jan Berger


The example in the blog just spits out what has 
been put into the TransformationMatrix.
The question is whether when you add a rotation 
this will be kept track of as well, right?
If I were you I would take the code from the blog 
and add some rotation either with rotateBy
or addRotation and then see what it spits out. 
Sorry I can not give you direct answers and/or write code ...



At 10:34 AM 3/21/2011, you wrote:

My current mel script that I'd like to turn into a scripted plugin:
for ($obj in $hir){
 string $type = `nodeType $obj`;
 if (`gmatch joint $type`){
  float $jo[] ={};
  $jo[0] = `getAttr ($obj + .jointOrientX)`;
  $jo[1] = `getAttr ($obj + .jointOrientY)`;
  $jo[2] = `getAttr ($obj + .jointOrientZ)`;
  rotate -r -os  $jo[0] $jo[1]  $jo[2] c;
 }
 float $rot[] = `xform -q -os -ro $obj`;
 rotate -r -os $rot[0] $rot[1] $rot[2] $target;
}
By classic way do you mean using the MMatrix class?
Because 'AK Eric' says in the above mentioned description that the
MTransformationMatrix [class] will keep track of rotations past 360
degrees  rotation order of the node, while MMatrix objects will not.
It makes sense: A matrix itself stores orientations as vectors, which
have no concept how how far they’ve been ‘rotated’, so the MMatrix
object doesn’t track this data. But behind the scenes, the
MTransformationMatrix does track this info... 
http://www.akeric.com/blog/?p=1067

The whole point of the plugin I want to create is to add up how many
times the source nodes have spun and incrementaly add the rotations
together and output it on to one node. It sounds like
MTransformationMatrix::rotateBy would allow me to do this?
http://download.autodesk.com/us/maya/2010help/api/class_m_transformation_matrix.html#554b247da58575f45b45446e04bb1afa
Thanks!

On Mar 21, 6:25 pm, j...@janberger.de j...@janberger.de wrote:

 You can match transformations with different rotation orders,
 because internally the rotation order is irrelevant, it is only used
 when calculating the input and the output ( given it is rotation ).
 Internally the 4x4 matrix is just a bunch of vectors, that dont
 know anything about rotation orders and how many times they spun around.
 So I am not sure if the classic way will get you what you are looking for.




 t nojun...@gmail.com hat am 21. März 2011 um 03:04 geschrieben:



  OK! Due to further research, it seems that matching rotations of
  different rotation orders is a mathmatical imposibility;
 http://en.wikipedia.org/wiki/Rotation_(mathematics)
  So, the question now is;

  What would be the scripted plugin code to do 'relative' additive
  rotations on one transform from the rotation values of nodes in a
  hierarchy?

  I'd like to use this class that supports rotations past 360 degrees
  using MTransformationMatrix::rotateBy
 http://download.autodesk.com/us/maya/2010help/api/class_m_transformat...

  Thanks!

  --
 http://groups.google.com/group/python_inside_maya- Hide quoted text -

 - Show quoted text -

--
http://groups.google.com/group/python_inside_maya


Jan Berger
j...@janberger.de :: www.janberger.de  


--
http://groups.google.com/group/python_inside_maya


Re: [Maya-Python] Turning off orient joint in the move options?

2011-08-16 Thread Jan Berger



jointCtx

command maybe?


At 06:14 16.08.2011, you wrote:

Sent this already, but I never saw it come through...
I've been digging for a global var to turn off the orient joint move 
option (turned on by default in Maya 2012), but I have not managed 
to find one. I know this is not directly related to Python but I 
wanted to ping this to all the expertise in here. Anyone know how to 
set that option to off (through code)?


Thanks
/ Christian

--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Jan Berger
j...@janberger.de :: www.janberger.de  


--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Re: [Maya-Python] custom constraint

2011-08-20 Thread Jan Berger


Didnt they introduce a MPXConstraint class at some point for custom constraints
to get this behaviour?

At 21:29 20.08.2011, you wrote:

I`m working on custom constraint and wonder how Maya does the
connections to translate or rotate attribute, so they can be still
changed. I will explain it more. If you make Maya constraint, you can
still move constrained object around, even if there are connections.
Actually Maya keyframes work the same way, you couldn`t animate really
if once keyframe is connected object`s attribute values couldn`t
change.
So I wonder if this is internal way of plug evaluation or I need
specific type of attribute (constraintTranslate seems to be simple
double3 type). Does anyone know how this works? thanks.

--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Jan Berger
j...@janberger.de :: www.janberger.de  


--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Re: [Maya-Python] issues with mPlug

2011-08-23 Thread Jan Berger


hard to tell from the info provided what might be the cause, 
especially if it seems

to work in other maya versions. Are array attributes or arrays involved?
A wrong index can easily crap out maya, but if it works in other versions...


At 16:09 23.08.2011, you wrote:

Just out of curiosity has anyone encountered issues using MPLug

one of our programmers is having an issue with a script that works 
fine in maya on windows 2011, and 2012 and linux 2011, but not in 
linux maya 2012.


ontop of that he's not quite able to isolate the issue down to the 
function call.


 he made a test script out of the same code he's using, but it 
works fine ( go figure) .
 however in the much larger script the exact same code  totally 
crashes maya out.


 i still have my doubts, but I thought I'd throw it out there to 
see if anyone else has run into anything similar.


thanks

-=s


--
mailto:stephenkm...@gmail.comstephenkm...@gmail.com
http://smannimation.blogspot.com/
http://nymayausersgroup.blogspot.com/http://nymayausersgroup.blogspot.com/
http://smann3d.blogspot.com/

--
view archives: 
http://groups.google.com/group/python_inside_mayahttp://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribehttp://groups.google.com/group/python_inside_maya/subscribe


Jan Berger
j...@janberger.de :: www.janberger.de  


--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Re: [Maya-Python] Re: environment for API calls ?

2011-09-02 Thread Jan Berger


A short answer would be yes, you can do it and it gives a lt of 
possibilities,

but if you are talking abou a script in the context of a bunch of commands
being executed one after another, you should realize that with calling the API
you may run into undo/redo issues.

I have done it in production but only to do really opportunistic stuff,
like copying mesh data around without creating tweaks etc.
and where creating a scripted or not plug-in would have caused
too much overhead.

But I really like this combo of API and Python and can only 
encouraged to go down

the path of Dark Magic Power Moves as I call it ; )

At 18:56 02.09.2011, you wrote:

More precisely, if there is a boundary between python scripting and
API calls, how is it formalized ?

Thanks

Adam

On 2 sep, 18:52, wannAPI urbnc...@hotmail.com wrote:
 This is a very basic question:

 Is it possible to make API calls from the command line, or should they
 in general be considered apart from python scripts ? Aren't both of
 the same nature ?

 This might sound odd but that's one of the conceptual point I'm
 missing personally.

--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Jan Berger
j...@janberger.de :: www.janberger.de  


--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Re: [Maya-Python] Re: addAttributeChangedCallback within deformer?

2011-09-05 Thread Jan Berger


I second Chad Vernon`s comment and suggest using the 
setDependentsDirty method for this purpose.


At 03:20 04.09.2011, you wrote:

Try using myNode.thisMObject() instead of OpenMaya.MObject(), thus
removing the need to have a myMojbect at all
Also, the callback function needs to have and only have the arguments
found in MNodeMessage::MAttr2PlugFunction. If *args
isn't that, then it isn't going to work...
On Sep 3, 5:10 pm, johnvdz john.vanderz...@gmail.com wrote:
 thanks guys.

 this is basically what i have.

 class myNode(OpenMayaMPx.MPxDeformerNode ):
  myMobject=OpenMaya.MObject()
  def __init__(self):
  OpenMayaMPx.MPxDeformerNode.__init__( self )
  def postConstructor(self):

 attrChangedCBId=OpenMaya.MNodeMessage.addAttributeChangedCallback(
 myNode.myMobject, myNode.attrChangedCallback, self)
   def attrChangedCallback(*args):
  print 'this node callback is working'

 however i generally get a

 # RuntimeError: (kInvalidParameter): Unexpected Internal Failure //
 this is in the post constructor.

 not sure if i have implemented it wrong

 john

 On 09/04/2011 05:44 AM, Chad Vernon wrote:







  You can also use setDependentsDirty to check when things change.

  On Sat, Sep 3, 2011 at 12:33 PM, notanymike notanym...@gmail.com
  mailto:notanym...@gmail.com wrote:

  In c++ I usually install it in MPxNode's postConstructor method and
  remove it in it's ~MPxNode method

  However I don't know what the ~ equivalent to Python is...

  On Sep 3, 7:49 am, johnvdz john.vanderz...@gmail.com
  mailto:john.vanderz...@gmail.com wrote:
   hi all,

   i'm really scratching my head here. anyone know of an example
  out there
   for attributeCallbacks
  (MNodeMessage.addAttributeChangedCallback) within
   a deformer or mpxnode.

   not sure if i should be putting this in the __init__ func or in
  its own
   custom constructor.

   I'm not really sure about what its passing how to deal with what it
   passes so any examples would be great. Google search doesn't
  bring up
   much python stuff.

   i need to be able to pass some message to update for the node to
   recalculate an array of values.

   thanks in advance

   john

  --
  view archives:http://groups.google.com/group/python_inside_maya
  change your subscription settings:
 http://groups.google.com/group/python_inside_maya/subscribe

  --
  view archives:http://groups.google.com/group/python_inside_maya
  change your subscription settings:
 http://groups.google.com/group/python_inside_maya/subscribe

--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


Jan Berger
j...@janberger.de :: www.janberger.de  


--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


[Maya-Python] Is it possible to write a HwShaderNode in Python?

2011-10-09 Thread Jan Lachauer
Hello All,

for several days I'm now trying to implement a Hw Shader Node using
the Python API.

Starting with the most basic node possible, I took RobTheBloke's
BasicHwShader and removed everything leaving just the color attribute
( see his c++ example here:
http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/source/maya/BasicHwShader1.zip
)

The problem occurs in the glGeometry method.
The call
glFT.glDrawElements( prim, indexCount,
OpenMayaRender.MGL_UNSIGNED_INT, indexArray )
just crashes Maya.

You can view my python code here:
http://pastebin.com/DtLVVND6

Does anyone have a clue how this could work? Any help is greatly
appreciated, thank you!

All the best, jan

PS: the glGeometry method also takes a pointer-to-pointer argument for
the normalArrays, i was also wondering if it's possible to acces that
with the MScriptUtil in some way??? getFloat4ArrayItem and
getFloatArrayItem doesn't work...

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


[Maya-Python] Re: Book

2011-10-12 Thread Jan Lachauer
Very interesting, just ordered a copy!

On 12 Okt., 22:14, Ehsan Kiani ehsankiani.t...@gmail.com wrote:
 thanks !

 On Wed, Oct 12, 2011 at 11:42 PM, Ricardo Viana cgolhei...@gmail.comwrote:









  Thank you very much
  For this book just bought the kindle version. This time im really gonna
  learnt it.

  Cheers
  Ricardo Viana

  On Oct 12, 2011, at 8:05 PM, Farsheed Ashouri farsheed.asho...@gmail.com
  wrote:

  Very good.

  On Wednesday, October 12, 2011, Sahak Sahakian wrote:

  On Wednesday, October 12, 2011 6:43:08 PM, Adam Mechtley wrote:

  Hey folks,

  For those interested, Ryan and I finally wrapped up our book and (not
  that anyone is keeping me in the loop on release dates) it's available on
  Kindle now, hardcover later this week 
  http://www.amazon.com/Maya-Python-Games-Film-Reference/dp/0123785782/...
 http://www.amazon.com/Maya-**Python-Games-Film-Reference/**
  dp/0123785782/ref=sr_1_1?ie=**UTF8qid=1318437212sr=8-1. Many thanks
  to Seth Gibson and Kristine Middlemiss for contributing chapters, and to
  Dean Edmonds for technical editing assistance. If you're curious, you can
  also check out the companion web site at http://www.maya-python.com/
 http://www.maya-python.com/

  I mostly wanted to post here to ask that, if anyone on this list happens
  to pick up a copy, please do get in touch with me regarding any errors you
  find! It turns out writing a book is really hard, so I'm sure there were
  plenty of things that made it in under the radar in the final crunch ;) I
  just want to make sure we have an opportunity to fix as many issues as
  possible for the second printing. Thanks!

  --
  view archives: http://groups.google.com/group/python_inside_maya
 http://groups.google.com/**group/python_inside_maya
  change your subscription settings:
  http://groups.google.com/group/python_inside_maya/subscribe
 http://groups.google.com/**group/python_inside_maya/**subscribe

  Hi Adam.

  I am expecting it in mail soon and will let you know of typos/errors...

  cheers

  --
  view archives: http://groups.google.com/group/python_inside_maya
 http://groups.google.com/**group/python_inside_maya
  change your subscription settings:
  http://groups.google.com/group/python_inside_maya/subscribe
 http://groups.google.com/**group/python_inside_maya/**subscribe

  --
  Sincerely,
  Farsheed Ashouri,
  ourway.ir
  Tel: +98 9388801504

   --
  view archives: http://groups.google.com/group/python_inside_maya
 http://groups.google.com/group/python_inside_maya
  change your subscription settings:
  http://groups.google.com/group/python_inside_maya/subscribe
 http://groups.google.com/group/python_inside_maya/subscribe

   --
  view archives:http://groups.google.com/group/python_inside_maya
  change your subscription settings:
 http://groups.google.com/group/python_inside_maya/subscribe

 --
 
 Ehsan Kiani
 Character TDhttp://vimeo.com/user2219426
 Mobile: +98 918 936 9006
 [GMT: +3:30 hrs]
 Iran
 

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


[Maya-Python] Re: Interactive selection of objects

2011-10-18 Thread Jan Lachauer
Does this help: 
http://download.autodesk.com/us/maya/2010help/Commands/scriptCtx.html
?

On 17 Okt., 17:20, André Adam a_adam_li...@gmx.de wrote:
 Hi again,

 most Maya tools rely on input selections to be made prior to executing
 a command working on the selection. Now, instead of doing that I'm
 looking for an easy way to invoke an interactive pick session from a
 function. I find bits and pieces in the API documentation, all of them
 looking pretty much over the top for this rather simple task.

 Anyone having a hint on how to tackle that? Thanks in advance, cheers!

 -André

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe


[Maya-Python] Re: aniMeta - simple rigging tools

2022-01-11 Thread Jan Berger
Hi Marcus, saw you ragdoll stuff, pure awesomeness! Regarding your 
questions, HumanIK is IMHO only good for retargeting animation(mocap) data 
in Maya. It is integrated in aniMeta by creating a hik character along with 
the actual rig and than there is an extra group with a pairBlend on each 
relevant control so one can dial in or out the hik effect ( "mocap" 
attribute on each control ). This allows one to animate/tweak the mocap 
data, ie for foot locking. I have not implemented a baking step, yet, I 
guess that depends if it gets becomes a priority for some reason, so far I 
had exported the animation then directly to game engines, mostly UE.

Your question regarding a comparison to other solutions is very 
interesting, as it touches the design choices made. There are already a few 
options for auto-rigging out there, why bother putting out another one? 
First, the key idea behind aniMeta is simplicity with having novice users 
in mind. In my experience it can be already a challenge for users to 
install a script/plug-in. My idea was to have everything needed in a 
compact format with no dependencies/build/platform/installation issues, 
that is way I made the choice that aniMeta needs to be a single text file 
that can be started from the plug-in manager.  Second, regarding features, 
the biped template would probably be considered basic when compared to 
other options out there, especially mGear. but that also makes it fast and 
has only what I consider the most important features to get some decent 
game animation loops. It is also vanilla Maya, so a rig created with 
aniMeta can be opened on another machine that does not have the plug-in 
installed. That is also a difference to mGear, which uses custom nodes. So 
IMHO mGear is definitely the choice if you need to customize stuff and want 
advanced features, aniMeta is more of a light-weight but fast solution, but 
offers some neat features that maya make it interesting for character TDs. 
For example. there is a tool to export/import hierarchies(json), there is 
skinning IO(json) and a procedural build system, which I used last year to 
build a couple of mGear characters with. So it complements Maya where I see 
some Maya`s rigging features lack and aniMeta can easily combined with 
other rigging tools and solutions out there. Some students told me that the 
smooth weights tool alone already makes it  worth having around.

I know there isn`t any info about usage of aniMeta yet. But I am in the 
process of putting info stuff together so people can get a more specific 
idea of what it is and how to use it.  But so far thanks for your interest! 
: )

Marcus Ottosson schrieb am Dienstag, 11. Januar 2022 um 16:24:07 UTC+1:

> Very exciting. :) I'm familiar with your work on Character Modular System, 
> years ago from Suntoucher Labs. That stuff was next-gen. Keen to dive into 
> this.
>
> One question comes to mind from your feature summary above, what are your 
> thoughts on HumanIK? Is it intended for use by animators, or is it an 
> integration kind of thing? Like for motion capture, Motion Builder or 
> Unreal/Unity?
>
> Also what are your thoughts on other auto riggers out there, in terms of 
> comparison. When should (or shouldn't) one choose to look at aniMeta over 
> anything else? Of particular interest to me personally is a comparison with 
> mGear.
>
> On Tuesday, 11 January 2022 at 15:17:25 UTC loopy@gmail.com wrote:
>
>>
>> Howdy, I created this auto-riggerfor my students that has features that I 
>> find vanilla maya lacks and published it on github as open-source. It is 
>> easy to install, it is just one py file that can be started via the plug-in 
>> manager. I thought it may be interesting to some of you, so here you go:
>> https://github.com/janberger/aniMeta
>>
>> Here are some features:
>> - Biped template ( Unity and Unreal compatible )
>> - HumanIK inegration
>> - Skinning IO
>> - Very nice Smooth Weights Tool ; )
>> - Picker UI
>> - Rig, Pose, Animation IO
>> - Transform tools ( mirroring, matching et al )
>>
>> Overall the rigging features may seem limited for the Biped, because they 
>> are ; ) but keep in mind it is for students, especially game design 
>> students. For more advanced stuff. there is a procedural build system for a 
>> data-cantric workflow integrated, but I guess I need to write some 
>> documentation before anybody but me can use it.  
>>
>> Please let me know if you have any questions! 
>> Jan Berger
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/51610d0e-f0f8-485f-bad2-dd1d51d949afn%40googlegroups.com.


[Maya-Python] aniMeta - simple rigging tools

2022-01-11 Thread Jan Berger

Howdy, I created this auto-riggerfor my students that has features that I 
find vanilla maya lacks and published it on github as open-source. It is 
easy to install, it is just one py file that can be started via the plug-in 
manager. I thought it may be interesting to some of you, so here you go:
https://github.com/janberger/aniMeta

Here are some features:
- Biped template ( Unity and Unreal compatible )
- HumanIK inegration
- Skinning IO
- Very nice Smooth Weights Tool ; )
- Picker UI
- Rig, Pose, Animation IO
- Transform tools ( mirroring, matching et al )

Overall the rigging features may seem limited for the Biped, because they 
are ; ) but keep in mind it is for students, especially game design 
students. For more advanced stuff. there is a procedural build system for a 
data-cantric workflow integrated, but I guess I need to write some 
documentation before anybody but me can use it.  

Please let me know if you have any questions! 
Jan Berger

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/be5f17f9-1806-48a5-96dc-7569e7a41859n%40googlegroups.com.