Re: [Maya-Python] MayaPy Cython Import Error

2020-02-03 Thread Robert White
You don't need to copy the files to a new include folder, instead you want 
to just make sure the folder is on the `INCLUDE` environment variable.
So much like you did for LIB, you'd do `set 
INCLUDE=%INCLUD%;path_to_maya\include\python2.7`


On Monday, February 3, 2020 at 3:47:17 AM UTC-6, Paul Winex wrote:
>
> Oh, i forgot one thing.
> You need to copy source files form *MayaXXX\include\python2.7* to 
> *Maya\Python\include*
>
> суббота, 1 февраля 2020 г., 23:57:24 UTC+3 пользователь Paul Winex написал:
>>
>> I have solution!
>>
>> 1. You need to build cython locally. Install correct VS Libraries. For 
>> example Maya2018 require VS v14. You need to install Individual component 
>> and select some C++ build tools v14 and Windows SDK.
>> 2. Install cpython for maya without binary, pip must build it on you 
>> local machine
>> Command: 
>> set LIB=\Maya2018\lib
>> \Maya2018\bin\mayapy.exe -m pip install cython --no-binary :all
>> :
>> LIB variable is path to file python27.lib
>>
>> Now cython is installed, you can try to compile with command from this 
>> example https://gist.github.com/nrtkbb/5b65d2f5ed42bd9947b5
>> mayapy.exe setup.py build_ext --inplace
>>
>>
>>

-- 
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/2739541e-0e13-4111-b756-92ad7cf1be42%40googlegroups.com.


[Maya-Python] Re: maya api : while importing prompts error

2019-11-20 Thread Robert White
It looks like in some of your code you're referencing it as `twistYAttribute` 
but in other places as `twistYAttr` which appears to be the correct 
spelling.

On Tuesday, November 19, 2019 at 4:06:58 AM UTC-6, blossom ghuntla wrote:
>
> Hello All,
>
> I autodidact basic python, basic maya.cmds, basic qt just for the sake of 
> learning to create a deformer and i am not doing good at all
>
> i referred 
> https://help.autodesk.com/view/MAYAUL/2017/ENU/?guid=__cpp_ref_y_twist_node_2y_twist_node_8cpp_example_html
>
>
> # defTwist.py
>
> import sys
> import maya.OpenMayaMPx as OpenMayaMPx
> import maya.OpenMaya as OpenMaya
> import maya.cmds as cmds
> import math
>
> # Plug-in information:
> kPluginNodeName = "twistDeformer" # The name of the node.
> kPluginNodeId = OpenMaya.MTypeId( 0xBEEF8 ) # A unique ID associated to 
> this node type.
>
> # Some global variables were moved from MPxDeformerNode to 
> MPxGeometryFilter.
> # Set som constants to the proper C++ cvars based on the API version
> kApiVersion = cmds.about(apiVersion=True)
> if kApiVersion < 201600:
> kInput = OpenMayaMPx.cvar.MPxDeformerNode_input
> kInputGeom = OpenMayaMPx.cvar.MPxDeformerNode_inputGeom
> kOutputGeom = OpenMayaMPx.cvar.MPxDeformerNode_outputGeom
> kEnvelope = OpenMayaMPx.cvar.MPxDeformerNode_envelope
> else:
> kInput = OpenMayaMPx.cvar.MPxGeometryFilter_input
> kInputGeom = OpenMayaMPx.cvar.MPxGeometryFilter_inputGeom
> kOutputGeom = OpenMayaMPx.cvar.MPxGeometryFilter_outputGeom
> kEnvelope = OpenMayaMPx.cvar.MPxGeometryFilter_envelope
>
>
>
> class MyDeformerNode(OpenMayaMPx.MPxDeformerNode):
> 
> # Static variable(s) which will later be replaced by the node's 
> attribute(s).
> twistYAttr = OpenMaya.MObject()
>
> def __init__(self):
> ''' Constructor. '''
> # (!) Make sure you call the base class's constructor.
> OpenMayaMPx.MPxDeformerNode.__init__(self)
>
> def deform(self, pDataBlock, pGeometryIterator, pLocalToWorldMatrix, 
> pGeometryIndex):
> ''' Deform each vertex using the geometry iterator. '''
>
> # The envelope determines the overall weight of the deformer on the mesh.
> # The envelope is obtained via the 
> OpenMayaMPx.cvar.MPxDeformerNode_envelope (pre Maya 2016) or
> # OpenMayaMPx.cvar.MPxGeometryFilter_envelope (Maya 2016) variable.
> # This variable and others like it are generated by SWIG to expose 
> variables or constants declared in C++ header files. 
> envelopeAttribute = kEnvelope
> envelopeValue = pDataBlock.inputValue( envelopeAttribute ).asFloat()
>
> # Get the value of the mesh twist node attribute.
> twistYAttribute = pDataBlock.inputValue( MyDeformerNode.twistYAttr )
> twistYAttributeType = meshInflationHandle.asDouble()
>
> # Get the input mesh from the datablock using our 
> getDeformerInputGeometry() helper function. 
> inputGeometryObject = self.getDeformerInputGeometry(pDataBlock, 
> pGeometryIndex)
>
> # Obtain the list of normals for each vertex in the mesh.
> normals = OpenMaya.MFloatVectorArray()
> meshFn = OpenMaya.MFnMesh( inputGeometryObject )
> meshFn.getVertexNormals( True, normals, OpenMaya.MSpace.kObject )
>
>
> def getDeformerInputGeometry(self, pDataBlock, pGeometryIndex):
> '''
> Obtain a reference to the input mesh. This mesh will be used to compute 
> our bounding box, and we will also require its normals.
>
> We use MDataBlock.outputArrayValue() to avoid having to recompute the mesh 
> and propagate this recomputation throughout the 
> Dependency Graph.
>
> OpenMayaMPx.cvar.MPxDeformerNode_input and 
> OpenMayaMPx.cvar.MPxDeformerNode_inputGeom (for pre Maya 2016) and 
> OpenMayaMPx.cvar.MPxGeometryFilter_input and 
> OpenMayaMPx.cvar.MPxGeometryFilter_inputGeom (Maya 2016) are SWIG-generated 
> variables which respectively contain references to the deformer's 'input' 
> attribute and 'inputGeom' attribute.   
> '''
> inputAttribute = OpenMayaMPx.cvar.MPxGeometryFilter_input
> inputGeometryAttribute = OpenMayaMPx.cvar.MPxGeometryFilter_inputGeom
>
> inputHandle = pDataBlock.outputArrayValue( inputAttribute )
> inputHandle.jumpToElement( pGeometryIndex )
> inputGeometryObject = inputHandle.outputValue().child( 
> inputGeometryAttribute ).asMesh()
>
> return inputGeometryObject
>
>
> ##
> # Plug-in initialization.
> ##
> def nodeCreator():
> ''' Creates an instance of our node class and delivers it to Maya as a 
> pointer. '''
> return OpenMayaMPx.asMPxPtr( MyDeformerNode() )
>
> def nodeInitializer():
> ''' Defines the input and output attributes as static variables in our 
> plug-in class. '''
> # The following MFnNumericAttribute function set will allow us to create 
> our attributes.
> numericAttributeFn = OpenMaya.MFnNumericAttribute()
>
> #==
> # INPUT NODE ATTRIBUTE(S)
> #==
>
> # Define a mesh inflation attribute, responsible for actually moving the 
> vertices in the direction of their 

Re: [Maya-Python] Re: Do Maya has signal to tell object's transform being changed?

2019-05-14 Thread Robert White
scritpJob is built on top of the MMessage event system that is exposed 
through the API. So it is capable of doing everything that a scriptJob is, 
plus has access to some more granular events.
Nothing is stored in userPrefs though, you have to setup the events for 
each session.


On Tuesday, May 14, 2019 at 12:28:35 PM UTC-5, Lucid Production wrote:
>
> Hi Alberto
> I don't have much experience with MayaAPI but is Maya's EventSystem equal 
> to Mel's ScriptJob? ScriptJob store in preference of user's machine, so i 
> don't really like it much
>
> On Wed, May 15, 2019 at 12:02 AM Alberto Sierra Lozano <
> alberto.s...@gmail.com > wrote:
>
>> Hello!
>>
>> Have you checked the Event system from the Maya API?
>>
>>
>> https://help.autodesk.com/view/MAYAUL/2019/ENU/?guid=__py_ref_class_open_maya_1_1_m_poly_message_html
>>
>> Hope it helps!
>>
>> El martes, 14 de mayo de 2019, 18:42:50 (UTC+2), em@gmail.com 
>> escribió:
>>>
>>> Hi everybody, it would be awesome if Maya could tell us if a transform's 
>>> node being modified or not. I want to connect that's signal to PyQT gui and 
>>> handle the data. 
>>>
>>> Is that possible? Thanks
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/python_inside_maya/n0fjcjQAyWk/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/da5367e0-6553-475f-9b6f-51e8d6a8384a%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
>
> Tuan Nguyen (Mr) - Team Coordinator
>
> EM.Lucid - Animation Studio
> Website  : https://emlucid.wixsite.com/lucidproduction
> Tel : +84 974858574
>

-- 
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/b4d9622a-fa69-4888-991a-798cd97902a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: String formatting error for arg in dictionary for use in mel.eval

2019-03-08 Thread Robert White
Try:

my_naming = 'my_layer'
command = '"{{"BaseAnimation", "{0}"'.format(my_naming)

I believe the problem is that because you've got the single open { the 
formatting code gets confused. To insert a { into a formatted string you 
just double them up.

On Friday, March 8, 2019 at 1:54:09 PM UTC-6, kiteh wrote:
>
> Adding on, if I tried using `mel.eval('animLayerMerge{"BaseAnimation", 
> "%s"}' % my_naming)`, while it seems to work, but it mutes out my_layer and 
> instead creates another animation layer called `Merged_Layer`
>
> On Friday, March 8, 2019 at 11:41:29 AM UTC-8, kiteh wrote:
>>
>> Hi all, I am trying to do a string formatting in which it is in a 
>> dictionary format that is to be used in mel command.
>>
>> This is my mel command - `mel.eval('animLayerMerge{"BaseAnimation", 
>> "my_layer"}')`
>>
>> In my python format, I rewrote as this:
>> my_naming = 'my_layer'
>> command = '"{"BaseAnimation", "{0}"'.format(my_naming)
>>
>> However this will results in the following error:
>> # Error: "BaseAnimation", "{0}"
>> # Traceback (most recent call last):
>> #   File "", line 2, in 
>> # KeyError: '"BaseAnimation", "{0}"' # 
>>
>> No matter how I wrote my `.format`, it will definitely errors out as soon 
>> as I tried to incorporate in `{ {0} }` and the reason I am doing this is 
>> because I would not want to hardcode the value of `my_naming` as it reads 
>> from a text field which would means different naming.
>>
>> Is there a better way that I can perhaps get around this?
>>
>>

-- 
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/dc713b2d-47e0-4f42-a0b4-f070435644c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Is it possible to install new modules in python to be used inside maya ?

2019-01-31 Thread Robert White
You can use mayapy instead of a custom python install when compiling 
modules for Maya. I've done this for quite a few extensions.

Also the easiest way to get pip running specifically for maya, is just 
`mayapy -m ensurepip` (at least for more recent versions)
On windows this will install it in c:\program files\autodesk\maya 
\Python, so you'll need permission to write to program files, 
which is super annoying.
Its a fairly old version of pip so it might complain about things until you 
update it with `mayapy -m pip install --upgrade pip setuptools`

As mentioned though, building C-extensions is a bit more of a pain.

On Thursday, January 31, 2019 at 5:27:09 PM UTC-6, Joe Weidenbach wrote:
>
> Yeah, my post was intended to be a bit more advanced (apologies about 
> that), primarily because windows makes things harder for customization, at 
> least with Maya and other DCC apps. Python 2.7 on windows still uses 
> msvc-9, where Maya, Houdini, etc are now on custom builds with msvc-2015.  
> So, anything that needs C-level compatibility (numpy etc) has issues unless 
> you use a custom compile of python.  Plain python _should_ work just fine 
> (hence my PYTHONPATH recommendations).  With any luck, you won't run into 
> issues with numpy (they've only accelerated certain parts with C to my 
> knowledge), but if you do, it's going to likely be due to the binary 
> incompaitibilities.
>
> Also, where on linux and (I believe) macos, mayapy is just a shell script 
> that sets up the maya environment for the system-installed python, on 
> Windows it's a custom-built executable -- which I believe is due to the 
> aforementioned compiler differences.
>
> For general development and small-studio work, there are plenty of ways to 
> get things running, so I'm glad the pip side worked.  It's more of a 
> challenge when you want to roll things out to a larger audience, with for 
> example a requirements.txt and as a pip module.  
>
> As to simply getting things running for personal projects, I've had a lot 
> of success in the past just copying the modules I need into my maya scripts 
> directory.  It's much less flexible, but it works well, at least so long as 
> you're not using modules that need C-level compatibility.  For those, I 
> believe that you'd need to build a custom python install with the correct 
> version of msvc, and then build the modules in question against that.  But, 
> as I've said, for most things I've needed that level of python support for, 
> I've found ways to get what I need out of maya for offline processing, and 
> then can just use my system python with whatever modules I want.  This also 
> has the side-benefit of keeping my maya code small and isolated, so that my 
> maya install can pretty much be off the shelf.  With that said, that does 
> add an extra layer of complexity.
>
> On Fri, 1 Feb 2019 at 11:42 francois bonnard  > wrote:
>
>> Thanks Markus & Joe
>>
>> I appreciate your support.
>>
>> Here is what I did :
>>
>> 1. Install python 2.7 in C:
>> 2. I have found a whl version  of scipy and numy from Eric Vignola in 
>> this forum
>> 3. python -m pip install "numpy-1.13.1+mkl-cp27-none-win_amd64.whl"  did 
>> the trick
>> 4. In Maya : 
>>
>> import sys
>> sys.path.append("C:\Python27\Lib\site-packages")
>> import numpy
>> import scipy
>>
>>
>>
>> That's it. 
>>
>> Now the big ML part has started :-)
>>
>> I guess Joe has a point with using mayapy to install pip and then install 
>> numpy (because I definitely don't see myself compiling source for windows)
>>
>>
>> PS for Markus : I have just read your "constructive" comments in an old 
>> post to David regarding his version of MayaSublime. 
>> https://github.com/justinfx/MayaSublime
>> Has he implemented your remark ? 
>>
>> (David if you read me, congratulations for this forum)
>>
>> François (just a guy in the universe)
>>
>>
>> Le jeudi 31 janvier 2019 22:23:35 UTC+1, Marcus Ottosson a écrit :
>>
>>> Based on the question, I’ve got a feeling “PYTHONPATH” and “Virtualenvs” 
>>> is a little on the advanced side with regards to what Francois is looking 
>>> for.
>>> If you’re able to install anything with Python, then it’d at least be 
>>> safe to assume a working knowledge of pip, in which case this should 
>>> help you get started.
>>>
>>> *Windows*
>>>
>>> $ pip install Qt.py --target ./
>>> $ set PYTHONPATH=%cd%
>>> $ start "" "c:\program files\autodesk\maya2018\bin\maya.exe"
>>>
>>> *Linux*
>>>
>>> $ pip install Qt.py --target ./
>>> $ export PYTHONPATH=$(pwd)
>>> $ maya
>>>
>>> Where pip install Qt.py is your everyday Python module installation 
>>> procedure, followed by --target ./ which means “Install to the current 
>>> working directory”. Then, set/export makes the module known to Python, 
>>> and finally Maya is launched.
>>>
>>> From within Maya, you should then be able to say import Qt
>>>
>>> --target could be given any path, like a global directory of some kind 
>>> where you keep all of your Maya modules, like 

[Maya-Python] Re: remap reference paths on load

2018-12-07 Thread Robert White
I've done this at a past job, and sadly don't have the code in front of me 
anymore.
But from what I remember you get a MFile object from the callback, and can 
edit the paths in that file object, and they will be passed into the 
created reference node after the callback is finished.


On Friday, December 7, 2018 at 8:50:14 AM UTC-6, Michał Frątczak wrote:
>
> So, has anybody found a nice way to remap path to a referenced file based 
> on referenceNode attributes?
> It seems referenceNode is not accessible inside 
> kBeforeCreateReferenceCheck callback
>
>
> On Thursday, December 30, 2010 at 3:12:58 PM UTC+1, Pierre A wrote:
>>
>> Thanks for the link, actually I had already bumped into that one.
>>
>> So let's recap the issue: if the file path does not lead to an existing 
>> file, the reference is not created.
>> This behavior is the same with buildLoadSettings set to True in the 
>> cmds.file function. And when there is no reference node in the scene, 
>> you've lost all your data. Too late.
>>
>> Regarding the callbacks, only MSceneMessage.addCheckFileCallback, 
>> and MSceneMessage.addCheckCallback can be used, with 
>> the kBeforeCreateReferenceCheck enum. These callbacks will be triggered 
>> before reference creation.
>>
>> If you parse a .ma file, there are at least three lines regarding 
>> reference creation:
>> 1/ file -rdi 1 -ns "REF_NS" -dr 1 -rfn "REF_NAME" "/path/to/file.ma";
>> 2/ file -r -ns "REF_NS" -dr 1 -rfn "REF_NAME" "/path/to/file.ma";
>> 3/ createNode reference -n "REF_NAME";
>>
>> The first line does not trigger the remap path popup ("abort..." - "skip" 
>> - "browse..." buttons). The second one does.
>> addCheckFileCallback and addCheckCallback are called just before 2/ is 
>> executed.
>>
>> If you want to monitor the reference node creation, this step is executed 
>> after the path check. It's the line 3/. You can have callbacks thanks 
>> to MDGMessage.addNodeAddedCallback, but it's useless for me.
>>
>> Among MSceneMessage.addCheckFileCallback 
>> and MSceneMessage.addCheckCallback, only addCheckFileCallback is relevant 
>> here because you can modify the MFileObject passed as argument of the 
>> callback (by reference).
>>
>> http://download.autodesk.com/us/maya/2011help/API/class_m_scene_message.html#5e6feb8445b04b7277c0a425a613444f
>>
>> http://download.autodesk.com/us/maya/2011help/API/class_m_message.html#c9d1a728216d6a9618052ad122710fa8
>>
>> Note: Don't forget to set retCode to True with 
>> OpenMaya.MScriptUtil.setBool(retCode, True). The signature of setBool is 
>> bool& but it seems to accept a bool*
>>
>> In my particular case, I need the reference node name (rfn) to be able to 
>> remap the bad path to an existing one. Unfortunately, I have not found a 
>> way to get this piece of info in a straightforward manner.
>> I have tried to use the MCommandMessage.addCommandCallback in order to 
>> see which 2/ "file -r -ns  " is executed, but the callback is called 
>> after the addCheckFileCallback.
>> Of course, the 1/ "file -rdi 1 -ns ... " are executed 
>> before addCheckFileCallback, and I could assume that 2/ commands will be 
>> called in the same order than 1/.
>> Another hack would be to directly parse the .ma file and build a 
>> list/dict for the list of 2/ command lines.
>> Then, by incrementing an index for each addCheckFileCallback call, I 
>> could match the reference name with the corresponding path.
>>
>> The first solution proposed by Christian is clearly simpler, providing 
>> that the renaming process is not harmful. Unfortunately I can not overwrite 
>> the maya files.
>>
>> I think I'll go with a .ma parsing for 2/ lines & building list of 
>> reference node name.
>>
>>

-- 
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/6250d149-c446-4781-8444-ca2af49303b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: pymel.core.nodetypes.Locator class giving a ValueError when instantiated

2018-11-02 Thread Robert White
Opened a PR for a fix https://github.com/LumaPictures/pymel/pull/415, may 
or may not get accepted.
But simple enough if you want to patch it locally.

On Friday, November 2, 2018 at 10:02:28 PM UTC-5, Robert White wrote:
>
> Also, the secondary check, where it tries to see if the nodetype matches 
> the newly created node also fails, because spaceLocator has created a 
> transform, and the secondary check is looking for a locator.
>
>
> On Friday, November 2, 2018 at 10:00:09 PM UTC-5, Robert White wrote:
>>
>> So what seems to be happening is that pymel.core.general.spaceLocator has 
>> been altered to return just a Locator and not a list.
>> pymel.core.nodetypes.Locator uses pymel.core.general.spaceLocator to 
>> generate the object, and then because it isn't a list (which is what the 
>> generic pymel machinery expects) it throws that error.
>>
>> So this is definitely a bug.
>>
>> On Friday, November 2, 2018 at 6:03:14 PM UTC-5, Luca Di Sera wrote:
>>>
>>> I can't seem to find anything about this particular problem on the web. 
>>> Basically, If I create a locator in any other way or if I instantiate 
>>> any other pymel.core.nodetype.* class ( I haven't tried them all obviously 
>>> ) I incur in no unexpected behavior. 
>>> If I, instead, try to create an instance of the 
>>> pymel.core.nodetypes.Locator class, I incur in the following error : 
>>>
>>>
>>> # Error: line 1: ValueError: file C:\Program 
>>> Files\Autodesk\Maya2017\Python\lib\site-packages\pymel\core\general.py line 
>>> 2273: unexpect result locator1 returned by spaceLocator # 
>>>
>>> Looking at general.py this seems to happen in the node creation when the 
>>> newly created Maya node can't be correctly found or is not of the correct 
>>> type. 
>>> I'm not sure what is the reason behind this error, but, considering that 
>>> it only happens when I try to instantiate this particular class ( the 
>>> product of which works perfectly if created in any other way ), I'm 
>>> thinking this may actually be a bug. 
>>>
>>> Does anyone know what exactly may be the reason behind this behavior? Am 
>>> I doing something wrong and this is to be expected ?
>>
>>

-- 
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/5e415435-6345-4b2e-977c-6117edc0bce5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: pymel.core.nodetypes.Locator class giving a ValueError when instantiated

2018-11-02 Thread Robert White
Also, the secondary check, where it tries to see if the nodetype matches 
the newly created node also fails, because spaceLocator has created a 
transform, and the secondary check is looking for a locator.


On Friday, November 2, 2018 at 10:00:09 PM UTC-5, Robert White wrote:
>
> So what seems to be happening is that pymel.core.general.spaceLocator has 
> been altered to return just a Locator and not a list.
> pymel.core.nodetypes.Locator uses pymel.core.general.spaceLocator to 
> generate the object, and then because it isn't a list (which is what the 
> generic pymel machinery expects) it throws that error.
>
> So this is definitely a bug.
>
> On Friday, November 2, 2018 at 6:03:14 PM UTC-5, Luca Di Sera wrote:
>>
>> I can't seem to find anything about this particular problem on the web. 
>> Basically, If I create a locator in any other way or if I instantiate any 
>> other pymel.core.nodetype.* class ( I haven't tried them all obviously ) I 
>> incur in no unexpected behavior. 
>> If I, instead, try to create an instance of the 
>> pymel.core.nodetypes.Locator class, I incur in the following error : 
>>
>>
>> # Error: line 1: ValueError: file C:\Program 
>> Files\Autodesk\Maya2017\Python\lib\site-packages\pymel\core\general.py line 
>> 2273: unexpect result locator1 returned by spaceLocator # 
>>
>> Looking at general.py this seems to happen in the node creation when the 
>> newly created Maya node can't be correctly found or is not of the correct 
>> type. 
>> I'm not sure what is the reason behind this error, but, considering that 
>> it only happens when I try to instantiate this particular class ( the 
>> product of which works perfectly if created in any other way ), I'm 
>> thinking this may actually be a bug. 
>>
>> Does anyone know what exactly may be the reason behind this behavior? Am 
>> I doing something wrong and this is to be expected ?
>
>

-- 
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/e377be73-1608-497a-bc5b-17f8e3f926a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: pymel.core.nodetypes.Locator class giving a ValueError when instantiated

2018-11-02 Thread Robert White
So what seems to be happening is that pymel.core.general.spaceLocator has 
been altered to return just a Locator and not a list.
pymel.core.nodetypes.Locator uses pymel.core.general.spaceLocator to 
generate the object, and then because it isn't a list (which is what the 
generic pymel machinery expects) it throws that error.

So this is definitely a bug.

On Friday, November 2, 2018 at 6:03:14 PM UTC-5, Luca Di Sera wrote:
>
> I can't seem to find anything about this particular problem on the web. 
> Basically, If I create a locator in any other way or if I instantiate any 
> other pymel.core.nodetype.* class ( I haven't tried them all obviously ) I 
> incur in no unexpected behavior. 
> If I, instead, try to create an instance of the 
> pymel.core.nodetypes.Locator class, I incur in the following error : 
>
>
> # Error: line 1: ValueError: file C:\Program 
> Files\Autodesk\Maya2017\Python\lib\site-packages\pymel\core\general.py line 
> 2273: unexpect result locator1 returned by spaceLocator # 
>
> Looking at general.py this seems to happen in the node creation when the 
> newly created Maya node can't be correctly found or is not of the correct 
> type. 
> I'm not sure what is the reason behind this error, but, considering that 
> it only happens when I try to instantiate this particular class ( the 
> product of which works perfectly if created in any other way ), I'm 
> thinking this may actually be a bug. 
>
> Does anyone know what exactly may be the reason behind this behavior? Am I 
> doing something wrong and this is to be expected ?

-- 
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/47b08964-2700-4b3f-aee7-d72f44e9d042%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] how to install pyodbc for maya 2017

2018-09-12 Thread Robert White
I think he's looking for a library to specifically access MS-SQL not MySQL.
Sadly I couldn't find any pure python implementations. So you'll probably 
just need to compile your own version.

On Wednesday, September 12, 2018 at 6:27:35 AM UTC-5, flop...@gmail.com 
wrote:
>
> You could try a pure python implementation called pymysql (
> https://pypi.org/project/PyMySQL/)
> It does have some dependencies: crytography, enum, six, and wheel (which 
> should come doe with the pip install.
>
> I haven't used it yet (still sorting other parts of the pipeline), but 
> looked into something I could run in Maya and 3DSMax so i didnt have to 
> compile things multiple times.
>
> Cheers,
> Dave
>
>
> On Wed, Sep 12, 2018 at 9:02 PM MW > 
> wrote:
>
>> oh my! I had hoped that I can get away without doing any compiling 
>> because I'm a total noob in this topic. maybe anyone on this forum is using 
>> a module in maya to access microsoft sql server (pymssql, pyodbc or 
>> something different). any help would be greatly appreciated!
>>
>> Am Mittwoch, 12. September 2018 12:56:33 UTC+2 schrieb Justin Israel:
>>>
>>> I'm not a Windows user but I imagine that you would have to compile it 
>>> against Microsoft Visual Studio 2012 (?) to match the Maya 2017 compiled 
>>> version. 
>>>
>>> On Wed, Sep 12, 2018, 10:50 PM  wrote:
>>>
 Hi everybody,

 I'm a little bit lost and hope for your help here.

 I'm running Maya 2017 update 5 and an microsoft sql server.

 I want to use pyodbc in maya to read and write data into our database 
 but i can't get pyodbc to work in maya. if i use an external python shell 
 it works but not in maya. I always get dll missing error. I checked the 
 dependencies and copied the missing msvcr90.dll to the python 
 site-packages 
 which led to another error:

 ImportError: DLL load failed: %1 is not a valid Win32 application

 can anyone tell me how to get pyodbc working in maya.

 thanks in advance

 -- 
 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/6f79dfcd-9fc9-4065-b549-f86026c6ef9d%40googlegroups.com
 .
 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/5d4bca57-77c8-4df2-be14-2a36afad3760%40googlegroups.com
>>  
>> 
>> .
>> 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/9cd4bd83-62bf-4879-b82c-35a558f15b72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: MayaPy Cython Error

2018-09-02 Thread Robert White
So you need to get the proper version of visual studio installed.
You'll also want to get pip installed with mayapy.
Then you want to use the command proper VS command prompt for that version.
You need to add the Python libs to LIB, and the headers to INCLUDE, these 
should be located somewhere in the maya install directory.
At this point you can finally do `pip install cython --no-binary :all:` 
which will for cython to install itself while building from source, and not 
using any pre-compiled binaries, which is what you're attempting to avoid.


On Wednesday, August 29, 2018 at 2:20:45 PM UTC-5, lirui...@gmail.com wrote:
>
> 在 2018年2月8日星期四 UTC+8上午11:12:52,徐宗巧写道: 
> > Thanks very much to Justin Israel and Robert White, I had solved the 
> issue already!! 
> > Like you said, i had install visual studio 2012, and build Cython for 
> maya2014 and maya2016. Both of them are working fine!! Great thanks! 
>
> How did you solve it? Could you elaborate on that? I had the same problem

-- 
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/3eec750a-39a7-4c63-9a98-e41eacc3203f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] dynamically changing sys.path

2018-07-27 Thread Robert White
I think you'd be better served with a small launcher app. That allows for 
the artist to make their selection.
Then that opens the proper app from the proper location.
Otherwise you're going to be fighting a lot of low level language machinery 
to get what you want.

On Friday, July 27, 2018 at 8:46:48 AM UTC-5, Juan Cristóbal Quesada wrote:
>
> basically,
> the same application when a selection button is clicked should perform 
> again all the imports from a specific repository. This specific repository 
> is not known beforehand, it is only known at the specific moment when the 
> artist chooses and hits that button.
> Some of the dependencies are duplicated in both folders, so what im doing 
> is deleting the modules loaded in the "pre-button hit", modifiying the sys 
> path and then importing them manually again to the sys.modules dictionary
> For example, we are using the Qt.py module. This module is duplicated and 
> appears in the "static" repo and also in every other "dynamic" repo, 
> although the PySide modules are the same.
> uhmm, maybe  i could treat PySide modules as a special case and choose not 
> to reimport them.. will give it a try.
>
> Apparently im not having any other problems with importing the 'dynamic' 
> repo modules but when it comes to PySide it does is this a general 
> behaviour of compiled libraries?
>
>
> 2018-07-27 3:35 GMT+02:00 Alok Gandhi >
> :
>
>> Try using importlib  or 
>> imp 
>>
>> Although, as Justin has already pointed out, it is not recommended to use 
>> reload in production code or to dynamically append/insert paths in sys.path.
>>
>> Give more thought to the design and architecture of your app. A good 
>> design should handle dependencies in a more elegant and efficient manner. A 
>> possible design idea would be this - If you are already aware of all the 
>> path that the app might need during runtime, load them up at boot time and 
>> use them later. Do note the fact that python modules are first class object 
>> i.e they can be used as a variable, can be dynamically created, passed and 
>> returned from a function. Use this for your design.
>>
>> - Alok
>>
>> On Fri, Jul 27, 2018 at 7:00 AM Justin Israel > > wrote:
>>
>>> Would you be able to explain a bit more about the goal you are trying to 
>>> solve, with dynamically loading a second widget into your main application? 
>>> Does this second widget have drastically different dependencies? I'm 
>>> interested specifically in the part where you need to reload modules. This 
>>> is where things are going to go wrong. It is one thing to modify the 
>>> sys.path (which you should still try to avoid at runtime), but reloading is 
>>> usually something only reserved for debug situations. It definitely does 
>>> not work correct with compiled extensions like the PySide modules.
>>>
>>>
>>>
>>> On Fri, Jul 27, 2018 at 1:52 AM Juan Cristóbal Quesada <
>>> juan.cri...@gmail.com > wrote:
>>>
 Hi,
 this is more of a pure python question i want to throw here.
 Im developing a PySide Application that is used as the 
 context/task/app/openfile launcher by the artists.

 The artist makes some choices that drive him towards different dialogs 
 and widgets. The thing is, due to a request, im facing the need to 
 dynamically change the sys path and reload all the modules from a 
 different 
 location inside the same main QApplication.

 The reason for this is that, once an artist makes a specific choice, 
 all the following widgets... and code that is executed should be loaded 
 from another location different than the current app. But, should look as 
 if it were still part of the same app, the widgets need to appear embedded.

 Ive managed to change the sys.path of the original folder to the folder 
 i want and successfully loaded all the modules from the new path, but then 
 im starting to get some strange behavior:

 QtCore.QObject.__init__(self)
 AttributeError: 'NoneType' object has no attribute 'QObject'

 (Even if performed the from PySide2 import QtCore)

 I understand what im trying to achieve is not very orthodox, i was 
 wondering if its even possible!

 I would like to avoid obvious ways of separating it in two 
 QApplications and closing one when the other is opened for example.

 Has any of you ever tried to do something like this? 
 What concerns should i be aware of when doing it?

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

[Maya-Python] Re: popupMenu command works in Python but not in Mel

2018-07-26 Thread Robert White
I believe the problem you're running into here, is that the popupMenu 
-postMenuCommand expects the command to be in mel, because you're 
triggering it from mel.


On Thursday, July 26, 2018 at 3:01:24 PM UTC-5, likage wrote:
>
> I was trying to convert a popupMenu command from Python to Mel..
>
> When using Python:
> cmds.popupMenu( button=1, postMenuCommand="import lod_select; lod_menu = 
> lod_select.make_dropdown(); lod_select.show_menu(lod_menu)")
>
>
> However, when I tried converting the above command into MEL, I get an 
> error:
> # Keeps getting error output of "Invalid use of Maya object "lod_menu"
> popupMenu -button 1 -postMenuCommand "import lod_select; lod_menu = 
> lod_select.make_dropdown(); lod_select.show_menu(lod_menu)";
>
>
> Any ideas?
>

-- 
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/6114e628-0030-4a87-813a-c9b0dc03125d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: PyCharm Auto Completion in Maya 2018 for QT5

2018-06-12 Thread Robert White
Someone has posted some backups of them here:
https://github.com/tds-anonymous/maya-devkit

Not sure where autodesk has moved them to this time, but they've been 
bouncing around the last few years.

On Tuesday, June 12, 2018 at 11:56:09 AM UTC-5, meljunky wrote:
>
> I have been using the completion from Maya 2015 found under in PyCharm 
> (Professional Edition) in my interpreter path with Maya 2018:
> C:\Program Files\Autodesk\Maya2015\devkit\other\pymel\extras\completion\py
>
> Everything was fine until I wanted to use Pyside and found out that I have 
> now have to switch to Qt5 which now uses PySide2 in Maya 2018.
>
> Hoping to switch over the autocomplete to Maya 2018 I looked devkit 
> directory and found it is empty and everything has been moved.
> C:\Program Files\Autodesk\Maya2018\devkit
>
> I haven't found any help with fixing autocomplete for Maya 2017/2018 in 
> PyCharm.
>
> How do I setup Pycharm autocomplete to work with Qt5 modules?
>
> Thanks,
> Brian
>

-- 
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/c6cb0e13-4c97-47a8-8702-2c815ef1b5c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] List all registered callbacks

2018-04-23 Thread Robert White
I'm not sure there is a simple way.
I went looking the last time I was doing serious work with callbacks, and 
eventually just settled on wrapping them with my own custom classes that 
could handle de-registration as needed.

The closest I could find was `MMessage.nodeCallbacks` which will return a 
list of callbacks associated with a node, but that won't track things like 
scene, ui, or other non-node based callbacks.




On Monday, April 23, 2018 at 10:06:17 PM UTC-5, Marcus Ottosson wrote:
>
> Hi all,
>
> With the Maya Python API (both 1.0 and 2.0) you can register callbacks, 
> like so:
>
> from maya.api import OpenMaya as om
> om.MDGMessage.addTimeChangeCallback(...)
>
> It’ll hand you an ID you can later use to deregister it.
>
> def myCallback(time, clientData):
>pass
>
> eventId = om.MDGMessage.addTimeChangeCallback(myCallback, None)
> om.MMessage.removeCallback(eventId)
>
> But what do you do when you haven’t kept track of the ID? I’m debugging a 
> potential leak of events being registered but not unregistered and am 
> looking for something along the lines of..
>
> for func, eventId in om.MMessage.listCallbacks():
>   print("EventID %d belongs to %s" % (func, eventId))
> # EventID 153 belongs to 'myCallback'
>
> I’m also curious about what events are registered per default and by 
> third-party plug-ins or scripts and figure this would be an intuitive way 
> of finding out.
>
> How can I list all currently registered events?
>
> Thanks,
> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/3aa9077b-70c7-4607-a70c-aeeb1a53ee92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Has anyone had success with setting up virtualenv with mayapy?

2018-03-08 Thread Robert White
The only time I've gotten virtualenv to operate was using a custom python 
build that matched the runtime environment of Maya (I was on windows, which 
meant compiling with a newer compiler), and then manually doing the dirty 
work to set all the paths and environment variables properly so that it 
could find all the maya packages and dlls.

In was a fun experiment, but felt like way more work than what I got out of 
it.


On Thursday, March 8, 2018 at 12:17:08 PM UTC-6, James Deschenes wrote:
>
> Yeah that's what I'm beginning to understand as well. I also need to 
> manage the plug-in environment as well as some other things which will 
> likely go beyond the scope of Python virtual environments. Thanks for 
> confirming my suspicions.
>

-- 
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/d2de87af-aaa2-466e-b371-bfdaa29aa367%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Has anyone had success with setting up virtualenv with mayapy?

2018-03-07 Thread Robert White
Maya does some things when it comes to how it deploys python that just 
aren't compatible with virtualenv.
The biggest hurdle is that they zip up the entire standard library, while 
virtualenv likes to copy and enhance certain files from the standard 
library so as to operate properly.




On Wednesday, March 7, 2018 at 1:31:35 PM UTC-6, James Deschenes wrote:
>
>
> Has anyone had success with setting up virtual environments with mayapy? 
> I'm seeing the following error and I'm guessing that the issue is with the 
> python home and the binary being in different locations.
>
> C:\dev\hg_checkouts\mayaenv>virtualenv --python="C:\Program 
> Files\Autodesk\Maya2018\bin\mayapy.exe" test
> Running virtualenv with interpreter C:\Program 
> Files\Autodesk\Maya2018\bin\mayapy.exe
> PYTHONHOME is set.  You *must* activate the virtualenv before using it
> Traceback (most recent call last):
>   File "c:\python27\lib\site-packages\virtualenv.py", line 2328, in 
> 
> main()
>   File "c:\python27\lib\site-packages\virtualenv.py", line 713, in main
> symlink=options.symlink)
>   File "c:\python27\lib\site-packages\virtualenv.py", line 925, in 
> create_environment
> site_packages=site_packages, clear=clear, symlink=symlink))
>   File "c:\python27\lib\site-packages\virtualenv.py", line 1145, in 
> install_python
> site_filename_dst = change_prefix(site_filename, home_dir)
>   File "c:\python27\lib\site-packages\virtualenv.py", line 1036, in 
> change_prefix
> (filename, prefixes)
> AssertionError: Filename C:\Program 
> Files\Autodesk\Maya2018\bin\python27.zip\site.py does not start with any of 
> these prefixes: ['C:\\Program Files\\Autodesk\\Maya2018\\Python']
>
>
>

-- 
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/134eaa48-9e52-4ea7-b9ef-0b50925b035d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] MayaPy Cython Error

2018-01-23 Thread Robert White
You'd need to build Cython for maya against the proper version of visual 
studio.
Which in 2014 I believe was VS2010. You'll also need to use that version 
when actually compiling your cython project.

On Monday, January 22, 2018 at 9:47:31 PM UTC-6, Justin Israel wrote:
>
> My guess is that the compiled aspects of Cython don't like being loaded 
> into Maya's python. Do you need to build Cython against Maya specifically?
> I use Cython-based projects inside of Maya, but my experience is on Linux. 
> Generally I can just use a standard Cython installation and build with a 
> generally compatible gcc version. 
>
> Justin
>
> On Tue, Jan 23, 2018 at 4:33 PM  wrote:
>
>> Hi Everyone!
>>  I got a issue which beset me in the past few days about how to 
>> compiling pyd file using mayapy.exe.
>>
>> I have tested on Windows10 with both maya2014 and maya2016 sp6, but got 
>> the same error like bellow:
>>
>>"Runtime Error!
>> Program: C:\Program Files\Autodesk\Maya2014\bin\mayapy.exe
>>
>> R6034
>> An application has made an attempt to load the C runtime library 
>> incorrectly.
>> Please contract the application's support team for more information."
>>
>>
>> E:\test\test>mayapy setup.py build_ext --inplace
>> Traceback (most recent call last):
>>   File "setup.py", line 2, in 
>> from Cython.Build import cythonize
>>   File "C:\Program 
>> Files\Autodesk\Maya2014\Python\lib\site-packages\Cython\Build\__init__.py", 
>> line 1, in 
>> from .Dependencies import cythonize
>>   File "C:\Program 
>> Files\Autodesk\Maya2014\Python\lib\site-packages\Cython\Build\Dependencies.py",
>>  
>> line 59, in 
>> from ..Compiler.Main import Context, CompilationOptions, 
>> default_options
>>   File "C:\Program 
>> Files\Autodesk\Maya2014\Python\lib\site-packages\Cython\Compiler\Main.py", 
>> line 28, in 
>> from .Scanning import PyrexScanner, FileSourceDescriptor
>> ImportError: DLL load failed: A dynamic link library (DLL) initialization 
>> routine failed.
>>
>>
>> 
>>
>> This is my simple hello world python script file:
>>
>> def hello():
>> print "Hello World"
>>
>> 
>>
>> This my setup.py file:
>>
>> from distutils.core import setup
>> from distutils.extension import Extension
>> from Cython.Distutils import build_ext
>>
>> setup(
>> cmdclass = {'build_ext': build_ext},
>> ext_modules = [Extension("helloworld", ["helloworld.py"])]
>> )
>>
>> --
>>
>> Btw, i used pip to install Cython under C:\Program 
>> Files\Autodesk\Maya2014\Python\Lib\site-packages.
>>
>>
>> Does anyone face the same issue like me and have any solution about it?
>> Anyone can help?
>> Great thanks for you!!
>>
>> --
>> 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/ece1c1e7-3729-4144-8a14-cbdab8d37368%40googlegroups.com
>> .
>> 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/b3c4c259-db8f-4d0d-9df1-45bd4cd263f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] changing path to references witha callback

2017-11-29 Thread Robert White

MSceneMessage.addCheckFileCallback with kBeforeLoadReferenceCheck should 
get you what you want. 

You'll get a reference to the file object before the reference has been 
loaded, and you should be able to tweak and update the file paths from 
there. 
I've used this in the past to fix issues where some machines were replacing 
environment variables with the full path.


On Wednesday, November 29, 2017 at 11:23:25 AM UTC-6, Michał Frątczak wrote:
>
> Yeah, dirmap is better. If only I could remember how I did it last time :)
> Will use dirmap() from now on, thanks !
>
>
> W dniu 29.11.2017 o 18:12, Mahendra Gangaiwar pisze:
>
> I think better approach here would be make use of "dirmap" command, so you 
> could map Linux to Windows and vice versa.. 
>
> Something like this:
>
> dirmap("//server", "/server");
> dirmap("/server", "//server");
>
> Try running above command, and open file, all references and texture paths 
> should remapped automatically by Maya.
>
> On Wed 29 Nov, 2017, 9:34 PM Michał Frątczak,  > wrote:
>
>> Hi
>>
>> We move maya scenes between linux and windows machines.
>> When linux references a file it uses UNC paths like: 
>> /server/project/file.ext
>> whereas windows needs double slash in front: //server/project/file.ext
>>
>> I have a MSceneMessage.kBeforeSave callback that fixes paths on texture 
>> nodes (ensures leading //).
>> I remember having done similar thing with references too, but I lost the 
>> script and can't recall details... any hints how to change path to 
>> reference ?
>>
>> Here is my texture fixing code:
>>
>> def addFirstSlash(i_str):
>> if i_str[0] == '/' and i_str[1] != '/':
>> return '/' + i_str
>> return i_str
>>
>> def mf_MSceneMessage_BeforeSave_CB(*args, **kwargs):
>> for f in mc.ls(type='file'):
>> mc.setAttr(f + '.ftn', addFirstSlash(mc.getAttr(f + '.ftn')), 
>> type='string')
>>
>> om.MSceneMessage.addCallback(om.MSceneMessage.kBeforeSave, 
>> mf_MSceneMessage_BeforeSave_CB)
>>
>>
>>
>>
>>
>> -- 
>> 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/d2c24e10-41f8-4b90-a05e-38369c42b8f5%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> -- 
> Best, 
>
> -M
> -- 
> 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/CA%2B7MZWtvrU3JSdZQ3v9PJTGu7QE27K9RCD2n1CwTYhK%2BZchL6A%40mail.gmail.com
>  
> 
> .
> 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/fe883a81-17dd-465f-8023-3294641fb230%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Add menu to grapheditor/hypershape

2017-11-27 Thread Robert White
Yeah, there isn't an API call for when UI's are created, just destroyed.
http://help.autodesk.com/view/MAYAUL/2017/ENU/?guid=__cpp_ref_class_m_ui_message_html



On Sunday, November 26, 2017 at 7:13:17 PM UTC-6, Justin Israel wrote:
>
>
>
> On Sat, Nov 25, 2017 at 9:35 AM Pritish Dogra  > wrote:
>
>> I can add the menu through the following code
>>
>> import pymel.core as pm
>> parent_object = pm.getPanel(sty="graphEditor")[0]
>> pm.menu("test_menu", parent=parent_object, label="Test Menu", tearOff=
>> True
>>
>> However as soon as I tear off the graph editor panel, I lose the menu. 
>> How can I make this permanent for the graph editor window or any other 
>> scripted panel? 
>>
>
> I haven't been setting this stuff up in newer Maya releases (2016+) so my 
> information may be out of date. But ya it is a bit tricky to make custom 
> changes to Maya's interface and have them be persistent when the UI is 
> modified. This is happening because a tear-off is recreating the widget and 
> your injected modifications to the old widget are lost. 
>
> Some options you have to automatically introduce this change is to include 
> setting an event filter 
>  on one of 
> the parent objects that don't change. This could end up just being the main 
> window or the QApplication. The event filter would be watching for the 
> ChildAdded  event, and if 
> its the expected type of widget you can apply your customization. 
>  
> I don't recall the MMessage API offering any hooks for when arbitrary UI's 
> are created.  
>
>
>> Cheers
>>
>> Pritish
>>
>>
>>
>>
>>
>>
>> -- 
>> 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/08d0a77a-a497-460e-8c69-9ef5e8231a7e%40googlegroups.com
>>  
>> 
>> .
>> 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/63e232d6-cca3-4676-b6b8-b36a74487d70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] StopIteration, where art thou?

2017-10-11 Thread Robert White
Huh, that is super weird.

I'm getting the same behavior. It probably has something to do with how 
maya is exec-ing the listener. Clearly it is throwing the exception, it 
just getting swallowed somewhere along the way. Maybe the for loop is 
grabbing it? execution does stop though.

Really weird.


On Wednesday, October 11, 2017 at 10:30:35 PM UTC-5, Michael Boon wrote:
>
> I'm on Windows. To clarify though, it's not about StopIteration being 
> available (except in 2015, apparently). It's about StopIteration being 
> silently caught. This appears to only happen in the Listener. In 2018, at 
> least, if I try it in an imported Python module, it works as expected. I 
> don't know what would happen in external editors.
>
> To add to the confusion, if you catch and raise the exception, it works.
> This
> i = iter([0,1])
> for n in range(3):
> print n, next(i)
> fails silently:
> 0 0
> 1 1
> 2
>
> While this
> i = iter([0,1])
> for n in range(3):
> try:
> print n, next(i)
> except Exception as e:
> raise
> shows the unhandled exception:
> 0 0
> 1 1
> 2# Error: 
> # Traceback (most recent call last):
> #   File "", line 4, in 
> # StopIteration # 
>
>
> On Thursday, 12 October 2017 08:09:43 UTC+11, Robert White wrote:
>>
>> I can see StopIteration just fine in 2018 on windows.
>>
>> It should live in both __builtins__ and the exceptions module. 
>> Maybe some other script is messing those up?
>>
>> On Wednesday, October 11, 2017 at 3:23:57 PM UTC-5, Justin Israel wrote:
>>>
>>> Is this only in Windows? I just tested 2016, 2017, and 2018. They all 
>>> have StopIteration available.
>>>
>>> On Tue, Oct 10, 2017 at 7:40 PM Marcus Ottosson <konstr...@gmail.com> 
>>> wrote:
>>>
>>>> Can confirm that it is defined in 2018 as well. The above was in 2015. 
>>>> How peculiar.
>>>>
>>>> On 10 October 2017 at 07:22, Michael Boon <boon...@gmail.com> wrote:
>>>>
>>>>> Wow! Happens in 2016 too.
>>>>> However, StopIteration is defined, and I can catch it.
>>>>>
>>>>> This:
>>>>> a = iter([1,2])
>>>>> for i in range(4):
>>>>> print i, next(a)
>>>>> gives
>>>>> 0 1
>>>>> 1 2
>>>>> 2
>>>>>
>>>>> While this:
>>>>> a = iter([1,2])
>>>>> for i in range(4):
>>>>> try:
>>>>> print i, next(a)
>>>>> except StopIteration:
>>>>> print 'StopIteration'
>>>>> gives
>>>>> 0 1
>>>>> 1 2
>>>>> 2 StopIteration
>>>>> 3 StopIteration
>>>>>
>>>>>
>>>>> On Tuesday, 10 October 2017 00:03:12 UTC+11, Marcus Ottosson wrote:
>>>>>>
>>>>>> I remember having this a while back, but this time it really 
>>>>>> flabbergasted me.
>>>>>>
>>>>>> def iterator():
>>>>>> yield
>>>>>>
>>>>>> it = iterator()
>>>>>> next(it)
>>>>>> next(it)
>>>>>>
>>>>>> Or take this one.
>>>>>>
>>>>>> next(i for i in range(0))
>>>>>>
>>>>>> What should happen is this.
>>>>>>
>>>>>> Traceback (most recent call last):
>>>>>>   File "", line 1, in 
>>>>>> StopIteration
>>>>>>
>>>>>> But instead, nothing. It’s problem when this happens somewhere in 
>>>>>> your code.
>>>>>>
>>>>>> def create_transform():
>>>>>>   transform = cmds.createNode("transform", name="MyTransform")
>>>>>>   next(i for i in range(0))
>>>>>>   return transform
>>>>>>
>>>>>> transform = create_transform()
>>>>>> print(transform)# Error: name 'transform' is not defined# Traceback 
>>>>>> (most recent call last):#   File "", line 1, in # 
>>>>>> NameError: name 'transform' is not defined #
>>>>>>
>>>>>> It’s not defined, because that line never runs. An exception is 
>>>>>> thrown, silently, stopping the script.
>>>>>>
>>>>>> Other exceptions run fine.

Re: [Maya-Python] StopIteration, where art thou?

2017-10-11 Thread Robert White
I can see StopIteration just fine in 2018 on windows.

It should live in both __builtins__ and the exceptions module. 
Maybe some other script is messing those up?

On Wednesday, October 11, 2017 at 3:23:57 PM UTC-5, Justin Israel wrote:
>
> Is this only in Windows? I just tested 2016, 2017, and 2018. They all have 
> StopIteration available.
>
> On Tue, Oct 10, 2017 at 7:40 PM Marcus Ottosson  > wrote:
>
>> Can confirm that it is defined in 2018 as well. The above was in 2015. 
>> How peculiar.
>>
>> On 10 October 2017 at 07:22, Michael Boon > > wrote:
>>
>>> Wow! Happens in 2016 too.
>>> However, StopIteration is defined, and I can catch it.
>>>
>>> This:
>>> a = iter([1,2])
>>> for i in range(4):
>>> print i, next(a)
>>> gives
>>> 0 1
>>> 1 2
>>> 2
>>>
>>> While this:
>>> a = iter([1,2])
>>> for i in range(4):
>>> try:
>>> print i, next(a)
>>> except StopIteration:
>>> print 'StopIteration'
>>> gives
>>> 0 1
>>> 1 2
>>> 2 StopIteration
>>> 3 StopIteration
>>>
>>>
>>> On Tuesday, 10 October 2017 00:03:12 UTC+11, Marcus Ottosson wrote:

 I remember having this a while back, but this time it really 
 flabbergasted me.

 def iterator():
 yield

 it = iterator()
 next(it)
 next(it)

 Or take this one.

 next(i for i in range(0))

 What should happen is this.

 Traceback (most recent call last):
   File "", line 1, in 
 StopIteration

 But instead, nothing. It’s problem when this happens somewhere in your 
 code.

 def create_transform():
   transform = cmds.createNode("transform", name="MyTransform")
   next(i for i in range(0))
   return transform

 transform = create_transform()
 print(transform)# Error: name 'transform' is not defined# Traceback (most 
 recent call last):#   File "", line 1, in # 
 NameError: name 'transform' is not defined #

 It’s not defined, because that line never runs. An exception is thrown, 
 silently, stopping the script.

 Other exceptions run fine.

 1/0# Error: integer division or modulo by zero# Traceback (most recent 
 call last):#   File "", line 1, in # 
 ZeroDivisionError: integer division or modulo by zero #

 Normally, you can instantiate an exception yourself, like this.

 ZeroDivisionError# Result:  #

 But guess what happens for StopIteration?

 StopIteration# Error: name 'StopIterationError' is not defined# Traceback 
 (most recent call last):#   File "", line 1, in # 
 NameError: name 'StopIterationError' is not defined #

 This is in Maya 2015 and 2018, and I bet it happens in other versions 
 too. A native exception is undefined. What gives?
 ​

>>> -- 
>>> 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/e9c86276-76f3-48d3-bae9-db935b7cca60%40googlegroups.com
>>>  
>>> 
>>> .
>>> 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/CAFRtmOC6mFDTZgewPjbNNofn-8J1w55Fk7B2w5PYa4M18i9s4g%40mail.gmail.com
>>  
>> 
>> .
>> 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/75939951-c556-4851-8318-64fa3f2f028f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: python 2.7 v.1700 64 bit VC 2012 build

2017-10-02 Thread Robert White
You can always just use the mayapy.exe as your python build.

To get the libs/headers you'll need to download the proper devkit for your 
maya version.

On Monday, October 2, 2017 at 7:37:35 AM UTC-5, riga_rig wrote:
>
> Hello!
> Could you please point me on python 2.7 v.1700 64 bit VC 2012 build binary 
> anywhere in web?
> I found this  link How to build Python 2.7.5 using Visual Studio 2012 
> Express on Windows 8 64-bit , but it 
> needs VS 2012.
> I wonder if anybody has a proper binary python 2.7 for windows?
> Regards, 
> Oleg Solovjov
>

-- 
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/30ff8a69-13f4-4c12-b674-b7a86180c3a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: P4python doesn't work under maya 2017

2017-09-28 Thread Robert White
It should behave the same as any other version of P4Python. All I did was 
include the OpenSSL value, and compile it with a maya compatible compiler 
version.

On Thursday, September 28, 2017 at 11:07:22 AM UTC-5, todd@gmail.com 
wrote:
>
> hey Robert..is there any documentation on your compile?  like what syntax 
> its looking for and such, or do I have to do run("p4 command","files")
>
>
> On Thu, Sep 28, 2017 at 5:46 AM, Robert White <robert@gmail.com 
> > wrote:
>
>> Last job I was using the version that I've shared here 
>> <https://onedrive.live.com/?cid=de880f5659db1a15=DE880F5659DB1A15%2118925=folder,zip=!AEinLoalQenrHdE>,
>>  
>> I had tested it up through 2017, but it might work in 2018 as well (no 
>> promises on 2018).
>> It was compiled with OpenSSL-1.0.2c, so that should potentially help with 
>> your SSL version error.
>>
>> On Thursday, September 28, 2017 at 7:20:55 AM UTC-5, riga_rig wrote:
>>>
>>> Hi,
>>> I tried to access our perforce server from Maya 2017.
>>> from P4 import P4,P4Exception# Import the module
>>> p4 = P4()# Create the P4 instance
>>> #p4.host = "ssl:perforce:1666"
>>> p4.port = "ssl:perforce:1666"
>>> p4.user = "user_name"
>>> p4.password = "secret"
>>> p4.client = "my_workspace"# Set some environment variables
>>> p4.connect()
>>>
>>> It works good from  external python console, but in Script Editor I got 
>>> following error:
>>> # Error: line 1: [P4.connect()] Connect to server failed; check $P4PORT.
>>> # SSL library must be at least version 1.0.1.
>>> # Traceback (most recent call last):
>>> #   File "", line 8, in 
>>> #   File "C:\Program 
>>> Files\Autodesk\Maya2017\Python\lib\site-packages\P4.py", line 798, in 
>>> connect
>>> # P4API.P4Adapter.connect( self )
>>> # P4Exception: [P4.connect()] Connect to server failed; check $P4PORT.
>>> # SSL library must be at least version 1.0.1. # 
>>>
>>> I'm under Windows 10. P4Python was installed 
>>> from p4python-2017.1.1526044-cp27-cp27m-win_amd64.whl.
>>>
>>> Python version in Maya 2017:
>>> import sys
>>> sys.version
>>> # Result: 2.7.11 (default, Dec 21 2015, 22:48:54) [MSC v.1700 64 bit 
>>> (AMD64)]
>>>
>>> Do you have any ideas how to fix it?
>>> Is anybody uses Perforce P4Python lib from Maya?
>>> Regards,
>>> Oleg Solovjov
>>>
>>> -- 
>> 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/829fec84-43fd-4418-859e-d5611437b49e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/829fec84-43fd-4418-859e-d5611437b49e%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Todd Widup
> Creature TD / Technical Artist
> todd@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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/9d26e1e7-30de-4bb8-bf64-48ec85515ccf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: P4python doesn't work under maya 2017

2017-09-28 Thread Robert White
Last job I was using the version that I've shared here 
,
 
I had tested it up through 2017, but it might work in 2018 as well (no 
promises on 2018).
It was compiled with OpenSSL-1.0.2c, so that should potentially help with 
your SSL version error.

On Thursday, September 28, 2017 at 7:20:55 AM UTC-5, riga_rig wrote:
>
> Hi,
> I tried to access our perforce server from Maya 2017.
> from P4 import P4,P4Exception# Import the module
> p4 = P4()# Create the P4 instance
> #p4.host = "ssl:perforce:1666"
> p4.port = "ssl:perforce:1666"
> p4.user = "user_name"
> p4.password = "secret"
> p4.client = "my_workspace"# Set some environment variables
> p4.connect()
>
> It works good from  external python console, but in Script Editor I got 
> following error:
> # Error: line 1: [P4.connect()] Connect to server failed; check $P4PORT.
> # SSL library must be at least version 1.0.1.
> # Traceback (most recent call last):
> #   File "", line 8, in 
> #   File "C:\Program 
> Files\Autodesk\Maya2017\Python\lib\site-packages\P4.py", line 798, in 
> connect
> # P4API.P4Adapter.connect( self )
> # P4Exception: [P4.connect()] Connect to server failed; check $P4PORT.
> # SSL library must be at least version 1.0.1. # 
>
> I'm under Windows 10. P4Python was installed 
> from p4python-2017.1.1526044-cp27-cp27m-win_amd64.whl.
>
> Python version in Maya 2017:
> import sys
> sys.version
> # Result: 2.7.11 (default, Dec 21 2015, 22:48:54) [MSC v.1700 64 bit 
> (AMD64)]
>
> Do you have any ideas how to fix it?
> Is anybody uses Perforce P4Python lib from Maya?
> Regards,
> Oleg Solovjov
>
>

-- 
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/829fec84-43fd-4418-859e-d5611437b49e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] where is does maya source the python scripts from.

2017-09-14 Thread Robert White
So it looks like 2018.1 has potentially fixed this. I've not yet tried the 
update, but it made it onto the release notes.

On Friday, September 8, 2017 at 9:26:34 PM UTC-5, Robert White wrote:
>
> Also, a fun fact, starting with Maya 2017, the import paths are scrambled 
> during startup by maya.
>
> Basically they are doing:
>
> sys.path = list(set(sys.path) | set(os.environ.get('PYTHONPATH', 
> '').split(os.pathsep)))
>
> The idea is that they are trying to eliminate duplicates, which this does, 
> but because they are putting everything into sets, it scrambles the order.
>
>
> On Friday, September 8, 2017 at 8:23:24 PM UTC-5, Justin Israel wrote:
>>
>> Its set by Maya's default environment variables, which can be modified in 
>> the Maya.env
>>
>> https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Environment-Variables-File-path-variables-htm.html
>>
>> Specifically, the PYTHONHOME dictates the root for the python standard 
>> library being injected into the PYTHONPATH 
>>
>> On Sat, Sep 9, 2017, 1:05 PM jettam <justin...@gmail.com> wrote:
>>
>>> Would someone be able to tell me what file maya is sourcing to find this 
>>> list. For example if I type "import sys" "sys.path" I get a list of all the 
>>> folders maya looks in. 
>>>
>>> import sys
>>> sys.path
>>> # Result: ['',
>>>  'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\xgen\\scripts\\cafm',
>>>  'C:\\Program Files\\Autodesk\\Maya2017\\bin',
>>>  'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\MASH\\scripts\\MASH',
>>>  'C:\\Program 
>>> Files\\Autodesk\\Maya2017\\plug-ins\\bifrost\\scripts\\boss',
>>>  'C:\\solidangle\\mtoadeploy\\2017\\scripts',
>>>
>>> Thanks you. 
>>>
>>> -- 
>>> 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/126bafad-d182-49d3-b552-36932b6a1646%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/python_inside_maya/126bafad-d182-49d3-b552-36932b6a1646%40googlegroups.com?utm_medium=email_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/3b5969ac-65a0-4ae4-a9bc-45151ac0bf76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] couple of userSetup file questions.

2017-09-11 Thread Robert White
If you're interested in seeing how maya handles `userSetup.py`, the code 
exists here on windows (no clue on other platforms, but probably a similar 
location):
`c:\Program 
Files\Autodesk\Maya2018\Python\Lib\site-packages\maya\app\startup\basic.py`

One extra thing, if you set the `MAYA_SKIP_USERSETUP_PY` environment 
variable, no `userSetup.py` files will be executed. I don't know if there 
is a similar way to block `userSetup.mel`

On Monday, September 11, 2017 at 6:10:13 PM UTC-5, Robert White wrote:
>
> Maya will exec every single `userSetup.py` files that it finds on 
> `sys.path` during startup, into the `__main__` namespace, the GUI won't 
> exist yet, so any modifications you want to make to the interface need to 
> be wrapped in a function that is passed to `maya.utils.executeDeffered` 
> which will trigger during the next idle tick, at which point the GUI will 
> exist.
>
> At the end of startup, maya will then run the first `userSetup.mel` that 
> it finds on the MAYA_SCRIPT_PATH.
>
> So you can have multiple `userSetup.py` files, but only one 
> `userSetup.mel`.
>
>
>
> On Monday, September 11, 2017 at 6:04:29 PM UTC-5, Justin Israel wrote:
>>
>>
>>
>> On Tue, Sep 12, 2017 at 11:01 AM jettam <justin...@gmail.com> wrote:
>>
>>> Q1 .. Is it okay for Maya (2017) to load two userSetup files upon 
>>> launch, a .mel version and a .py version? 
>>>
>>>
>>> Q2. I am trying to get maya to auto load my 'see' module upon launch. So 
>>> I add this code to my userSetup.py  Unfortunately this doesnt work. Could 
>>> someone tell me what I am missing in this code.
>>>
>>> // PYTHON CONVENIENCE TOOL
>>> from see import see
>>>
>>
>> If I remember correctly, Maya would pick up the py file first if it 
>> exists, otherwise it would use the mel script (or visa versa?) but I 
>> believe you should only have one or the other.
>> That import statement looks correct to me, and it is similar to what I do 
>> in my own userSetup.py:
>>
>> import maya.cmds as cmds
>> import maya.OpenMaya as om
>>  
>>
>>>
>>>
>>> -- 
>>> 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/1b028a8e-5868-48f4-81c9-e79faf78145d%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/python_inside_maya/1b028a8e-5868-48f4-81c9-e79faf78145d%40googlegroups.com?utm_medium=email_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/5b88ad89-99cd-4651-9cf3-3484f02bc1a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] couple of userSetup file questions.

2017-09-11 Thread Robert White
Maya will exec every single `userSetup.py` files that it finds on 
`sys.path` during startup, into the `__main__` namespace, the GUI won't 
exist yet, so any modifications you want to make to the interface need to 
be wrapped in a function that is passed to `maya.utils.executeDeffered` 
which will trigger during the next idle tick, at which point the GUI will 
exist.

At the end of startup, maya will then run the first `userSetup.mel` that it 
finds on the MAYA_SCRIPT_PATH.

So you can have multiple `userSetup.py` files, but only one `userSetup.mel`.



On Monday, September 11, 2017 at 6:04:29 PM UTC-5, Justin Israel wrote:
>
>
>
> On Tue, Sep 12, 2017 at 11:01 AM jettam  
> wrote:
>
>> Q1 .. Is it okay for Maya (2017) to load two userSetup files upon launch, 
>> a .mel version and a .py version? 
>>
>>
>> Q2. I am trying to get maya to auto load my 'see' module upon launch. So 
>> I add this code to my userSetup.py  Unfortunately this doesnt work. Could 
>> someone tell me what I am missing in this code.
>>
>> // PYTHON CONVENIENCE TOOL
>> from see import see
>>
>
> If I remember correctly, Maya would pick up the py file first if it 
> exists, otherwise it would use the mel script (or visa versa?) but I 
> believe you should only have one or the other.
> That import statement looks correct to me, and it is similar to what I do 
> in my own userSetup.py:
>
> import maya.cmds as cmds
> import maya.OpenMaya as om
>  
>
>>
>>
>> -- 
>> 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/1b028a8e-5868-48f4-81c9-e79faf78145d%40googlegroups.com
>>  
>> 
>> .
>> 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/0240a306-5ed1-4402-80bc-089fe3fb15a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] where is does maya source the python scripts from.

2017-09-10 Thread Robert White
Try that with a userSetup.py instead of .mel. Otherwise, yes that should 
work.

On Sunday, September 10, 2017 at 7:49:40 PM UTC-5, jettam wrote:
>
> I made a userSetup.mel file, and placed it here: 
>  C:\Users\justin\Documents\maya\2017\scripts\userSetup.mel
> In this file I added this text: 
>
> *import sys*
> *sys.path.insert(0, "E:/ProfessionalDevelopment/python/Introduction to 
> Python Scripting in Maya/cgcircuitPython") *
>
> Should this work? When maya launches will it add this custom path to my 
> sys.path?   I ask because when maya opens I check to see if its there by 
> typing *import sys*and   *pprint(sys.path). *When I type this I 
> don't see my custom path in the name.
>
>>
>>>

-- 
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/741d23c0-3c84-4d1f-8a93-da491f116400%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] where is does maya source the python scripts from.

2017-09-09 Thread Robert White
Easiest place to places scripts while learning everything is in (if you're 
on windows) `C:/Users//documents/maya/2017/scripts`
No clue on other OS's off the top of my head though.


On Saturday, September 9, 2017 at 10:48:08 AM UTC-5, jettam wrote:
>
> I am using maya 2017.  Robert mentioned things work differently in maya 
> 2017. I am very new to scripting in Maya and could really do with some help 
> with this question. 
>
> I need to place my python modules in a custom path, and I am confused as 
> to where to put this custom path, so that maya will read it. 
>
> Do I put that custom path into my maya.env folder or into my 
> userSetup.mel.  The maya.env file existed but there is nothing in it!? and 
> the userSetup.met file does not exist, am I suppose to create this one? 
>
>


-- 
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/613ef293-c493-4225-9cfd-0c202b379ad6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] where is does maya source the python scripts from.

2017-09-08 Thread Robert White
Also, a fun fact, starting with Maya 2017, the import paths are scrambled 
during startup by maya.

Basically they are doing:

sys.path = list(set(sys.path) | set(os.environ.get('PYTHONPATH', 
'').split(os.pathsep)))

The idea is that they are trying to eliminate duplicates, which this does, 
but because they are putting everything into sets, it scrambles the order.


On Friday, September 8, 2017 at 8:23:24 PM UTC-5, Justin Israel wrote:
>
> Its set by Maya's default environment variables, which can be modified in 
> the Maya.env
>
> https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Environment-Variables-File-path-variables-htm.html
>
> Specifically, the PYTHONHOME dictates the root for the python standard 
> library being injected into the PYTHONPATH 
>
> On Sat, Sep 9, 2017, 1:05 PM jettam  
> wrote:
>
>> Would someone be able to tell me what file maya is sourcing to find this 
>> list. For example if I type "import sys" "sys.path" I get a list of all the 
>> folders maya looks in. 
>>
>> import sys
>> sys.path
>> # Result: ['',
>>  'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\xgen\\scripts\\cafm',
>>  'C:\\Program Files\\Autodesk\\Maya2017\\bin',
>>  'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\MASH\\scripts\\MASH',
>>  'C:\\Program 
>> Files\\Autodesk\\Maya2017\\plug-ins\\bifrost\\scripts\\boss',
>>  'C:\\solidangle\\mtoadeploy\\2017\\scripts',
>>
>> Thanks you. 
>>
>> -- 
>> 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/126bafad-d182-49d3-b552-36932b6a1646%40googlegroups.com
>>  
>> 
>> .
>> 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/e24f62ac-5133-4ccb-8806-049c86b8cc30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Get objects that are not uv

2017-07-20 Thread Robert White
If you need to avoid pymel for some reason:

from maya import cmds

def find_unmapped_meshes():
unmapped_meshes = []
for mesh in cmds.ls(type='mesh'):
uvs = cmds.polyListComponentConversion(mesh, toUV=True)
uvs = cmds.ls(uvs, fl=True)
if len(mesh) < 2:
unmapped_meshes.append(mesh)
return unmapped_meshes




On Thursday, July 20, 2017 at 3:04:56 PM UTC-5, Andres Weber wrote:
>
> There's probably a hundred ways to do this but here's one:
> import pymel.core as pm
> sel = pm.ls(sl=True)
> sel[0].getShape().getUVs()
>
> >>> ([], []) # This is empty/no UVs
> # Or you could do 
>
> sel[0].getShape().map
> # or
> sel[0].map
> # Empty objects should just return something like (depending on object 
> name)
> >>> pCubeShape2.map[0]
> Interested to see what other people come up with.  For completeness you 
> should probably also check all UV sets just in case...but you mentioned 
> that's not a constraint.
>
>
>
> On Thursday, July 20, 2017 at 3:02:49 PM UTC-4, likage wrote:
>>
>> Hi all,
>>
>> I have this model in which some of the geometries within are not uv-ed.
>> As in, you select the geometry >> open up uv editor >> it is blank.
>>
>> And so it is causing some problems with a script I am doing. Are there 
>> any ways in which I can use python to check for such geos with the blank 
>> uvs?
>>
>> FYI, there is only 1 uv set for this model.
>>
>

-- 
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/550c3316-19ba-4132-a215-09168d90d7c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Nearest Point On Mesh in Maya

2017-05-05 Thread Robert White
` is usually referred to as the backtick.

On Thursday, May 4, 2017 at 4:09:37 PM UTC-5, Michael Boon wrote:
>
> The little apostrophe character you're using should be `, not '
> On a US keyboard, that's the key above Tab. I don't know what it's called 
> (and I've never seen it used for anything other than MEL).
>
>
> On Thursday, 4 May 2017 18:04:24 UTC+10, Junaid Iqbal wrote:
>>
>> Hey guys, 
>> I need some help with the script. I have no idea about scripting. I am 
>> watching a tutorial for making grass in Maya 2016. I am at the point where 
>> I am trying to write the script where the grass faces the normals so the 
>> grass goes with the uneven surface of the land. Below is the code that is 
>> there in the script. Kindly let me know what is wrong as I keep getting the 
>> error "//Error: 4.15: Syntax error" 
>> the code I am writing is " vector $nrm = 'nearestPointOnMesh -1p ($p.x) 
>> ($p.y) ($p.z) -normal -q pPlane'; " 
>>
>> I am using nparticles and have added few expressions, everything else is 
>> working fine but when I add the above line the error appears. Is there 
>> another way to do this? please you can suggest and tutorial as well if 
>> anything available. 
>> Regards 
>> Junaid.
>
>

-- 
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/4693d98c-62c4-4599-9618-f871c2850967%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: PYTHON MAYA convert string u'001' to 001?

2017-04-17 Thread Robert White
Try it without the backticks around cmds.textField.


SBpath = 'G:\\ProjectPath\\'
import maya.cmds as cmds 
import os, glob, time

def buttonLGTPressed(*args):
EpisodeName = cmds.textField("Episode", query = True, text = True)
print EpisodeName
rootEp = SBpath + "{}\\".format(EpisodeName)
print(rootEp) # EXPECTED: G:\ProjectPath\*\241\ # RESULT: 
G:\ProjectPath\u'241'\

window = cmds.window(title = "Open Last scene", width = 150, height = 100)
cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'left', 0), 
columnWidth=[(1, 100), (2, 250)] )
cmds.textField( "Episode", text = "001")
cmds.button('OpenLGT', l="Open Last LGT scene", w=180, h=30, command=
buttonLGTPressed)
cmds.showWindow()


On Monday, April 17, 2017 at 8:29:59 AM UTC-5, gnn wrote:
>
> did someone know how to convert this result: u'001 in : 001
> To put it in a variable path: Z:\ProjectPath\001\
> By advance, thanks a lot for your help!! 
> 
>
> SBpath = 'G:\\ProjectPath\\'
> import maya.cmds as cmds 
> import os, glob, time
> 
> def buttonLGTPressed(*args):
> EpisodeName = `cmds.textField("Episode", query = True, text = True)`
> print EpisodeName
> rootEp = SBpath + "{}\\".format(EpisodeName)
> print(rootEp) # EXPECTED: G:\ProjectPath\*\241\ # RESULT: 
> G:\ProjectPath\u'241'\
>
> window = cmds.window(title = "Open Last scene", width = 150, height = 100)
> cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'left', 0), 
> columnWidth=[(1, 100), (2, 250)] )
> cmds.textField( "Episode", text = "001")
> cmds.button('OpenLGT', l="Open Last LGT scene", w=180, h=30, command=
> buttonLGTPressed)
> cmds.showWindow()
>
>
>
>

-- 
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/652a378e-1f2b-416e-81ea-c740fb9bfdfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Command flag in symbolButton keeps erroring for me

2017-03-14 Thread Robert White
Because maya expects you to pass either a string, or a callable to the 
command flag. 
When you don't wrap the function in a lambda, you're calling the function, 
and passing the result to the command flag.


On Tuesday, March 14, 2017 at 11:12:08 AM UTC-5, likage wrote:
>
> Try wrapping it in a lambda?
>> self.btn_add = cmds.symbolButton( width=60, height=20, annotation='Add 
>> object(s)', image='add.xpm', command=lambda *x: self.add_btn_callback(
>> "item_list") )
>>
>
> Okay, so it works. And my question is why? 
>

-- 
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/a7863132-255b-4bbf-b37b-5712fc9fafc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Command flag in symbolButton keeps erroring for me

2017-03-14 Thread Robert White
Try wrapping it in a lambda?
self.btn_add = cmds.symbolButton( width=60, height=20, annotation='Add 
object(s)', image='add.xpm', command=lambda *x: self.add_btn_callback(
"item_list") )

On Tuesday, March 14, 2017 at 10:59:37 AM UTC-5, likage wrote:
>
> While it works for the example, I tried applying the same concept into my 
> actual code, I am getting the errors..
> self.btn_add = cmds.symbolButton( width=60, height=20, annotation='Add 
> object(s)', image='add.xpm', command=self.add_btn_callback("item_list") )
>
> def add_btn_callback(self, "list"):
> # Do the exec when add button is clicked
>
>

-- 
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/6193d5e7-2ddd-4e1e-a822-0c3d35a8a1f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Rename all objects in list with name of an other lists

2017-02-23 Thread Robert White
for shader_name, new_name in zip(ShaderNames, newNames):
rename shader_name, new_name

On Thursday, February 23, 2017 at 11:53:08 AM UTC-6, Michał Frątczak wrote:
>
> smth like this...
>
> for i in xrange(len(ShaderNames)):
> rename ShaderNames[i]  NewNames[i]
>
>
> W dniu 2017-02-23 o 17:14, denis hoffmann pisze:
>
> Hey guys,
>
> I want to rename all shaders with names from a list.
>
> so I make a list of all shaders and a var with all names I want to have.
>
> ShaderNames = [u'Shader0', u'Shader1', u'Shader2', u'Shader3', u'Shader4', 
> u'Shader5']
>
> NewNames = ['Name1', 'Name2', 'Name3', 'Name4', 'Name5']
>
>
> what is the solution if I want to have my "Shader0"  new name is "Name1" 
>
> Thank You very mutch!!!
>
>
> -- 
> 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/a9ca5154-c746-4b35-8789-088d654186b0%40googlegroups.com
>  
> 
> .
> 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/0ca3db9c-bb43-43e1-9b3c-76fff114c999%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: MayaPy 2017 PythonInterpreter crash

2017-01-26 Thread Robert White
I've had the interpreter crash a lot on exit due to plugins not unloading 
cleanly. Might be worth trying it with all of them disabled?

On Thursday, January 26, 2017 at 5:22:45 AM UTC-6, Erik Karlsson wrote:
>
> Hi everyone!
>
> I'm trying to get maya 2017 up and working. But I'm having some issues.
> This time it's the mayapy.exe. It's not behaving the way it did in 2016. I 
> can't run it cleanly without a crash...
>
> I get a windows popup saying PythonInterpreter has stopped working.
>
> And this is the output from the commandline:
>
> i:\python\scripts>"c:\Program Files\Autodesk\Maya2017\bin\mayapy.exe" 
> testMayaPy.py
> [u'frontShape', u'perspShape', u'sideShape', u'topShape']
> Stack trace:
>   python27.dll!PyInterpreterState_Delete
>   python27.dll!PyGILState_Ensure
>   CommandEngine.dll!TpythonLock::initLock
>   ExtensionLayer.dll!TelfUtils::TelfUtils
>   ExtensionLayer.dll!TscriptAction::~TscriptAction
>   SharedUI.dll!TsetManipValueAction::callContext
>   SharedUI.dll!TelfIconTextButtonCmd::skipFlagForCreateCmd
>   SharedUI.dll!QmayaHotkeyEditor::qt_static_metacall
>   SharedUI.dll!QmayaHotkeyEditor::qt_static_metacall
>   ntdll.dll!RtlDeactivateActivationContextUnsafeFast
>   ntdll.dll!LdrShutdownProcess
>   ntdll.dll!RtlExitUserProcess
>   KERNEL32.DLL!ExitProcess
>   MSVCR110.dll!_initterm_e
>   KERNEL32.DLL!BaseThreadInitThunk
>   ntdll.dll!RtlUserThreadStart
>
>
> the python file "testMayaPy.py" I'm running is simple and looks like this:
>
> import maya.standalone
> maya.standalone.initialize(name='python')
>
> import maya.cmds as cmds
>
> print cmds.ls(type='camera')
>
> maya.standalone.uninitialize()
>
>
> It looks like the script runs fine but has troubles when exiting in 2017.
> In Maya 2016 everything works fine. I get this output:
>
> i:\python\scripts>"c:\Program Files\Autodesk\Maya2016\bin\mayapy.exe" 
> testMayaPy.py
> [u'frontShape', u'perspShape', u'sideShape', u'topShape']
>
>
> Anyone else having similar problems, and possibly a workaround?
>
> The idea is to batchprocess a bunch of maya files. But since I get a crash 
> for every file in the loop, I need to click the annoying "Interpreter has 
> stopped working" window for it to continue. So I managed to process 100 
> maya files with 100 clicks, which is not ideal...
>
> thanks!
> /Erik
>
>

-- 
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/ee83fec9-9835-424e-831e-e31573b01f9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] bakeresults in Python is super slow

2016-12-24 Thread Robert White
Also, preserveOutsideKeys used to cause some major slowdown in 2014/2015. I 
believe the bug was finally fixed in 2016, so that might be another culprit.


On Saturday, December 24, 2016 at 6:42:35 AM UTC-8, Jeremie Passerin wrote:
>
> Thanks Christopher, 
> I'll take a look that could be useful.
>
> I found what was the problem with my scene. It was the parallel evaluation 
> turned on. 
> I turned it off and things seem to work much better. I also suspended the 
> refreshing of the viewport, now I have some decent result.
>
> On Dec 24, 2016 06:10, "Christopher Crouzet"  > wrote:
>
>> Hey Gerem!
>>
>> I have no idea of what might be causing this slowdown with the Python 
>> version but I was curious to see how a quick and dirty custom 
>> implementation using the Maya API would fare, so I gave it a go. Here's the 
>> file: 
>> https://gist.github.com/christophercrouzet/e4daa884d4d4e08bce24addfe820af4d
>>
>> It is a very naive implementation and it is the first time that I'm using 
>> the `OpenMaya.MDGContext` object, so chances are high that the code 
>> isn't optimal and could be speeded up. Also I didn't test it at all outside 
>> of the scene that it generates, so it might be crippled with bugs. And in 
>> all fairness it doesn't implement all the features covered by the `
>> bakeResults` command, but still, it can be a starting point so give it a 
>> go to see if it helps. On my old laptop it takes 25 seconds to bake the 
>> animation on 6 attributes (pos + rot) for 500 locators over 400 frames. 
>> Maybe it'll be faster on your workstation?
>>
>> On a side note I'm currently working on a small library to help 
>> benchmarking code for Maya, maybe that'll interest someone around here?
>>
>>
>> On 24 December 2016 at 05:56, Jeremie Passerin > > wrote:
>>
>>> Hello Maya coders !
>>>
>>> I'm having a weird issue right now using the bakeresults command in Maya 
>>> 2016.5 (aka ext2)
>>> I've built a test scene with 500 locators constrained to 500 others that 
>>> have a simple animation on 400 frames (Parent Constraint)
>>>
>>> When I bake the animation to fcurve using the MEL
>>> It's done in a about 40s
>>> When I do it in Python it takes almost 5 minutes
>>> I had to set simulation to False in Python otherwise... it's taking even 
>>> longer... I wasn't able to get it to finish (I left it running for 2 hours)
>>>
>>> Any idea ? any tips on baking a bunch of controllers that are 
>>> constrained to something ? 
>>>
>>> *MEL*
>>> timer -s;
>>> bakeResults -simulation true -t "1:400" -sampleBy 1 
>>> -disableImplicitControl true -preserveOutsideKeys true -sparseAnimCurveBake 
>>> false -removeBakedAttributeFromLayer false -removeBakedAnimFromLayer false 
>>> -bakeOnOverrideLayer false -minimizeRotation true {"slave", [...], 
>>> "slave500"};
>>> timer -e;
>>> // Result: 25.241 // 
>>>
>>> *Python*
>>> from datetime import datetime as dt
>>> import maya.cmds as cmds
>>> start = dt.now()
>>> cmds.bakeResults("slave", [...], ["slave500"], 
>>> simulation=False,t=(0,400),sampleBy=1,disableImplicitControl=True,preserveOutsideKeys=True,sparseAnimCurveBake=False,removeBakedAttributeFromLayer=False,removeBakedAnimFromLayer=False,bakeOnOverrideLayer=False,minimizeRotation=True)
>>> print dt.now() - start
>>> >>> 0:04:44.691000
>>>
>>>
>>> Thanks, 
>>> Jeremie
>>>
>>>
>>> -- 
>>> 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/CAKq4km-qgWqQZpVMa9biYMuTTvSh8GiKdfM7y1xmNYZ%2BeivpKQ%40mail.gmail.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Christopher Crouzet
>> *https://christophercrouzet.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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/CANuKW50jH9F7t_2%3D3kyt27itqcK1q73ZOE4sV7KCx9z2L8KMNw%40mail.gmail.com
>>  
>> 
>> .
>> 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 

[Maya-Python] Re: finding plane normal to a vector

2016-11-08 Thread Robert White
http://mathonline.wikidot.com/point-normal-form-of-a-plane

Should just need the normal and a point.

On Tuesday, November 8, 2016 at 3:19:14 PM UTC-6, s...@weacceptyou.com 
wrote:
>
> Hello, 
>
> i was wondering if there was a quick way of finding the equation of a 
> plane normal to a vector in maya 
>
> say the vector is (3,5,1) and passing through point (2,4,5) 
>
> i was wondering if there was maybe a math command that could make this 
> easier 
>
>
> thanks, 
> Sam

-- 
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/5036f947-9e19-447f-bca0-9ae3196ea07e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Help with a closure in Maya and Python.

2016-10-28 Thread Robert White
What error exactly are you getting when you try that?


On Friday, October 28, 2016 at 12:50:46 PM UTC-5, Padraig Ó Cuínn wrote:
>
> Nope no difference
>
> On Friday, 28 October 2016 08:58:37 UTC-7, Robert White wrote:
>>
>> Does this work by chance?
>>
>> # File_1 
>> from file_2 import selection as sel
>>
>>
>> def create_window():
>> 
>>  def pushButton():
>>  sel()
>>
>>
>>
>> On Friday, October 28, 2016 at 10:46:26 AM UTC-5, Padraig Ó Cuínn wrote:
>>>
>>> Hi Marcus,
>>>
>>> I am trying to get to selection() which is in a maya code file, The UI 
>>> is built under a create_window() function, in a UI specific file. The 
>>> code is separated from the UI. 
>>>
>>> under create_window() I have another function nested in it for the 
>>> button to call selection() but it is not reaching due to the enclosure,
>>>
>>> File_1 
>>> from file_2 import selection as sel
>>>
>>>
>>> def create_window():
>>> 
>>>  def pushButton():
>>>  file_2.sel()
>>>
>>> File_2
>>> import pymel.core
>>>
>>>
>>> def selection():
>>> pymel.core.selection(n="transforms")
>>>
>>> as you can see there are two files and due to the closure I can't 
>>> execute the selection function. I know I could easily throw it under the 
>>> pushbutton inside the UI but i strictly want UI code alone and maya code 
>>> alone on another file. 
>>>
>>> Thanks again
>>>
>>

-- 
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/8fa92a6d-64d9-48bc-ad46-615ac0d1fa41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Help with a closure in Maya and Python.

2016-10-28 Thread Robert White
Does this work by chance?

# File_1 
from file_2 import selection as sel


def create_window():

 def pushButton():
 sel()



On Friday, October 28, 2016 at 10:46:26 AM UTC-5, Padraig Ó Cuínn wrote:
>
> Hi Marcus,
>
> I am trying to get to selection() which is in a maya code file, The UI is 
> built under a create_window() function, in a UI specific file. The code 
> is separated from the UI. 
>
> under create_window() I have another function nested in it for the button 
> to call selection() but it is not reaching due to the enclosure,
>
> File_1 
> from file_2 import selection as sel
>
>
> def create_window():
> 
>  def pushButton():
>  file_2.sel()
>
> File_2
> import pymel.core
>
>
> def selection():
> pymel.core.selection(n="transforms")
>
> as you can see there are two files and due to the closure I can't execute 
> the selection function. I know I could easily throw it under the pushbutton 
> inside the UI but i strictly want UI code alone and maya code alone on 
> another file. 
>
> Thanks again
>

-- 
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/a6ed571e-c9ef-4274-a263-cfd47d779837%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: How to use subprocess.Popen() with maya ?

2016-10-21 Thread Robert White
https://pymotw.com/2/subprocess/ is a really good rundown of working with 
the subprocess module.
In fact the site is full of tutorials for the entire std library.

On Friday, October 21, 2016 at 2:12:37 PM UTC-5, cyrill...@gmail.com wrote:
>
> Hello, 
>
> Anyone know how to use subprocess inside Maya ? 
> When i'm trying this code inside maya: 
>
> import subprocess 
>
> dirName = '/u/Users/TEST/' 
> xdg = subprocess.Popen(['xdg-open', dirName], stdout=subprocess.PIPE, 
> stdin=subprocess.PIPE, stderr=subprocess.PIPE) 
>
> It does nothing, but when I execute this code in a Linux script command it 
> works. 
>

-- 
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/d37ceba6-b760-4613-b9d0-bc6f3bd3405d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: succesfully adding to PYTHONPATH using Maya.env

2016-09-20 Thread Robert White
Usually the path separator is ; not ,

Not sure if that is the potential problem here or not.
I've stopped using the Maya.env file, and instead do any environment 
variable setup in a maya module definition file.
Some links:
http://docs.autodesk.com/MAYAUL/2013/ENU/Maya-API-Documentation/index.html?url=files/GUID-9E096E39-AD0D-4E40-9B2A-9127A2CAD54B.htm,topicNumber=d30e30995
http://around-the-corner.typepad.com/adn/2012/07/distributing-files-on-maya-maya-modules.html
http://techartsurvival.blogspot.com/2014/01/mayas-mildy-magical-modules.html

On Tuesday, September 20, 2016 at 3:22:00 PM UTC-5, smann wrote:
>
> Has  anyone been able to get the maya.env to add to an existing PYTHONPATH 
> ? 
>
> adding the MAYA_SCRIPT_PATH  is as easy as 
>
> MAYA_SCRIPT_PATH = %MAYA_SCRIPT_PATH%, c:/myWwnDir
>
> but doing the same with PYTHONPATH doesn't appear to be working. 
>
> PYTHONPATH = %PYTHONPATH% , c/myOwnDir/
>
> ( does not add to the PythonPath) 
>
>  I can certainly go and write some os.path.append  statements. but If 
> possible I'd like to be to keep it in the MAYA.env and easily distributed.
>
> thanks
>
> -=s
>
>

-- 
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/3719af33-044f-49d0-8120-574466b3566d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Installing Pillow for Maya 2016 / Python 3.6

2016-09-19 Thread Robert White
Are you on windows?
Because Maya (2013+) does not use the same C-runtime as standard python2.7 
on windows, which means you can't just reuse the same C-extensions between 
the two versions.
Usually you need to rebuild the library against the version(s) of Maya that 
you're planning to support. 

On Monday, September 19, 2016 at 9:42:18 AM UTC-5, francois bonnard wrote:
>
> I have stepped back to Python 2.7.12 with Pillow installed with pip.
>
> It worked with the Idle provide with Python, but in Maya :
>
> ImportError: file  line 5: No module named PIL # 
>
>
> Le samedi 17 septembre 2016 09:29:20 UTC+2, francois bonnard a écrit :
>>
>> Key guys
>>
>> I am looking for a way to install Pillow for Python 3.6 on Windows 10.
>>
>> There is a package to download on gitHub, but no exe files (just a basic 
>> tutorial on how to build it, which is a bit above my competencies)
>>
>> Any hep ?
>>
>> Thanks
>>
>> Fransua
>>
>>
>>
>>
>>

-- 
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/0e1b173f-52b3-4843-9811-1b6e0d04f304%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] ImageMagick and subprocess

2016-08-30 Thread Robert White
If you're running this from python, take a look 
at http://docs.wand-py.org/en/0.4.3/ .
I've not used it myself, but I've had a few people I trust recommend it.

On Tuesday, August 30, 2016 at 8:16:53 AM UTC-5, Cesar Saez wrote:
>
> Hi, 
> You have check imagemagick/whatever-app return codes by getting its 
> stdin/stdout/stderr pipes (check subprocess docs, it is straight forward).
>
> Cheers! 
>

-- 
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/0b50b86f-511c-4e3f-aa84-498cecfdbbd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Re-Direct print back to the Script Editor

2016-07-28 Thread Robert White
If you're on windows the following file is where the maya log handling 
stuff gets setup. Should be in a fairly similar place on other OSs

C:\Program Files\Autodesk\Maya2014\Python\Lib\site-packages\maya\utils.py

That should hopefully give you a starting point for how they're hooking 
into stdout/stderr and getting it to the script editor.
I honestly can't remember what I had done to get it logging to both a file 
and not interrupting the internal handler.

On Thursday, July 28, 2016 at 10:38:10 AM UTC-5, Aaron Carlisle wrote:
>
> I wrote a logging system that redefines XStream and directs stdout and 
> stderr to a Qt window so that I can also log output to a file (selectively).
>
> This broke the Python print statement and the output of that will no 
> longer show up in Maya's script editor.
>
> Is there a way to reset Maya's internal Python printing? They're obviously 
> doing something in the API because it include line endings and coloring 
> output, I'm just not sure how to re-initialize it.
>
> Any input would helpful!!
>
> Thanks!
>

-- 
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/25ac4db1-4fb4-4a73-87e7-9501ccd834b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: PyGame Installation

2016-02-16 Thread Robert White
You can't use compiled extension libraries from standard python27 with 
Maya's internal python interpreter.
You'll need to recompile the extension with Visual Studio 2012, because 
standard python27 is compiled against vs2008.


On Tuesday, February 16, 2016 at 10:10:58 PM UTC-6, Ruchit Bhatt wrote:
>
> Hi, Need help to install PyGame module for Maya 2016 x64.
>
> I downloaded 64bit PyGame Lib from Christoph Gohlke PY LIB 
> 
> site and i installed successfully in "C:\Python27" using "pip install 
> *.whl" command.
> After that i copied PyGame folder from "C:\Python27\Lib\site-packages" & 
> paste in "C:\Program Files\Autodesk\Maya2016\Python\Lib\site-packages".
>
> And then run import pygame in Maya script editor & got below error
> # Error: ImportError: file C:\Program 
> Files\Autodesk\Maya2016\Python\lib\site-packages\pygame\__init__.py line 
> 142: DLL load failed: The specified module could not be found. # 
>
>
> it works fine in python shell, only problem is inside Maya.
>

-- 
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/9b8f059a-a57d-4c60-a18c-245dc7eacb8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: need help with userSetup.py and calling a script that is mainly a class.

2016-02-15 Thread Robert White
Looks like your error is in your create_cam_class.py file, not in your 
userSetup.py, probably something in that file is trying to interact with 
the GUI outside of your evalDeferred call. 
You could probably try testing it by moving the import create_cam_class and 
from_cam_class import smRealCameras into your build_menu function, that way 
the import will be deferred along with the rest of the menu.



On Monday, February 15, 2016 at 2:09:21 PM UTC-6, md wrote:
>
> Hey Guys,
>
> I am building my own Maya menu through userSetup.py ... 
>
> I have written another python script which is basically just a pySide 
> class. I want to call this script from the menu created in userSetup.py.
>
> There is no main function .. just the class that gets instantiated at the 
> bottom of the script with the following code. The script runs fine when run 
> from the script editor.
>
> Any insight would be awesome.
>
> if __name__ == "__main__":
> 
> try:
> cam_ui.deleteLater()
> except:
> pass
> 
> cam_ui = smRealCameras()
> 
> try:
> cam_ui.create()
> cam_ui.show()
> except:
> cam_ui.deleteLater()
> traceback.print_exc()
>
>
> I get this error in the command window when Maya launches ...
>
> Failed to execute userSetup.py
> Traceback (most recent call last):
>   File 
> "K:\ifs\resources\3D_resources\workgroups\maya_workgroup\net_modules\sm_module\scripts\userSetup.py",
>  
> line 11, in 
> from create_cam_class import smRealCameras
>   File 
> "K:\ifs\resources\3D_resources\workgroups\maya_workgroup\net_modules\sm_module\scripts\create_cam_class.py",
>  
> line 36, in 
> class smRealCameras (QtGui.QDialog) :
>   File 
> "K:\ifs\resources\3D_resources\workgroups\maya_workgroup\net_modules\sm_module\scripts\create_cam_class.py",
>  
> line 37, in smRealCameras
> def __init__(self, parent=maya_main_window()):
>   File 
> "K:\ifs\resources\3D_resources\workgroups\maya_workgroup\net_modules\sm_module\scripts\create_cam_class.py",
>  
> line 33, in maya_main_window
> return wrapInstance(long(main_window_ptr), QtGui.QWidget)
> TypeError: long() argument must be a string or a number, not 'NoneType'
>
>
> ... here is my userSetup.py that builds the menu
>
> import traceback
>
> import maya.cmds as cmds
> import maya.mel as mel
> import maya.utils as utils
>
>  
>
> import sm_CreateProjectPlugin
>
> from sm_CreateProjectPlugin_Maya_v0003 import *
>
> import create_cam_class
> from create_cam_class import smRealCameras
>
> cmds.evalDeferred("build_menu()")
>
> def build_menu():
> if cmds.menu('sm_menu', exists=1):
> cmds.deleteUI('sm_menu')
> sm_menu = cmds.menu('sm_menu', parent='MayaWindow', tearOff=True, 
> allowOptionBoxes=True, label='[===my menu===]')
> cmds.menuItem( divider=True)
> cmds.menuItem(parent=sm_menu,  subMenu = True, label="Pipeline 
>   ")
> cmds.menuItem(l="create project", c = createProjectWindow)
> *cmds.menuItem(l ="real cams" c = smRealCameras)*
> cmds.menuItem(parent=sm_menu, divider=True)
> cmds.menuItem(parent=sm_menu, subMenu = True, label="Rendering", 
> enable=True)
> cmds.menuItem(label="setup passes")
> cmds.menuItem(label="render manager") 
> cmds.menuItem(parent=sm_menu, label="Modeling",enable=False)
> cmds.menuItem(parent=sm_menu, label="Lighting",enable=False)
> cmds.menuItem(parent=sm_menu, divider=True)
>
>
> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/5bc389eb-24fd-4a7c-9e20-cb89ec7db5db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] python modules

2016-02-11 Thread Robert White
I've got a build of Perforce that should work with both 2015 and 2016, its 
also compiled with a compatible version of openSSL if your server happens 
to require that.
https://onedrive.live.com/?cid=de880f5659db1a15=DE880F5659DB1A15%2118925=folder,zip=!AEinLoalQenrHdE




On Thursday, February 11, 2016 at 4:25:23 PM UTC-6, Antonio Govela wrote:
>
> Hey Justin, was this resolved? I have a similar issue with Python2.7 , P4 
> python  and Maya 2016.
> I can import P4 just fine through a python shell, but not through Maya, 
> I've added the path to my PYTHONPATH env variable with no luck.
> It seems to import P4.py and then in line 410 "import P4API" i get the DLL 
> load failed, cant find the specified file. Maybe it's compiled for the 
> wrong version? but how come I can run it through shell?
>
> Also how could I make P4Python accessible throughout the network to deploy 
> tools like animation exporters with P4 checkout options to other 
> workstations..
>
>  I also tried something like this:
> import sys
> path = "C:\\Python27\\Lib\\site-packages"
> if path not in sys.path:
> sys.path.append(path)
> import P4
>
> and I get this:
>
> # File "", line 9, in 
>
> # File "C:\Python27\Lib\site-packages\P4.py", line 410, in 
>
> # import P4API
>
> # ImportError: DLL load failed: The specified module could not be found. //
>
> but I can see the "P4API.pyd" in the folder ..:/
>
> Thanks!
>
> # File 
> "\\newcastle\Tools\SDK\Maya\Tools\Python27\Lib\site-packages\P4.py", line 
> 410, in 
>
> # import P4API
>
> # ImportError: DLL load failed: The specified module could not be found. //
>
>
> On Wednesday, January 6, 2016 at 4:28:25 PM UTC-8, Justin Israel wrote:
>>
>> Should be 64-bit for any of the recent versions of Maya. What should 
>> actually matter is that it is build with the matching compiler for the 
>> particular Maya version. 
>>
>> On Thu, Jan 7, 2016 at 1:03 PM Todd Widup  wrote:
>>
>>> hmm...ok, discussing with our engineers...is Maya's Python 32 or 64 bit?
>>>
>>> On Wed, Jan 6, 2016 at 3:51 PM, Todd Widup  wrote:
>>>
 ok.. will get our engineers to recompile the perforce tools

 On Wed, Jan 6, 2016 at 3:41 PM, Justin Israel  
 wrote:

> I'm not sure how Maya picks up external environments on Windows. But 
> you do have to expand its PYTHOPATH by some means to point at external 
> locations.
>
> As for your perforce module... compiled extensions have to be compiled 
> to match Maya. So you may have to rebuild it against Maya's own python.
>
>
> On Thu, Jan 7, 2016 at 12:10 PM Todd Widup  wrote:
>
>> so I have to set the lib/site-package path then would be nice if 
>> there was an easier way, lol.
>>
>> ok..now to figure out why standalong works fine for P4Python and why 
>> Maya Python wont load it due to some DLL error :(
>>
>>
>> On Wed, Jan 6, 2016 at 3:06 PM, Justin Israel  
>> wrote:
>>
>>> Did you update your Maya.env or your userSetup.py to include extra 
>>> paths?
>>>
>>> On Thu, Jan 7, 2016 at 12:05 PM Todd Widup  
>>> wrote:
>>>
 so Pip and P4python are already installed on my Python 27 install.. 
 my dirs for Python27 and Python27/Scripts are already in my path.  
 both of 
 course load and work fine in a standalone Python, but not in 
 Maya..Maya 
 does not see them..this is a more accurate question.

 How do you get Maya Python to see/use modules that are installed to 
 teh lib/site-package director of a python 27 install.  

 On Wed, Jan 6, 2016 at 1:55 PM, Todd Widup  
 wrote:

> ok, was hoping that would work for those..though there seems to be 
> an issue with the P4 one I got
>
>
> On Wed, Jan 6, 2016 at 1:50 PM, Justin Israel  > wrote:
>
>> Just add extra paths to your PYTHONPATH in the Maya.env or 
>> sys.path in userSetup.py?
>>
>> On Thu, Jan 7, 2016 at 10:44 AM Todd Widup  
>> wrote:
>>
>>> so...how do I get site packages, like Pip and P4Python installed 
>>> correctly for Maya Py to see and use?  
>>> can they just sit in the local system install and scripts 
>>> directory (the default Python27 install that is) or do they have to 
>>> be in 
>>> the Maya python dir int eh maya install dir?
>>>
>>>
>>> -- 
>>> Todd Widup
>>> Creature TD / Technical Artist
>>> to...@toddwidup.com
>>> todd@gmail.com
>>> www.toddwidup.com
>>>
>>> -- 
>>> You received this message because you are subscribed to the 
>>> Google Groups "Python 

Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Robert White
So maya doesn't play to nicely with virtualenv, has to do with how it 
packages the standard lib into a zip-file.
Now you can transfer pure python libraries from a standard python install's 
virtualenv, and then just place that onto maya's pythonpath.

So I use a version of pip that I've installed to my local maya environment, 
then I integrate them into our development and distribution setup myself. 
Artists then use our deployed packages on their local machines, and for 
that we piggy back on maya's module system.

I've also built my own local versions of Python that match maya's python 
build environment, at least on windows. So I've got copies of 2.7 build 
against VS2010 (Maya2014), and VS2012 (Maya2015/6). This has helped me when 
compiling extension modules for python such as the P4API and PySide/PyQt 
ect...


On Thursday, January 21, 2016 at 2:09:17 AM UTC-6, Fredrik Averpil wrote:
>
> I'm late to the party and have probably misunderstood what's going on 
> totally... but...
>
> I'd create a virtual environment outside of Maya, pip install into it and 
> then inside of Maya I would make the virtualenv's site-packages available. 
> This would leave the Maya installation intact.
>
> Is there a reason why you wouldn't want to go down such a route?
> Do you need to use modules which needs to be compiled during pip install?
>
> Cheers,
> Fredrik
>
>
> On Thu, Jan 21, 2016 at 9:01 AM Justin Israel  > wrote:
>
>> So,  what about Maya modules, which are meant to be distributed packages 
>> of code? 
>> Another option, what about distributing your tools with vendored 
>> dependencies bundled in? What if a given studio doesn't have an internet 
>> connection on the same machines as their production workstations? 
>>
>> On Thu, 21 Jan 2016 7:44 PM Paxton  
>> wrote:
>>
>>> I totally agree, but expecting small animation studios to learn the 
>>> intricacies of easy_install and pip in the context of Mayas python 
>>> interpreter is not realistic (in my experience). 
>>> Are there any other options for distributing tools (with dependencies) 
>>>  that don't involve programmers on the receiving end?
>>>
>>>
>>> On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton wrote:



 Hey Folks, 

 I am trying to download and install setup_tools, easy_install and 
 tinydb all from within mayas python interpreter..

 I'm pretty close, but it looks like the system command to run 
 ez-setup.py is not downloading the easy_install packages to mayas 
 site_packages directory, which is strange because the same command works 
 perfectly in the shell..

 So the system call reads like this: 
 /Applications/Autodesk/maya2016/Maya.app/Contents/bin/mayapy 
 /Users/paxtongerrish/downloads/ez_setup.py

 I am pointing mayas python interpreter at ez_setup.py

 When i punch this command into the shell, it downloads setup_tools to 
 mayas python site_packages directory... Great! :D

 However.. I need to have this all happen from inside mayas python 
 interpreter and it does not work when called from os.system or 
 subprocess.call

 Any help super appreciated..

 thanks!


 import os
 import sys
 import urllib2
 import subprocess

 setup_tools_address = 
 'https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py'
 downloads_directory = '%s/downloads' % os.getenv('HOME')

 if not os.path.exists(downloads_directory):
 os.makedirs(downloads_directory)

 def setup():
 url = setup_tools_address
 file_path = '%s/%s' % (downloads_directory, url.split('/')[-1])
 maya_py = maya_py_path()
 for p in download_url(url, file_path):
 print p
 system_command = '%s %s' % (maya_py, file_path)
 print '- sys command---  (only works in shell)--\n'
 print system_command
 print '\n--\n'
 #This system command works from shell, but not from python Maybe 
 superuser thing??
 #os.system(system_command)
 #sub process doesnt work either

 p = subprocess.Popen(system_command, shell=True, 
 stdout=subprocess.PIPE)
 for i in p.stdout.readline():
 sys.stdout.flush()
 print i
 add_eggs()
 from setuptools.command import easy_install
 easy_install.main(['tinydb'])
 add_eggs()
 import tinydb

 def download_url(url, file_path, block_size=2056):
 request = urllib2.urlopen(url)
 file_size = int(request.info()['Content-Length'])
 if not file_path:
 file_path = '%s/%s' % (os.getenv('HOME'), url.split("/")[-1])
 downloaded_chunk = 0
 with open(file_path, "wb") as f:
 while downloaded_chunk < file_size:
 chunk = 

Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Robert White
So I've not had any issues really using mayapy to handle compilation 
either. I was doing the custom build to potentially use it as a base for a 
CI/build system where I could avoid installing maya itself. Never did get a 
chance to finish the project, other issues came up and it keeps getting 
stuck in the middle of my queue.

As to how,  I found this walkthrough 
<http://www.p-nand-q.com/python/building-python-27-with-visual_studio.html>awhile
 
back, and adapted the process to work with VS2012. 

On Thursday, January 21, 2016 at 8:21:54 AM UTC-6, Marcus Ottosson wrote:
>
> I’ve also built my own local versions of Python that match maya’s python 
> build environment, at least on windows. So I’ve got copies of 2.7 build 
> against VS2010 (Maya2014), and VS2012 (Maya2015/6). This has helped me when 
> compiling extension modules for python such as the P4API and PySide/PyQt 
> ect…
>
> I’m curious, how come you compiled your own Python here, and didn’t use 
> mayapy? I’ve compiled packages with it before and can’t recall having any 
> issues with it.
> ​
>
> On 21 January 2016 at 14:16, Robert White <robert@gmail.com 
> > wrote:
>
>> So maya doesn't play to nicely with virtualenv, has to do with how it 
>> packages the standard lib into a zip-file.
>> Now you can transfer pure python libraries from a standard python 
>> install's virtualenv, and then just place that onto maya's pythonpath.
>>
>> So I use a version of pip that I've installed to my local maya 
>> environment, then I integrate them into our development and distribution 
>> setup myself. Artists then use our deployed packages on their local 
>> machines, and for that we piggy back on maya's module system.
>>
>> I've also built my own local versions of Python that match maya's python 
>> build environment, at least on windows. So I've got copies of 2.7 build 
>> against VS2010 (Maya2014), and VS2012 (Maya2015/6). This has helped me when 
>> compiling extension modules for python such as the P4API and PySide/PyQt 
>> ect...
>>
>>
>> On Thursday, January 21, 2016 at 2:09:17 AM UTC-6, Fredrik Averpil wrote:
>>>
>>> I'm late to the party and have probably misunderstood what's going on 
>>> totally... but...
>>>
>>> I'd create a virtual environment outside of Maya, pip install into it 
>>> and then inside of Maya I would make the virtualenv's site-packages 
>>> available. This would leave the Maya installation intact.
>>>
>>> Is there a reason why you wouldn't want to go down such a route?
>>> Do you need to use modules which needs to be compiled during pip install?
>>>
>>> Cheers,
>>> Fredrik
>>>
>>>
>>> On Thu, Jan 21, 2016 at 9:01 AM Justin Israel <justin...@gmail.com> 
>>> wrote:
>>>
>>>> So,  what about Maya modules, which are meant to be distributed 
>>>> packages of code? 
>>>> Another option, what about distributing your tools with vendored 
>>>> dependencies bundled in? What if a given studio doesn't have an internet 
>>>> connection on the same machines as their production workstations? 
>>>>
>>>> On Thu, 21 Jan 2016 7:44 PM Paxton <paxton...@gmail.com> wrote:
>>>>
>>>>> I totally agree, but expecting small animation studios to learn the 
>>>>> intricacies of easy_install and pip in the context of Mayas python 
>>>>> interpreter is not realistic (in my experience). 
>>>>> Are there any other options for distributing tools (with dependencies) 
>>>>>  that don't involve programmers on the receiving end?
>>>>>
>>>>>
>>>>> On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> Hey Folks, 
>>>>>>
>>>>>> I am trying to download and install setup_tools, easy_install and 
>>>>>> tinydb all from within mayas python interpreter..
>>>>>>
>>>>>> I'm pretty close, but it looks like the system command to run 
>>>>>> ez-setup.py is not downloading the easy_install packages to mayas 
>>>>>> site_packages directory, which is strange because the same command works 
>>>>>> perfectly in the shell..
>>>>>>
>>>>>> So the system call reads like this: 
>>>>>> /Applications/Autodesk/maya2016/Maya.app/Contents/bin/mayapy 
>>>>>> /Users/paxtongerrish/downloads/ez_setup.py
>>>>>

Re: [Maya-Python] Re: userSetup.py not running on startup

2015-11-24 Thread Robert White
You're right, it just has to be importable, so sys.path. I think I got my 
maya / python brains crossed there.

Also glad it got worked out!

On Tuesday, November 24, 2015 at 2:20:55 PM UTC-6, Justin Israel wrote:
>
>
>
> On Wed, Nov 25, 2015 at 8:47 AM Robert White <robert@gmail.com 
> > wrote:
>
>> So I just tested that in Maya2016 and it seemed to work fine. Remember 
>> that anything printed in a userSetup.py will most likely end up in the 
>> output window (which is minimized by default in 2016), and not in the 
>> script editor window once Maya is done loading. This is because 
>> userSetup.py is run before the various GUI elements have actually been spun 
>> up and initialized.
>>
>> Just in case, double check that the env variable MAYA_SKIP_USERSETUP_PY 
>> isn't set, and obviously that your userSetup.py is on the PYTHONPATH.
>>
>
> I didn't think it had to be on the PYTHONPATH if you use one of the 
> standard Maya location. Doesn't it just need to live in a maya "scripts" 
> directory? Either in the "shared/scripts" or "/scripts" locations?
>
>
>>
>> On Tuesday, November 24, 2015 at 1:15:19 PM UTC-6, Aren Voorhees wrote:
>>>
>>> Hey everyone,
>>>
>>> I'm trying to use the userSetup.py to do some imports whenever Maya is 
>>> started up (ex. import pymel.core as pm, import maya.cmds as cmds, etc).  
>>> However I can't seem to get the file to run on Maya's startup.  I know I've 
>>> done this before on a different computer without issue.  Even boiling it 
>>> down to something as simple as putting: print "Hello World" in userSetup.py 
>>> doesn't do anything.  
>>>
>>> Inside of Maya I've tried doing: 
>>>
>>> import sys
>>>
>>>
>>> for p in sys.path:
>>> print p
>>>
>>>
>>> Of course that gives me a list of paths...I've tried putting the 
>>> userSetup.py in many different of those places and still no luck.
>>>
>>> I also tried:
>>>
>>> print cmds.internalVar(usd=True)
>>>
>>> and putting userSetup.py there (which I had already tried earlier, but 
>>> hey, why not).
>>>
>>> I've also tried blowing away my maya.env file to make sure that wasn't 
>>> doing anything weird.  
>>>
>>> Any ideas?
>>>
>>> Thanks!
>>>
>> -- 
>> 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/86384880-5b5f-4c85-b60c-669b961c308d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/86384880-5b5f-4c85-b60c-669b961c308d%40googlegroups.com?utm_medium=email_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/b2eca0f5-d20d-4aef-9566-4d5adda208fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: userSetup.py not running on startup

2015-11-24 Thread Robert White
So I just tested that in Maya2016 and it seemed to work fine. Remember that 
anything printed in a userSetup.py will most likely end up in the output 
window (which is minimized by default in 2016), and not in the script 
editor window once Maya is done loading. This is because userSetup.py is 
run before the various GUI elements have actually been spun up and 
initialized.

Just in case, double check that the env variable MAYA_SKIP_USERSETUP_PY 
isn't set, and obviously that your userSetup.py is on the PYTHONPATH.

On Tuesday, November 24, 2015 at 1:15:19 PM UTC-6, Aren Voorhees wrote:
>
> Hey everyone,
>
> I'm trying to use the userSetup.py to do some imports whenever Maya is 
> started up (ex. import pymel.core as pm, import maya.cmds as cmds, etc). 
>  However I can't seem to get the file to run on Maya's startup.  I know 
> I've done this before on a different computer without issue.  Even boiling 
> it down to something as simple as putting: print "Hello World" in 
> userSetup.py doesn't do anything.  
>
> Inside of Maya I've tried doing: 
>
> import sys
>
>
> for p in sys.path:
> print p
>
>
> Of course that gives me a list of paths...I've tried putting the 
> userSetup.py in many different of those places and still no luck.
>
> I also tried:
>
> print cmds.internalVar(usd=True)
>
> and putting userSetup.py there (which I had already tried earlier, but 
> hey, why not).
>
> I've also tried blowing away my maya.env file to make sure that wasn't 
> doing anything weird.  
>
> Any ideas?
>
> Thanks!
>

-- 
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/86384880-5b5f-4c85-b60c-669b961c308d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Qmake: Error compiling qtforms from the Maya devkit [C++]

2015-11-18 Thread Robert White
Maya 2016 on windows uses VS2012 not 2013. So you'll need to install the 
other compiler. I believe there is a way to tell VS2013 to use older 
compilers, but I'm not sure how on earth to go about doing that.
Also if you don't want the entire VS2012 installation you should be able to 
use the Windows8 SDK instead, it contains the compilers and a command line 
shortcut to run everything in.


On Wednesday, November 18, 2015 at 3:26:45 PM UTC-6, Settoken wrote:
>
> Yes but no result. 
>
> Le mercredi 18 novembre 2015 21:40:14 UTC+1, Justin Israel a écrit :
>
> I don't know much about compiling on Windows, but that is telling you the 
> required version of Visual Studio, for compatibility with Maya 2016. I know 
> that when compiling Maya plugins, on Windows, you have to use the right 
> msvc version to match the particular Maya. 
>
> Aside from that, your error suggests missing includes. Have you tried 
> adding:   #include  
> to your plugin?
>
> On Thu, Nov 19, 2015 at 9:29 AM Settoken  wrote:
>
> Well I'm not sure about the compiler. I'm using the visual studio 2013 
> command prompt, QMAKESPEC is set on win32-msvc2010, and the Qt version is 
> the 4.8.6 shipping with Maya2016 and the devkit.
>
> I've found this 
> ,
>  
> but I don't really know what I'm supposed to do with that information. 
>
>
> Le mercredi 18 novembre 2015 19:43:31 UTC+1, Justin Israel a écrit :
>
> Are you using a compiler and Qt version that is compatible with Maya 2016?
>
> On Thu, 19 Nov 2015 5:12 AM Settoken  wrote:
>
> I'm trying to compile *qtforms* which is one of the Qt example plugins 
> provided by Autodesk with the Maya Devkit. It demonstrates 3 different ways 
> to integrate Qt in a maya plugin. 
>
> You can find it here: devkit plug-ins 
> 
>  
>
> I've been through several issues already but I am now stuck with errors 
> while compiling.Here is the output:
>
> C:\Program Files (x86)\Microsoft Visual Studio 12.0>cd 
> C:\Users\A\Documents\Visu
> al Studio 2013\Projects\qtForms
>
> C:\Users\A\Documents\Visual Studio 2013\Projects\qtForms>nmake -f Makefile.qt 
> re
> lease\qtForms.mll
> Microsoft (R) Program Maintenance Utility Version 12.00.21005.1Copyright (C) 
> Microsoft Corporation.  All rights reserved.
>
> qmake -makefile -o qtForms.mak qtForms.pro
> "C:\Program Files (x86)\Microsoft Visual Studio 
> 12.0\VC\BIN\nmake.exe" -
> nologo -f qtForms.mak
> "C:\Program Files (x86)\Microsoft Visual Studio 
> 12.0\VC\BIN\nmake.exe" -
> f qtForms.mak.Release
> C:\Autodesk\Maya2016\bin\moc.exe -DUNICODE -DWIN32 
> -DQT_NO_IMPORT_QT47_Q
> ML -DNDEBUG -D_WINDOWS -DNT_PLUGIN -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN 
> -DQT_XML_L
> IB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE 
> -DQT_H
> AVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT 
> -I"c:\Autodesk\Maya2016\include\QtUiTools" 
> -I"c:\Autodesk\Maya2016\include\QtCore" -I"c:\Autodesk\Maya2016\include
> \QtGui" -I"c:\Autodesk\Maya2016\include\QtXml" 
> -I"c:\Autodesk\Maya2016\include"-I"." -I"..\..\include" 
> -I"c:\Autodesk\Maya2016\include\ActiveQt" -I"release" -I"." 
> -I"c:\Autodesk\Maya2016\mkspecs\win32-msvc2012" -D_MSC_VER=1700 -DWIN32 qtFo
> rms.h -o release\moc_qtForms.cpp
> c:\Autodesk\Maya2016\bin\rcc.exe -name qtForms qtForms.qrc -o 
> release\qr
> c_qtForms.cpp
> cl -c -nologo -Zm200 -Zc:wchar_t /FD /GS -O2 -MD -Zi -W3 -w34100 
> -w34189
>  -GR -EHsc -DUNICODE -DWIN32 -DQT_NO_IMPORT_QT47_QML -DNDEBUG -D_WINDOWS 
> -DNT_PL
> UGIN -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN -DQT_XML_LIB -DQT_GUI_LIB 
> -DQT_CORE_LIB-DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT 
> -DQT_HAVE_SSE2 -DQT
> _THREAD_SUPPORT -I"c:\Autodesk\Maya2016\include\QtUiTools" 
> -I"c:\Autodesk\Maya2016\include\QtCore" 
> -I"c:\Autodesk\Maya2016\include\QtGui" -I"c:\Autodesk\Maya2016\include\QtXml" 
> -I"c:\Autodesk\Maya2016\include" -I"." -I"..\..\include" 
> -I"c:\Autodesk\Maya2016\include\ActiveQt" -I"release" -I"." 
> -I"c:\Autodesk\Maya2016\mk
> specs\win32-msvc2012" -Forelease\ @C:\Users\A\AppData\Local\Temp\nm81FD.tmp
> qtForms.cpp
> cl -c -nologo -Zm200 -Zc:wchar_t /FD /GS -O2 -MD -Zi -W3 -w34100 
> -w34189
>  -GR -EHsc -DUNICODE -DWIN32 -DQT_NO_IMPORT_QT47_QML -DNDEBUG -D_WINDOWS 
> -DNT_PL
> UGIN -DQT_DLL -DQT_NO_DEBUG -DQT_PLUGIN -DQT_XML_LIB -DQT_GUI_LIB 
> -DQT_CORE_LIB-DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT 
> -DQT_HAVE_SSE2 -DQT
> _THREAD_SUPPORT -I"c:\Autodesk\Maya2016\include\QtUiTools" 
> -I"c:\Autodesk\Maya2016\include\QtCore" 
> -I"c:\Autodesk\Maya2016\include\QtGui" -I"c:\Autodesk\Maya2016\include\QtXml" 
> -I"c:\Autodesk\Maya2016\include" -I"." -I"..\..\include" 
> -I"c:\Autodesk\Maya2016\include\ActiveQt" -I"release" -I"." 
> -I"c:\Autodesk\Maya2016\mk
> specs\win32-msvc2012" 

Re: [Maya-Python] pymel crashing maya.standalone

2015-11-12 Thread Robert White
So I've been running into this a lot with 2016. 

The fix I've been using is:
def crash_fix():
import maya.cmds as cmds
try:
cmds.quit()
except AttributeError:
pass
atexit.register(crash_fix)

I usually throw that in either userSetup.py or sitecustomize.py, mostly so 
I don't need to think about it.

>From what I remember when I tried to really dig into this, during shutdown 
maya is trying to run maya.app.finalize, but by the time it tries to run, 
the system seems to have unloaded whatever libraries that function is 
depending on. 



On Thursday, November 12, 2015 at 8:09:08 PM UTC-6, elrond79 wrote:
>
> Hmm... well, not sure I know exactly what's going on, because I can't 
> reproduce your issue on my linux box, but we've seen some similar stuff 
> before - basically, issues where when using 
> mayapy + maya.standalone.initialize(), maya fails to clean up properly on 
> exit, and segfaults.  It's an issue we've reported to autodesk before, 
> since it messes up the return code, but I don't think it's high on their 
> priority list to fix.
>
> A few things to try:
>
>- instead of importing pymel, import maya.cmds, and do something that 
>will trigger actual loading of some of the commands / libraries (maya.cmds 
>uses some fancy delayed loading stuff), and populate the scene, and see if 
>it still crashes on exit - ie:
>   - import maya.cmds
>   - maya.cmds.polyCube()
>- add these lines to your script:
>   - import pymel.internal.startup
>   - pymel.internal.startup.fixMayapy2011SegFault()  # we first 
>   encountered the problem in maya 2011, but it still happens as of 2015 
> at 
>   least...
>
> Even if the first non-pymel test doesn't trigger the crash, my guess is 
> it's still this same issue - it just may be a different library that 
> triggers the issue (libOpenMayaFX, or OpenMayaRender, etc).  Pymel may 
> import some of these to do some basic inspection stuff, which is why you 
> see the crash on import of pymel.
>
> Last thing you can try doing - instead of doing an explicit 
> maya.standalone.initialize(), simply import pymel.core.  This will trigger 
> maya.standalone.initialize() if it hasn't been done already, and also tries 
> to run a startup sequence that more closely mirrors that of a normal gui 
> maya session - for instance, come to think of it, I think it runs 
> pluginPrefs.mel (which maya.standalone doesn't do) - so it could be a 
> plugin that's causing problems. You can test that by executing that mel 
> script yourself...
>
> On Fri, Nov 13, 2015 at 11:11 AM Chad Vernon  > wrote:
>
>> Anyone with experience using pymel and maya.standalone experience any 
>> Fatal Errors when the process ends?  I don't have any experience with pymel 
>> and am looking into running a setup in standalone mode.
>>
>> # runtests.py
>> import maya.standalone
>> print 'initialize maya'
>> maya.standalone.initialize(name='python')
>> print 'done initialize maya'
>> import pymel.core as pm
>> print 'done import pymel'
>> # pm.i_hate_you()
>>
>> I've cleared my prefs, Maya.env, MAYA_SCRIPT_PATH, MAYA_MODULE_PATH, and 
>> PYTHONPATH variables to make sure there were no conflicts.  This is what 
>> happens:
>>
>> C:\Users\cvernon\Documents\Development>"C:\Program 
>> Files\Autodesk\Maya2015\bin\mayapy.exe" runtests.py
>> initialize maya
>> done initialize maya
>> pymel.internal.startup : DEBUG : startup.mayaInit: called
>> pymel.internal.startup : DEBUG : startup.mayaInit: maya already started - 
>> exiting
>> pymel.internal.factories : DEBUG : Loading api cache...
>> pymel.internal.startup : DEBUG : Loading the API cache from u'C:\\Program 
>> Files\\Autodesk\\Maya2015\\Python\\lib\\site-packages\\pymel\\cache\\mayaApi2015.zip'
>> pymel.internal.startup : DEBUG : Loading the API-MEL bridge from 
>> 'C:\\Program 
>> Files\\Autodesk\\Maya2015\\Python\\lib\\site-packages\\pymel\\cache\\mayaApiMelBridge.zip'
>> pymel.internal.factories : DEBUG : Initialized API Cache in in 0.22 sec
>> pymel.internal.factories : DEBUG : Loading cmd cache...
>> pymel.internal.startup : DEBUG : Loading the list of Maya commands from 
>> u'C:\\Program 
>> Files\\Autodesk\\Maya2015\\Python\\lib\\site-packages\\pymel\\cache\\mayaCmdsList2015.zip'
>> pymel.internal.factories : DEBUG : Initialized Cmd Cache in in 0.13 sec
>> pymel.core.uitypes : DEBUG : could not determine node type for AETemplate
>> pymel.internal.factories : DEBUG : MFnDagNode.model is deprecated
>> pymel.core : DEBUG : Adding pluginLoaded callback
>> pymel.core : DEBUG : Adding pluginUnloaded callback
>> pymel.internal.startup : DEBUG : finalizing
>> pymel.internal.startup : DEBUG : initMEL
>> pymel.internal.startup : DEBUG : running: createPreferencesOptVars.mel
>> pymel.internal.startup : DEBUG : running: createGlobalOptVars.mel
>> pymel.internal.startup : DEBUG : running: 
>> C:/Users/cvernon/Documents/maya\2015-x64\prefs\userPrefs.mel
>> pymel.internal.startup : 

[Maya-Python] Re: mel global vars

2015-10-21 Thread Robert White
Should be the melGlobals object.
It works like a dict

So this should work

import pymel.core as pm
pm.melGlobals['$gShelfTopLevel']
# Result: 'MayaWindow|toolBar2|MainShelfLayout|formLayout14|ShelfLayout' # 




On Wednesday, October 21, 2015 at 12:51:33 PM UTC-5, todd@gmail.com 
wrote:
>
> does pyMel store/add the maya global vars anyplace?  
> globals like $gShelfForm or $gShelfTopLevel, etc
>
> -- 
> Todd Widup
> Creature TD / Technical Artist
> to...@toddwidup.com 
> todd@gmail.com 
> www.toddwidup.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/b7d728a6-24d2-409f-8042-98f53a1ce442%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Procedurally determining the number of submenus

2015-10-09 Thread Robert White
So, subMenus are really just menus, which means you can query the itemArray 
value and get a list of their children, if that list is empty, you've got 
an empty subMenu. 

I've got an example of how to search a top level menu recursively and 
return a list of all the empty subMenus:
https://gist.github.com/bob-white/322e0e77f8d21468b8e2

One annoyance with the itemArray query, is that it returns the short name 
of the menuItem, so you need to combine it with it's parent to query any of 
it's children. But otherwise it just works.

On Thursday, October 8, 2015 at 8:36:32 PM UTC-5, Ken Ibrahim wrote:
>
> Silly question here but I haven't figured this out yet nor come across the 
> answer online.
>
> What's the best way to determine the number of submenus a menuItem has 
> after it's been created? I have a system that dynamically adds menu items 
> based on certain criteria. After that work is done I'd like to disable the 
> menu (or remove it) if the total number of children is zero.
>
> Assume that I cannot get the number of items explicitly before creating 
> the menu and that I'm using PyMEL's "with" nested structure to create the 
> menu hierarchy.
>
> Thx!
>
> Ken
>
> -- 
> "God is a metaphor for a mystery that absolutely transcends all human 
> categories of thought. It's as simple as that!" - Joseph Campbell
>

-- 
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/ed6170c2-5521-41c3-9c59-45f9b58e1895%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: Procedurally determining the number of submenus

2015-10-09 Thread Robert White
Your not overlooking anything, MenuItem, and CommandMenuItem don't have the 
same methods on them that Menu does. Basically MenuItems and 
CommandMenuItems can't have any children, because they aren't Menus, but 
once you've set subMenu=True, the item returned is now a Menu, it can 
possibly have children.

So another thing you could attempt, would be just duck typing the whole 
affair by wrapping your call to getNumberOfItems() in a try / except block 
that catch's AttributeErrors, these would obviously fail on 
MenuItems/CommandMenuItems, but would return properly for Menus, this would 
let you continue to use the PyMel convenience methods, and is certainly 
considered 'pythonic'.

On Friday, October 9, 2015 at 12:11:32 PM UTC-5, Ken Ibrahim wrote:
>
> Correct, I only know after the fact.
>
> I got it working by running the following: pm.menu(my_menu, q=True, 
> numberOfItems=True)
>
> I was trying to be more Pythonic via PyMEL by running this: 
> my_menu.getNumberOfItems() but that method apparently doesn't exist for the 
> menu item (which is of type commandMenuItem I think). Again I must be 
> overlooking something silly in my access attempt here.
>
> On Fri, Oct 9, 2015 at 9:57 AM, Marcus Ottosson <konstr...@gmail.com 
> > wrote:
>
>> Just to perhaps state the obvious, I suppose ideally you would look at 
>> the items you are *about* to create and determine whether or not to create 
>> the menu in the first place, but maybe that's not an option in this case?
>>
>> On 9 October 2015 at 18:02, Kenneth Ibrahim <kenib...@gmail.com 
>> > wrote:
>>
>>> Thx for the response. I had thought that was the case and had tried 
>>> using PyMEL's 'getNumberOfItems' method to no avail. I'll have a look at 
>>> your code reference and see what I was doing wrong.
>>>
>>> Cheers! Ken
>>>
>>> On Fri, Oct 9, 2015 at 12:03 AM, Robert White <robert@gmail.com 
>>> > wrote:
>>>
>>>> So, subMenus are really just menus, which means you can query the 
>>>> itemArray value and get a list of their children, if that list is empty, 
>>>> you've got an empty subMenu. 
>>>>
>>>> I've got an example of how to search a top level menu recursively and 
>>>> return a list of all the empty subMenus:
>>>> https://gist.github.com/bob-white/322e0e77f8d21468b8e2
>>>>
>>>> One annoyance with the itemArray query, is that it returns the short 
>>>> name of the menuItem, so you need to combine it with it's parent to query 
>>>> any of it's children. But otherwise it just works.
>>>>
>>>> On Thursday, October 8, 2015 at 8:36:32 PM UTC-5, Ken Ibrahim wrote:
>>>>>
>>>>> Silly question here but I haven't figured this out yet nor come across 
>>>>> the answer online.
>>>>>
>>>>> What's the best way to determine the number of submenus a menuItem has 
>>>>> after it's been created? I have a system that dynamically adds menu items 
>>>>> based on certain criteria. After that work is done I'd like to disable 
>>>>> the 
>>>>> menu (or remove it) if the total number of children is zero.
>>>>>
>>>>> Assume that I cannot get the number of items explicitly before 
>>>>> creating the menu and that I'm using PyMEL's "with" nested structure to 
>>>>> create the menu hierarchy.
>>>>>
>>>>> Thx!
>>>>>
>>>>> Ken
>>>>>
>>>>> -- 
>>>>> "God is a metaphor for a mystery that absolutely transcends all human 
>>>>> categories of thought. It's as simple as that!" - Joseph Campbell
>>>>>
>>>> -- 
>>>> 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/ed6170c2-5521-41c3-9c59-45f9b58e1895%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/python_inside_maya/ed6170c2-5521-41c3-9c59-45f9b58e1895%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>&

Re: [Maya-Python] List referenced files

2015-08-11 Thread Robert White
So if you want the texture file nodes in the scene, you can get them from 
pymel with:

import pymel.core as pm
file_nodes = pm.ls(type=pm.nt.File)
file_paths = [fyle.fileTextureName.get() for fyle in file_nodes]

with cmds:
import maya.cmds as cmds
file_nodes = cmds.ls(type='file')
file_paths = [cmds.getAttr(fyle + '.fileTextureName') for fyle in 
file_nodes]

Unresolved reference paths can be gotten pretty easy in pymel :
unresolved_paths = [ref.unresolvedPath() for ref in pm.listReferences()]

with cmds:
[cmds.referenceQuery(pth, unresolvedName=True, filename=True) for pth in  
cmds.file(q=True, reference=True)]



On Tuesday, August 11, 2015 at 10:59:47 AM UTC-5, Marcus Ottosson wrote:

 I’m looking for a way to list all nodes that somehow reference an external 
 file; be it references, textures, or some obscure custom node with an 
 attribute for paths.

 I was looking at the cmds.filePathEditor 
 http://help.autodesk.com/cloudhelp/2015/ENU/Maya-Tech-Docs/CommandsPython/filePathEditor.html
  
 which is close.

  cmds.filePathEditor(query=True, listDirectories=)
 [list of paths]

 But it doesn’t show me which nodes are responsible for these paths, and 
 doesn’t show me the full filenames.

 Any ideas?
 ​
 -- 
 *Marcus Ottosson*
 konstr...@gmail.com javascript:


-- 
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/a0cfa12a-90cb-4890-8e3f-6b46cfc34ffd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: Simple program with complicated problem! InternalVar issue?

2015-08-10 Thread Robert White
Or, if you're like me and don't ever remember how the %s formatting works:

imagePath={pth}icons/staircon.jpg.format(pth=mc.internalVar(userPrefDir=True))

or better yet, because it's a file path:

import os
imagePath= os.path.join(mc.internalVar(userPrefDir=True), 'icons', 
'staircon.jpg')

That last one is often best, because it will handle os specific things like 
whether directories are split by '/' or by '\'.

On Monday, August 10, 2015 at 3:49:34 PM UTC-5, larry wrote:

 *I would use python string formatting instead of the  + operator.*

 *Try something like:*

 *imagePath=%sicons/staircon.jpg%**mc.internalVar(userPrefDir=True)*


 *instead of:imagePath = mc.internalVar(userPrefDir=True) 
 +'icons/stairIcon.jpg'*

 *More info:*


 *http://www.diveintopython.net/native_data_types/formatting_strings.html 
 http://www.diveintopython.net/native_data_types/formatting_strings.html*

 On Mon, Aug 10, 2015 at 9:13 AM, Kate Sendall kate.alic...@googlemail.com 
 javascript: wrote:

 Are you kidding me? That's it! Thank you so much, haha. I was using an 
 american set keyboard and a small screen. The two obviously don't mix well.

 Perfect answer.

 On Sunday, August 9, 2015 at 4:41:43 PM UTC+1, ABHIRAJ KK wrote:

 *Hi, kate *

 *check the icons i in ur code i think u have used some special 
 characters *

 *imagePath = mc.internalVar(userPrefDir=True) +'icons/stairIcon.jpg'*
 *mc.image(image=imagePath)*

 -- 
 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 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/python_inside_maya/8d601779-da77-4d79-9c5c-704583697a91%40googlegroups.com
  
 https://groups.google.com/d/msgid/python_inside_maya/8d601779-da77-4d79-9c5c-704583697a91%40googlegroups.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/0e34b1fe-7332-443c-bb05-662d20ea3892%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Any Python IDE that works similar to Maya's script editor?

2015-06-05 Thread Robert White
Sounds like you're looking for more of a live coding environment than an 
IDE.
The thing to keep in mind with Maya is that you're sort of dealing with a 
constantly running interpreter, not a development environment.

Happily though there are some python tools that do work similarly.
I use iPython http://ipython.org/ a lot, it has an enhanced interpreter 
mode, a Qt based console mode (which is an extra pretty interpreter + 
toys), and then the notebook web interface mode. That one is rather awesome 
to work with as you can rerun cells at any time, much like the hightlight 
+ run option you get inside maya.

Another enhanced interpreter you can try out is dreampie 
http://www.dreampie.org/, the interface looks more like Maya's with the 
split between a space for entering code, and a space for results. It can be 
a bit finicky about comments and docstrings when doing huge copy / pastes, 
and I can't remember if you can do partial execution (its been a few years 
since the last time I used it).

And of course there is also the option of doing work in a IDE / editor, and 
using Maya's commandport to send code over. Justin's MayaSublime package is 
pretty awesome for this, and I know someone has made a similar set of tools 
for both PyCharm and Eclipse.


On Thursday, June 4, 2015 at 10:51:00 PM UTC-5, Panupat Chongstitwattana 
wrote:

 I really enjoy how the scripting in Maya is like 1 continuous session. 
 Meaning I can import something once and keep on running its method over and 
 over. Also enjoy how I can high light parts of my code and execute only 
 that without losing the code.

 Any IDE out there that offers similar functionality?


-- 
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/55504857-d585-4de2-856c-14951042d991%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Thread with callback

2015-03-26 Thread Robert White
If you're worried about event handlers keeping callback objects alive when 
they should have already been wiped out.

Use the weakref module.

They have a pretty good example at 
http://code.activestate.com/recipes/578298-bound-method-weakref/.

I ended up using a variation of this for my MSceneMessage handler system. 
Been working really well for me.

On Wednesday, March 25, 2015 at 2:59:41 PM UTC-5, Justin Israel wrote:

 If I remember correctly, the original motivation for my version was that I 
 encountered an issue with callbacks where they were methods of objects that 
 could be deleted before the callback gets a chance to run, and the fact 
 that holding a reference to the methods would prevent garbage collection 
 (which also triggers signal/slot auto cleanup, etc). So I had come across 
 some information about weakref callbacks. I made some modifications to some 
 examples I had found. The result is that you can use bound methods as 
 callbacks, and run your initial logic through a thread pool. Then the 
 callback will be executed in the main thread, but can quietly fail if the 
 owning object was deleted. And it won't hold a reference to the owning 
 object. 


 On Thu, Mar 26, 2015 at 8:11 AM Justin Israel justin...@gmail.com 
 javascript: wrote:

 This looks kind of similar to something I did a while back 

 https://gist.github.com/justinfx/6183367

 We even both use the term invoke  :-) 
 Mine uses a posted event to the main loop instead of signals and slots. 
  
 On Thu, 26 Mar 2015 7:39 AM Marcus Ottosson konstr...@gmail.com 
 javascript: wrote:

 Hi all,

 I threw something together on a whim and would like your opinion of it.

 Inspired by JavaScript and it’s use of callbacks for IO-bound functions:

 expensiveFunction(argument, function(result) {
 console.log(The results are:  + result);
 })

 I did this.

 def callback(result):
 print The results are: %s % result

 invoke(expensive_function, callback)

 Code here:
 https://gist.github.com/mottosso/c20df396f4ecc882b53c

 Question is, is there already a way of doing this? If not, what could be 
 made better, faster, stronger? I’m calling it “invoke” but I’m sure there’s 
 already an established term for it, do you know of any?

 Best,
 Marcus
 ​
 -- 
 *Marcus Ottosson*
 konstr...@gmail.com javascript:
  
 -- 
 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 
 javascript:.
 To view this discussion on the web visit https://groups.google.com/d/
 msgid/python_inside_maya/CAFRtmOD6jDvWtY39eBEbQVU95HB2T
 0wF89GHeXSAdHEnUn5yDA%40mail.gmail.com 
 https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD6jDvWtY39eBEbQVU95HB2T0wF89GHeXSAdHEnUn5yDA%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/fa3f0627-14a3-43bf-95b9-9ed02bc4d4fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Basic question about pyMel

2015-03-24 Thread Robert White

Nope this wouldn't work:

pm.ls(type='camera')[0].pm.getParent().pm.getTranslation().z


Instead you'd need:

pm.ls(type='camera')[0].getParent()..getTranslation().z


Its only the initial function that gets prefixed with the module namespace.

On Monday, March 23, 2015 at 12:59:00 PM UTC-5, Simon Davies wrote:

 Hi all,

 I understand that if I import pyMel into Maya like this:

 from pymel.core import *

 I can then build up pyMel functions like this:

 ls(type='camera')[0].getParent().getTranslation().z


 However if I import pyMel with a name space instead:

 import pymel.core as pm

 Would the pyMel methods above all need prefixing with pm like this?

 pm.ls(type='camera')[0].pm.getParent().pm.getTranslation().z


 The above code doesn't work, so how should it be written if I import pymel 
 as pm?

 Thanks a lot.


-- 
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/c4f4b6ff-427c-462a-a31f-d4be95354cf2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Fun fact

2014-11-27 Thread Robert White
I did a quick scan of my codebase and while I know I used it in the past it 
looks like I'm no longer using executeInMainthreadWithResult anywhere.

So it looks like I've been surviving on just doing executeDeferred. 

And the major places that I am triggering it all seem to fall into a few 
scenarios,
1) Setting up some GUI stuff during startup.
2) Updating GUIs (which can be a hacky way of getting results back to the 
main thread) 
3) And with some of my callbacks built around the MSceneMessages, because 
blocking during those events can be super painful. And sometimes maya 
crashes without it.

On Sunday, November 23, 2014 3:58:18 AM UTC-8, Marcus Ottosson wrote:

 I’ve had good luck with it for simple tasks like updating GUIs.

 Ah, are you then also calling executeDeferred() from a separate thread, 
 without first wrapping it into a executeInMainThreadWithResult?
 ​

 On 21 November 2014 at 16:39, Robert White robert@gmail.com 
 javascript: wrote:

 I've had good luck with it for simple tasks like updating GUIs.

 I also use it as part of my startup sequence for any tasks that need to 
 build/tweak/change maya's default GUIs, because not enough of the maya 
 environment is loaded during userSetup.py's execution. But if you defer 
 those tasks, the idle queue won't be processed until after maya is done 
 loading, and by then if the GUI isn't there, you've got bigger problems.



 On Friday, November 21, 2014 10:03:14 AM UTC-6, Marcus Ottosson wrote:

 Thanks, Robert. Makes sense now.

 Which is why this does work if you just use executeDeferred(), which 
 doesn’t block in the same way.

 Do you have experience with this across threads? Since it doesn’t return 
 anything it’s a little tricky as a replacement, but if it’s thread-safe 
 then I’ll certainly keep it in mind.
 ​

  -- 
 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 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/python_inside_maya/30006d28-8193-4db8-b85b-a38cbf6e7964%40googlegroups.com
  
 https://groups.google.com/d/msgid/python_inside_maya/30006d28-8193-4db8-b85b-a38cbf6e7964%40googlegroups.com?utm_medium=emailutm_source=footer
 .

 For more options, visit https://groups.google.com/d/optout.




 -- 
 *Marcus Ottosson*
 konstr...@gmail.com javascript:
  

-- 
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/c865f731-dc1c-402b-bacf-9ed9529ea51f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Fun fact

2014-11-21 Thread Robert White


The script or callable object is executed in the main thread during the 
next idle event. The thread callingexecuteInMainThreadWithResult() blocks 
until the main thread becomes idle and runs the code. Once the main thread 
is done executing the code, executeInMainThreadWithResult() returns the 
result. If executeInMainThreadWithResult() is called from the main thread, 
then it simply runs the code immediately and returns the result.

Because idle events are being used to implement 
executeInMainThreadWithResult(), it is not available in batch mode. 

This is 
from 
http://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Python-Python-and-threading-htm.html

So yeah, basically by nesting these you end up in a situation where you've 
blocked the main thread, waiting for a result, and because its blocked, it 
can't process the idle queue to get that result.

Which is why this does work if you just use executeDeferred(), which 
doesn't block in the same way.

On Friday, November 21, 2014 9:24:13 AM UTC-6, Marcus Ottosson wrote:

 Could it be that the inner call is waiting for the outer call to finish, 
 before it can start? And because it never starts, the outer call is never 
 finished?

 On 21 November 2014 14:06, Marcus Ottosson konstr...@gmail.com 
 javascript: wrote:

 That would have been acceptable, but it actually locks Maya up when used 
 from within a thread as well. Seems no matter how I twist and turn, that 
 call called from within another call locks Maya up.

 On 21 November 2014 12:46, Eduardo Grana eduard...@gmail.com 
 javascript: wrote:

 Hey Marcus,

 Maybe it's like nuke's similar command, that is only meant to be used 
 inside other threads, and not the main one...
 Just thinking out loud...
 Cheers!
 Eduardo


 On Fri, Nov 21, 2014 at 9:02 AM, Marcus Ottosson konstr...@gmail.com 
 javascript: wrote:

 This locks up Maya.

 from maya import utils
 def nested_func():
 print Hello world
 def func():
 utils.executeInMainThreadWithResult(nested_func)

 utils.executeInMainThreadWithResult(func)

 Though I can currently work around it, I can’t quite understand why it 
 would lock up.
 ​
 -- 
 *Marcus Ottosson*
 konstr...@gmail.com javascript:
  
 -- 
 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 
 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB0ag9qydyNXS-CqKuhvUf%2BBEAXQxnsqxPhWamF%2BXinyQ%40mail.gmail.com
  
 https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB0ag9qydyNXS-CqKuhvUf%2BBEAXQxnsqxPhWamF%2BXinyQ%40mail.gmail.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Eduardo Graña
 www.eduardograna.com.ar
  
 -- 
 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 
 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/python_inside_maya/CACt6GrmATAuHuAzhpY%2BXgECBKXGJtGJG2%2BgOwU8KWs6MFVRDPg%40mail.gmail.com
  
 https://groups.google.com/d/msgid/python_inside_maya/CACt6GrmATAuHuAzhpY%2BXgECBKXGJtGJG2%2BgOwU8KWs6MFVRDPg%40mail.gmail.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.




 -- 
 *Marcus Ottosson*
 konstr...@gmail.com javascript:
  



 -- 
 *Marcus Ottosson*
 konstr...@gmail.com javascript:
  

-- 
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/2c5bd8a8-5a77-40c2-87ae-78186e1d7017%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Fun fact

2014-11-21 Thread Robert White
I've had good luck with it for simple tasks like updating GUIs.

I also use it as part of my startup sequence for any tasks that need to 
build/tweak/change maya's default GUIs, because not enough of the maya 
environment is loaded during userSetup.py's execution. But if you defer 
those tasks, the idle queue won't be processed until after maya is done 
loading, and by then if the GUI isn't there, you've got bigger problems.



On Friday, November 21, 2014 10:03:14 AM UTC-6, Marcus Ottosson wrote:

 Thanks, Robert. Makes sense now.

 Which is why this does work if you just use executeDeferred(), which 
 doesn’t block in the same way.

 Do you have experience with this across threads? Since it doesn’t return 
 anything it’s a little tricky as a replacement, but if it’s thread-safe 
 then I’ll certainly keep it in mind.
 ​


-- 
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/30006d28-8193-4db8-b85b-a38cbf6e7964%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] mysql in maya

2014-07-03 Thread Robert White
Or PyMySQL https://github.com/PyMySQL/PyMySQL which is another pure 
python implementation this one offers the same interface as MySQLdb so it 
can act as a drop in replacement. No idea if the MySQL connector behaves 
the same way.

On Thursday, July 3, 2014 7:20:23 AM UTC-5, Nils wrote:

 The mysql connector is written in pure python and does not require any 
 additional libs or need to be compiled.

 http://dev.mysql.com/downloads/connector/python/
 On Jun 25, 2014 5:27 PM, Fredrik Averpil fredrik...@gmail.com 
 javascript: wrote:

 I've compiled MySQLdb for Python 2.7 (which Maya 2014/2015 is using). I 
 jotted down some notes about compiling it here: 
 http://fredrik.averpil.com/post/87906472836

 Regards,
 Fredrik




 On Wed, Jun 25, 2014 at 4:37 PM, Marcus Ottosson konstr...@gmail.com 
 javascript: wrote:

 On Windows, Python in Maya is running MSC1600 (since version 2012 or 
 so?) as opposed to MSC1500 which is the default for standalone Python, so 
 you might have to compile it via mayapy.exe for it to play nice with Maya.


 On 25 June 2014 15:31, Tony Barbieri grea...@gmail.com javascript: 
 wrote:

 The mysqldb package does need to be compiled for your os and python 
 version.

 There is a pure python alternative here: 
 https://github.com/PyMySQL/PyMySQL

 In order to compile mysqldb you should only have to run the setup.py 
 that is distributed with it.


 On Wed, Jun 25, 2014 at 10:25 AM, n.si...@barajoun.com javascript: 
 wrote:

 import MySQLdb works from python 2.6 ( outside maya ). But since 
 maya is using python 2.7 above command gives an error.

 # ImportError: No module named _mysql #

 Question :

 How do i get independant of download a module from net to run mysql ( 
 or an alternative ) through maya.

 What is step by step installation to get MySQL running on maya ( linux 
 ( centos ) and windows )

 If their is a need to compile ( or any thing like this, how would a 
 first timer do it ).



 Thank you.


 --
 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 
 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/python_inside_maya/a7bacd4d-95aa-4954-a991-cade53856496%40googlegroups.com
 .
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Tony
  
 -- 
 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 
 javascript:.
  To view this discussion on the web visit 
 https://groups.google.com/d/msgid/python_inside_maya/CAJhmvsSuE47hAsSzqe%2BbjwAL%2BXzWe7aNcfgFBxfAfKL%3DKwhO%2BA%40mail.gmail.com
  
 https://groups.google.com/d/msgid/python_inside_maya/CAJhmvsSuE47hAsSzqe%2BbjwAL%2BXzWe7aNcfgFBxfAfKL%3DKwhO%2BA%40mail.gmail.com?utm_medium=emailutm_source=footer
 .

 For more options, visit https://groups.google.com/d/optout.




 -- 
 *Marcus Ottosson*
 konstr...@gmail.com javascript:
  
 -- 
 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 
 javascript:.
  To view this discussion on the web visit 
 https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBTdsLRGMVKnz-roJ3GcNs_6NaNuhG%2Bz1xnGfFvgtUMXQ%40mail.gmail.com
  
 https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBTdsLRGMVKnz-roJ3GcNs_6NaNuhG%2Bz1xnGfFvgtUMXQ%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 javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWMvHbM_UR2MPxX%3DJxqawWRZEDjxoF%2B1OBmuOQ5n%2BN4_%3Dg%40mail.gmail.com
  
 https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWMvHbM_UR2MPxX%3DJxqawWRZEDjxoF%2B1OBmuOQ5n%2BN4_%3Dg%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/ed7c6971-bc34-4370-868a-8b10a2cb8ed6%40googlegroups.com.
For more