Re: [Maya-Python] Turning off Orient Joint Move Option

2011-08-20 Thread John Creson
you could put something like

manipMoveContext -e -oje 0 Move;

in your userSetup.mel...

or

import maya.cmds as cmds

cmds.manipMoveContext("Move", e=True, oje = 0 )

in your userSetup.py
On Wed, Aug 10, 2011 at 12:28 PM, Christian Akesson  wrote:

> I have been digging around in the globals but have not found an option to
> turn this off through altering a global.
> The move tool has a orient joint flag for when initializing the move tool,
> but nothing that is editable.
>
> Anyone dealt with this?
>
> Thanks,
> /Christian
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>

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


Re: [Maya-Python] Standalone mode and SamplerInfo node

2011-01-11 Thread John Creson
can you set off a render to get it to calculate?

On Tue, Jan 4, 2011 at 4:19 PM, pro  wrote:
> Hey folks-
>
> I have a python script that works fine when run from Maya's script
> editor (i.e., UI mode). I'm trying to get this script to work in
> standalone mode for batch processing.
>
> The script uses Maya's samplerinfo node, which seems to be only able
> to sample with respect the active camera (i.e., there seems to be no
> way to hook the node's input to an arbitrary camera matrix). So to get
> the sampleinfo node to work with respect to a particular camera in the
> scene I have tried the following:
>
> 1. Using the command: maya.cmds.lookthru(myCam)
> This command works fine in UI mode but fails in standalone mode with
> the exception:
> 'RuntimeError: There is no active view.'
>
> 2. I have also tried the following commands to set the active camera:
> maya.cmds.viewSet(myCam, persp=True)
> maya.cmds.renderSettings(camera = myCam)
> These commands don't throw an exception in standalone mode. However,
> the rendered image does not sample information from the specified
> camera (i.e., no matter what camera I set the active camera to, the
> same image is generated in standalone mode). However, in the UI mode
> these commands works fine.
>
> 3. I have also tried setting the perspective camera's attributes to
> match the desired camera:
> for attr in maya.cmds.listAttr(myCamShape, k=1):
>  mc.setAttr("perspShape." + attr, mc.getAttr(myCamShape + "." +
> attr))
>
> for attr in maya.cmds.listAttr(myCam, k=1):
>  mc.setAttr("persp." + attr, mc.getAttr(myCam + "." +
> attr))
>
> None of these solutions work in standalone mode. Any suggestions would
> be greatly appreciated.
> Thanks,
> -pro
>
> --
> http://groups.google.com/group/python_inside_maya
>

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


Re: [Maya-Python] restarting maya.standalone after a crash

2011-01-11 Thread John Creson
You probably want something that starts the maya.standalone in a sep
process on your machine, and keep track of tests left to run in a
dynamic file on disk, so you can recover if there is a crash.
Often it is good to try that crashing test again  before continuing
on, there maybe a longform crash coming up.

On Tue, Jan 4, 2011 at 3:13 PM, hapgilmore  wrote:
> I'm working on a testing framework which iterates over lists of maya
> files: opening each file, running scripts, then closing the file.
>
> My problem is that if I hit a bad maya file, the maya.standalone
> crashes.  What is the proper way to re-start a maya standalone
> instance so I can continue testing?
>
> --
> http://groups.google.com/group/python_inside_maya
>

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


Re: [Maya-Python] Re: pymel floatSlider: attaching it into an existing pyQT layout:

2010-11-09 Thread John Creson
another bit to try.

give the layout a unique name and set parent to that unique name

or, dumpwidgets and weed through the dump...

for widge in cmds.lsUI(dumpWidgets=True):
if widge.startswith('mywindow'):
   print widge

MQtUtil is also a great place to start digging.

On Tue, Nov 9, 2010 at 4:39 AM, David Moulder  wrote:
> I think you'll find this useful... some basic wraps of MQtUtil I did.
>  I originally got the idea for this from http://nathanhorne.com/?p=183
> It's well worth bookmarking these TD's and using Google Reader.  I'm forever
> stealing and learning from these guys!
> http://pastebin.com/rE6uhtm4
> I've not tried to do what your attempting yet but I hope to when I get 5
> minutes at work...
> -Dave
>
>
>
> On Mon, Nov 8, 2010 at 6:45 PM, mtherrell  wrote:
>>
>> thanks David.
>>
>> in a function of my subclassed qtDesigner ui, i have access to the
>> QGridLayoutitself  and/ or the QTabWidget that has that grid layout
>> within it.
>> like this: self.sliderLayout ..
>>
>> i am trying to get the maya fullname of that widget using
>> MQtUtil.fullName().
>>
>> my problem is MQtUtil.fullName().. and its c++ ducumentaion vs. python
>> documentation.
>> MQtUtil.fullName() supposedly returns the fullname as an MString or
>> the control, given it's QObject.
>>
>> but i do not know how to represent the QObject pointer in python. the
>> docs say fullName() requires a pointer to the QObject.
>> even after reading up on how python handles pointers.. i still cannot
>> get MQtUtil.fullName() to work in python..
>>
>> any help or examples on how to represent the QObject as a pointer in
>> python.. ort how to translate the c++ docs into python in general
>> would be a great help!
>>
>> thanks
>> -mt
>> On Nov 6, 12:48 pm, David Moulder  wrote:
>> > hmm, should be possible in 2011.
>> >
>> > As long as you know the fullName of the parent layout then can you not
>> > use
>> > the setParent() cmd and then add the floatSlider.
>> > Then get the float slider back as a QObject see the api MQtUtil i think.
>> >  I
>> > think pymel has toQObject, not documented tho.
>> >
>> > I suppose you can then use signal as slots with that QObject.
>> >
>> > It's an interesting mix as it's all Qt but the implementation in both
>> > are
>> > different.
>> >
>> > -Dave
>> >
>> >
>> >
>> > On Sat, Nov 6, 2010 at 7:04 PM, mtherrell 
>> > wrote:
>> > > i should probably restate the problem and be a bit more clear..
>> >
>> > > my goal is to generate a maya float slider using the pymel
>> > > floatSlider() command, in a subclass of an interface created in qt
>> > > designer (and then pyuic4.. not using "loadUI").
>> > > i want to be able to treat this slider like any other QObject..
>> > > placing and attaching it into a QGridLayout in my QT interface, and
>> > > connecting its signals to
>> > > functions within my subclass. (whether by signals and slots or by the
>> > > callback functions of the floatslider() command itself..not sure)
>> >
>> > > my problem is that i do not know how to get the QObject that
>> > > represents the maya floatSlider so that i can do all these things to
>> > > it.
>> > > the object that is returned by pymel does not seem to allow QObject
>> > > functions. (not a QObject?)
>> >
>> > > am i missing something simple?
>> > > i am very new to qt and pymel..
>> > > its likely just newb-ism.
>> > > just needed a little help.
>> >
>> > > thanks.
>> >
>> > > On Nov 5, 5:02 pm, mtherrell  wrote:
>> > > > i am using pymel 1.0 in maya 2011.
>> > > > i am using QTDesigner to create my interface base class.
>> >
>> > > > unfortunately, (and surprisingly) QT does not have a float slider.
>> > > > so
>> > > > i need to make my float slider in my subclass of my qt interface
>> > > > using
>> > > > pymel. ( prefer not to make an intslider powers of ten bigger than
>> > > > my
>> > > > desired float range in order to approximate a float slider in QT.)
>> >
>> > > > (i am using pyuic4 to emit my interface as a .py then i subclass
>> > > > that .py)
>> >
>> > > > 1. are there any examples of creating a floatSlider using pymel, and
>> > > > then laying it out in an already existing qt layout?
>> >
>> > > > 2. how do i get the QObject that results from creating a floatSlider
>> > > > so that I can connect its signals using qt?
>> >
>> > > > 3. is it better to use qt signals  to connect the floatSlider to my
>> > > > functions or better to use the mel 'dragCommand' conventional
>> > > > callback
>> > > > system somehow?
>> >
>> > > > thanks for any help on using pymel floatSlider inside a qt layout..
>> >
>> > > > -mark therrell
>> >
>> > > --
>> > >http://groups.google.com/group/python_inside_maya
>> >
>> > --
>> > David Moulderhttp://www.google.com/profiles/squish3d
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>
>
>
> --
> David Moulder
> http://www.google.com/profiles/squish3d
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Re: maya.cmds vs pymel speed?

2010-10-03 Thread John Creson
There are seldom areas where scripts' speeds actually impact the job
you are doing.

Yes, there are things I can do to really slow down my scripts (lots
and lots of prints statements perhaps?), but if our scripts are
working efficiently, they will be using Maya to do the heavy lifting,
not the scripting.

Something that PyMEL has helped us accomplish, and has helped with a
specific known speed issue, is the ability to pass a selection as an
mObject, rather than converting it to a string, passing the string and
then converting back to an mObject. (kind of like the lots and lots of
prints statements above, only applied to how commands communicate
their results to the next command)  This can be really important when
the names of the selections need to be really long because there are
many levels of hierarchy and the objects have been duplicated many
times.

Also, as suggested, taking advantage of python enabled API queries is
fast and safe, and PyMEL has built this into normal scripting
situations.  You don't have to do anything special to take advantage
of this other than use PyMEL, API opportunities are built in. (and
it's a great place to look to see how it's done, in case you'd like to
work out how to make things faster in this way)

Along the lines of passing strings into commands...
The example is doing just that:

pm.setAttr("locator1.tx",5)

whereas, if you built the locator in your script, assigining it to a
variable, and then set that attr using the variable, then you should
avoid needing to convert the string to the mObject.

myL = pm.spaceLocator()
pm.setAttr(myL.tz,5)

Also, perhaps you are also seeing the time it takes to do the first
part in the example:

import pymel.core as pm

It takes a little time to import pymel.  It's doing a lot.  It should
not be factored into performance tests.
This part is done once in Maya(like starting Maya), and could be put
into your userSetup.py to make it more invisible.

If you use PyMEL, you don't tend to use it as a one-off here and
there, you tend to work with it to accomplish a major task, or in a
series of inter-working tools.  The more you use it, the more
opportunities it has to save you time at runtime, as well as during
development.

-JohnCreson


On Sun, Oct 3, 2010 at 3:58 AM, Paul Molodowitch  wrote:
> Yes, Ofer is basically right, in that pymel's priority has always been ease
> of use over execution speed.  If execution speed is your thing, then pymel
> probably isn't the right tool for the job.
> Having said that, though, I would like to take a look at what can be done to
> try to speed up pymel at some point...
> - Paul
>
> On Sat, Oct 2, 2010 at 10:49 PM, Count Zer0  wrote:
>>
>> Well put Ofer.
>>
>> IMHO, the speed of coding in PyMEL FAR outweighs the lack of speed in
>> script execution. 99% of the time, script execution speed is near
>> instantaneous, so PyMEL is the proper thing to use.
>>
>> When you get into lots of mesh iteration and weights stuff, you might
>> want to go back to maya.cmds or better yet get into Python API calls.
>> I think that stuff works even faster then MEL or maya.cmds, not as
>> fast as compiled API, of course.
>>
>> Chad confirms this at the bottom of this thread:
>> http://forums.cgsociety.org/archive/index.php/t-833446.html
>>
>> -jason
>>
>> On Oct 2, 7:36 pm, Ofer Koren  wrote:
>> > pymel is more about the speed of coding, less about the speed of the
>> > code... right Paul?
>> >
>> > - Oferwww.mrbroken.com
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Sat, Oct 2, 2010 at 1:22 PM, Paul Molodowitch 
>> > wrote:
>> > > (err... that should have read 'area', not 'are'...)
>> > > - Paul
>> >
>> > > On Sat, Oct 2, 2010 at 1:21 PM, Paul Molodowitch 
>> > > wrote:
>> >
>> > >> For setAttr, it doesn't create a pynode... but the command is
>> > >> wrapped, so
>> > >> it will still be slower than the maya.cmds equivalent.
>> > >> In general, though, speed is one are where PyMel still has a lot of
>> > >> room
>> > >> for improvement...
>> > >> - Paul
>> > >> On Sat, Oct 2, 2010 at 12:29 PM, breeder 
>> > >> wrote:
>> >
>> > >>> Example:
>> > >>> import pymel.core as pm
>> > >>> pm.setAttr("locator1.tx",5)
>> >
>> > >>> So , in this example , does pymel use maya.cmds or is actually
>> > >>> creating PyNode for "locator1" and than setting attribute???
>> >
>> > >>> On Oct 2, 8:16 pm, Jo Jürgens  wrote:
>> > >>> > A node in maya.cmds is just a text string, while in Python it is a
>> > >>> > PyNode
>> > >>> > instance. Creating all those instances in PyMel does take time.
>> > >>> > For
>> > >>> > operations on large number of items where speed is crucial, I
>> > >>> > still
>> > >>> > tend to
>> > >>> > use maya.cmds.
>> >
>> > >>> --
>> > >>>http://groups.google.com/group/python_inside_maya
>> >
>> > > --
>> > >http://groups.google.com/group/python_inside_maya
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>
> --
> http://groups.google.com/group/python_inside_maya

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

Re: [Maya-Python] Re: pymel in mayapy.exe hanging

2010-09-22 Thread John Creson
you could possibly put it into a Maya.env file...

http://download.autodesk.com/us/maya/2011help/files/Environment_Variables_Setting_environment_variables_using_Maya.env.htm

On Wed, Sep 22, 2010 at 2:26 PM, hapgilmore  wrote:
> Thanks for the suggestions, I really appreciate your help.
>
> I am already remote debugging with Wing, though I could never get a
> connection on the server.
>
> I spent a couple hours yesterday setting up my local machine to
> replicate the environment on the server.  It turns out that because
> the Windows Service isn't run as a regular user with regular
> permissions, maya standalone won't launch.
> On my local machine, the service pops up a warning (from the maya
> instance) that a valid MAYA_APP_DIR can be found.
> I assume that because I was using a remote desktop connection to the
> server, I never sawt the pop-up, and the process wasn't really
> hanging, just waiting for user input.
>
> Now I just need to figure out how to give maya a valid MAYA_APP_DIR
> under a service, which doesn't have the same user/system permissions
> that a regular user login gives.
>
> -Ian
>
>
>
> On Sep 22, 11:48 am, Paul Molodowitch  wrote:
>> Hey there - first of all, I'm sorry I didn't notice your earlier issue.  We
>> try to scan this list for pymel related stuff and respond, but sometimes we
>> miss stuff...
>>
>> However, regarding some of your questions about pymel support: well, there
>> is no official support.  It is still being actively developed, and we try to
>> get to tickets when we can but having said that, we don't receive any
>> money for pymel, so our time is essentially donated to the project, and
>> sometimes we simply don't have much time to devote to pymel.  There is a
>> chance that you will have to end up troubleshooting on your own though - all
>> of pymel is open source, and it's all python, so you should be able to use
>> all the usual python-debugging tricks.
>>
>> It can help to email Chad (chad...@gmail.com) or I (elron...@gmail.com)
>> directly... particularly if you want to let us know about something urgent /
>> important for your project / pipe.
>>
>> Anyway, to the issue at hand - my guess is that Chris is on the right track
>> - it's probably the process of starting maya itself that's causing the
>> problem.  Ie, does doing this:
>>
>> import maya.standalone
>> maya.standalone.initialize()
>>
>> ...in your service also result in a crash? If so, that's the issue...
>> whenever pymel.core is imported, if maya isn't already running, it tries to
>> start it by doing the above two lines (as pymel.core requires a running maya
>> to do anything).
>>
>> If that isn't it, I'll try to figure out what's wrong when I get home later
>> tonight.  Also, some general debugging stuff you can try:
>>
>> 1) enable pymel logging
>>
>> To do this, go to your pymel directory (if you're using the default install,
>> somewhere inside the maya install... don't remember where exactly it puts it
>> in windows, but I think it's in %MAYA_INSTALLATION%\Python...), and find the
>> file called pymel.conf.  You'll need to either edit this in this location,
>> or copy it to your home directory... (if no %HOME% environment variable is
>> defined, you'll need to define that...), or define a %PYMEL_CONF%
>> environment var, and have it contain the location of wherever you'd like
>> you're pymel.conf to be.
>>
>> Once you've got that, you'll need to add 'fileLogger' to the logger_pymel
>> handlers... ie, change this:
>>
>> [logger_pymel]
>> ## Set the root 'pymel' logger to DEBUG mode
>> ## Setting PYMEL_LOGLEVEL environment variable will override this
>> level=INFO
>> qualname=pymel
>> handlers=
>>
>> to this:
>>
>> [logger_pymel]
>> ## Set the root 'pymel' logger to DEBUG mode
>> ## Setting PYMEL_LOGLEVEL environment variable will override this
>> level=DEBUG
>> qualname=pymel
>> handlers=fileLogger
>>
>> Once you've done that, pymel should log stuff to your homeDir/pymel.log...
>> which may at least give us an idea of how far it gets before it crashes.
>>
>> Another option would be:
>>
>> 2) Remote debugging
>>
>> More powerful / useful, but you'll need an IDE that supports it (and can
>> also be more involved to get working).  Both eclipse and Wing support remote
>> debugging; exactly how to go about setting it up depends on what IDE you're
>> using.  For eclipse + pydev, the process is explained here:
>>
>> http://pydev.org/manual_adv_remote_debugger.html
>>
>> ...but the basic idea is that you'd insert code like this:
>>
>> import sys
>> sys.path.append(r'D:\bin\eclipse_36_final\plugins\org.python.pydev.debug_1. 
>> 6.1.2010072814\pysrc')
>> import pydevd
>> pydevd.settrace()
>>
>> ...into wherever you're importing pymel.core, right before the pymel.core
>> import.  Then you'd fire up eclipse, and go to the python debugging view,
>> and click on the button to hook up to a remote debugging session.
>>
>> - Paul
>>
>>
>>
>> On Tue, Sep 21, 2010 at 5:22 PM, Chris G  wrote:
>> > It might be 

Re: [Maya-Python] selecting attributes in channelBox?

2010-09-03 Thread John Creson
You're trying to perform the selection?
Not read the selection?
right?

On Fri, Sep 3, 2010 at 1:25 PM, damon shelton  wrote:
> is this to allow for the usage of the middle mouse virtual slider function?
>
> when in a move mode, by clicking on one of the directional handles of any
> manipulator allows you to middle mouse drag after that in only that axis, or
> all three when you are in the transform mode
> if you are trying to do it for attrs other than the default transforms then
> that is another story.
>
>
> On Fri, Sep 3, 2010 at 4:59 AM, Nicolas Combecave 
> wrote:
>>
>> I'd be very interested to hear about this too. We had to find a
>> workaround, which involved selectionLists and dragAttrContext to manipulate
>> channelBoxAttrs, but it was way more complicated than selecting directly the
>> attribute via select -r persp.translateX for example, and being able to use
>> the virtual slider...
>>
>> Nicolas
>>
>> On Fri, Sep 3, 2010 at 12:56 PM, martin tomoya  wrote:
>>>
>>> Does anyone know a way to select attributes in the channelBox from a
>>> python script?
>>>
>>> --
>>> http://groups.google.com/group/python_inside_maya
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Re: World Matrix as driver

2010-08-16 Thread John Creson
actually, just clicking in a script editor tab will trigger the
outliner to update.

I was trying to getAttr the visiblitiy of the nodes under LOD, and
just clicking in the scriptEditor tab prompted the outliner to change.

On Mon, Aug 16, 2010 at 4:20 PM, John Creson  wrote:
> I think you may be looking at a lag in the Outliner, and not in Maya really.
>
> I published up Distance and Active Level and the transforms that will
> trip the trigger easily and I'm watching real-time interaction with
> the distance and the Active level trigger.
> The Outliner doesn't catch up until I re-select the asset in the outliner.
>
> On Mon, Aug 16, 2010 at 4:07 PM, susanta  wrote:
>> humm no that callback is because of attribute editor though it is not
>> displayed...
>> ...but outliner update lag is still there if there is no 3d view for
>> LOD. Wondering what else
>> can be possible so LOD node can listen to world matrix change?
>>
>> On Aug 16, 8:01 pm, susanta  wrote:
>>> You are right with all of these. But I'm more expermenting with it ...
>>> I'm speculating even not camera shape or any node's world matrix, LOD
>>> visibility trigger mechanism actually
>>> driven by some other kind of callback mechanism or somthing else? Ok
>>> let me tell you my observation...
>>>
>>> when you change camera distance by changing camera position you can
>>> see on outliner, node's under LOD group grayed out or
>>> highlighted based on current distance immidiately after distance
>>> change. In my test I'm using a locator, whose worldmatrix connected
>>> with LOD group node's
>>> camera matrix...so by changing locator's location I can change LOD
>>> visibility. changes are very quick and works for othographic or
>>> perspective view. But if I now turn off all 3d view...(i have a single
>>> viewport and now I'm displaying timeline in that area) If I change
>>> locator's position through channel editor...from outliner I can see
>>> LOD Group not immdiately changing LOD visibility for chilld
>>> nodesuntill i change my selection state or back to 3d view. Even
>>> if i move my time slider or manually call dgeval on locator node still
>>> no feeback for LOD visibility change on outliner. Is it some kind of
>>> viewport refresh or selection change or etc callback driving it
>>> instead of DAG tree evalution?
>>>
>>> Another observation, if my locator's is not connected with
>>> loadgroup...it does not print this after changing its transform
>>> through channel editor but it does when connected to a LOD group
>>>
>>> AEupdateWorldPivots locator1;
>>> AEupdateLocalPivots locator1;
>>> AEupdateLocalPivots locator1;
>>>
>>> ...so I'm assuming this is the function they are using as
>>> callback...i.e. external querry to noode's world matrix via MEL? I
>>> hope I'm wrong.
>>>
>>> global proc AEupdateWorldPivots ( string $nodeName )
>>> {
>>>         float $worldRotatePivot[] = `xform -ws -q -rp $nodeName`;
>>>         float $worldScalePivot[] = `xform -ws -q -sp $nodeName`;
>>>
>>>         floatField -e -v $worldRotatePivot[0] wrpX;
>>>         floatField -e -v $worldRotatePivot[1] wrpY;
>>>         floatField -e -v $worldRotatePivot[2] wrpZ;
>>>
>>>         floatField -e -v $worldScalePivot[0] wspX;
>>>         floatField -e -v $worldScalePivot[1] wspY;
>>>         floatField -e -v $worldScalePivot[2] wspZ;
>>>
>>> }
>>>
>>> On Aug 16, 6:10 pm, John Creson  wrote:
>>>
>>> > LOD global world space attribute gives the LOD group node the ability
>>> > to be driven by changes to its parents' transforms.
>>>
>>> > Before, or when the world space attribute is unchecked, the parent
>>> > transformations did not affect the visibility of the LOD group
>>> > children.   Now that it is there and checked on, changes to its parent
>>> > nodes cause updates to the distance attribute which is calculated
>>> > between the LOD node and the camera.  (it acts as you would expect it
>>> > to act, and more importantly, the transformations of its parents
>>> > (which could be joints, why not?)  trigger the update to its distance
>>> > attribute)
>>>
>>> > On Mon, Aug 16, 2010 at 6:36 AM, susanta  wrote:
>>> > > "Have you set up the node's attribute dependencies?"
>>>

Re: [Maya-Python] Re: World Matrix as driver

2010-08-16 Thread John Creson
I think you may be looking at a lag in the Outliner, and not in Maya really.

I published up Distance and Active Level and the transforms that will
trip the trigger easily and I'm watching real-time interaction with
the distance and the Active level trigger.
The Outliner doesn't catch up until I re-select the asset in the outliner.

On Mon, Aug 16, 2010 at 4:07 PM, susanta  wrote:
> humm no that callback is because of attribute editor though it is not
> displayed...
> ...but outliner update lag is still there if there is no 3d view for
> LOD. Wondering what else
> can be possible so LOD node can listen to world matrix change?
>
> On Aug 16, 8:01 pm, susanta  wrote:
>> You are right with all of these. But I'm more expermenting with it ...
>> I'm speculating even not camera shape or any node's world matrix, LOD
>> visibility trigger mechanism actually
>> driven by some other kind of callback mechanism or somthing else? Ok
>> let me tell you my observation...
>>
>> when you change camera distance by changing camera position you can
>> see on outliner, node's under LOD group grayed out or
>> highlighted based on current distance immidiately after distance
>> change. In my test I'm using a locator, whose worldmatrix connected
>> with LOD group node's
>> camera matrix...so by changing locator's location I can change LOD
>> visibility. changes are very quick and works for othographic or
>> perspective view. But if I now turn off all 3d view...(i have a single
>> viewport and now I'm displaying timeline in that area) If I change
>> locator's position through channel editor...from outliner I can see
>> LOD Group not immdiately changing LOD visibility for chilld
>> nodesuntill i change my selection state or back to 3d view. Even
>> if i move my time slider or manually call dgeval on locator node still
>> no feeback for LOD visibility change on outliner. Is it some kind of
>> viewport refresh or selection change or etc callback driving it
>> instead of DAG tree evalution?
>>
>> Another observation, if my locator's is not connected with
>> loadgroup...it does not print this after changing its transform
>> through channel editor but it does when connected to a LOD group
>>
>> AEupdateWorldPivots locator1;
>> AEupdateLocalPivots locator1;
>> AEupdateLocalPivots locator1;
>>
>> ...so I'm assuming this is the function they are using as
>> callback...i.e. external querry to noode's world matrix via MEL? I
>> hope I'm wrong.
>>
>> global proc AEupdateWorldPivots ( string $nodeName )
>> {
>>         float $worldRotatePivot[] = `xform -ws -q -rp $nodeName`;
>>         float $worldScalePivot[] = `xform -ws -q -sp $nodeName`;
>>
>>         floatField -e -v $worldRotatePivot[0] wrpX;
>>         floatField -e -v $worldRotatePivot[1] wrpY;
>>         floatField -e -v $worldRotatePivot[2] wrpZ;
>>
>>         floatField -e -v $worldScalePivot[0] wspX;
>>         floatField -e -v $worldScalePivot[1] wspY;
>>         floatField -e -v $worldScalePivot[2] wspZ;
>>
>> }
>>
>> On Aug 16, 6:10 pm, John Creson  wrote:
>>
>> > LOD global world space attribute gives the LOD group node the ability
>> > to be driven by changes to its parents' transforms.
>>
>> > Before, or when the world space attribute is unchecked, the parent
>> > transformations did not affect the visibility of the LOD group
>> > children.   Now that it is there and checked on, changes to its parent
>> > nodes cause updates to the distance attribute which is calculated
>> > between the LOD node and the camera.  (it acts as you would expect it
>> > to act, and more importantly, the transformations of its parents
>> > (which could be joints, why not?)  trigger the update to its distance
>> > attribute)
>>
>> > On Mon, Aug 16, 2010 at 6:36 AM, susanta  wrote:
>> > > "Have you set up the node's attribute dependencies?"
>>
>> > > ...are you talking about overriding setDependentsDirty function?
>>
>> > > "...but the LOD group node has a global world space attribute..."
>> > > Seems like in case of LOD group node driving force is camera shape
>> > > node's worldMatrix (connected to cameraMatrix of LOD group node)...as
>> > > you said global world space attribute is telling how to calculate
>> > > node's LOD feature and affects child node's visibility...so in this
>> > > case really transform nodes's world m

Re: [Maya-Python] Re: World Matrix as driver

2010-08-16 Thread John Creson
Yes, the viewport is a great driver of the dependency graph.
It needs to know where to draw those polys, or lines or whatever...

This is one reason why viewport 2.0 can show more stuff faster.
It is being more selective about how often, and how deeply it needs to
evaluate the DG.

Other than that, something else has to drive it.

something has to do something to kick off the evaluation.

You do seem to right though, the DAG changes above the LOD node do not
seem to dirty the LOD node, they are just being taken into account
when the Camera or in this case, your locator makes it's changes.

One thing that may yet be helpful...
I can group your locator - the one that is taking the place of the
camera's world matrix, and the parent  DAG changes on locator do
trigger the evaluations...

I put both in an advanced asset and published up the transforms for
the parent nodes above the locator, I could select the LodGroup1 node
and change the transforms above and watch the distance adjust, I am
seeing what you are seeing, the visibility doesn't change, but the
distance is changing...

On Mon, Aug 16, 2010 at 3:01 PM, susanta  wrote:
> You are right with all of these. But I'm more expermenting with it ...
> I'm speculating even not camera shape or any node's world matrix, LOD
> visibility trigger mechanism actually
> driven by some other kind of callback mechanism or somthing else? Ok
> let me tell you my observation...
>
> when you change camera distance by changing camera position you can
> see on outliner, node's under LOD group grayed out or
> highlighted based on current distance immidiately after distance
> change. In my test I'm using a locator, whose worldmatrix connected
> with LOD group node's
> camera matrix...so by changing locator's location I can change LOD
> visibility. changes are very quick and works for othographic or
> perspective view. But if I now turn off all 3d view...(i have a single
> viewport and now I'm displaying timeline in that area) If I change
> locator's position through channel editor...from outliner I can see
> LOD Group not immdiately changing LOD visibility for chilld
> nodesuntill i change my selection state or back to 3d view. Even
> if i move my time slider or manually call dgeval on locator node still
> no feeback for LOD visibility change on outliner. Is it some kind of
> viewport refresh or selection change or etc callback driving it
> instead of DAG tree evalution?
>
> Another observation, if my locator's is not connected with
> loadgroup...it does not print this after changing its transform
> through channel editor but it does when connected to a LOD group
>
> AEupdateWorldPivots locator1;
> AEupdateLocalPivots locator1;
> AEupdateLocalPivots locator1;
>
> ...so I'm assuming this is the function they are using as
> callback...i.e. external querry to noode's world matrix via MEL? I
> hope I'm wrong.
>
> global proc AEupdateWorldPivots ( string $nodeName )
> {
>        float $worldRotatePivot[] = `xform -ws -q -rp $nodeName`;
>        float $worldScalePivot[] = `xform -ws -q -sp $nodeName`;
>
>        floatField -e -v $worldRotatePivot[0] wrpX;
>        floatField -e -v $worldRotatePivot[1] wrpY;
>        floatField -e -v $worldRotatePivot[2] wrpZ;
>
>        floatField -e -v $worldScalePivot[0] wspX;
>        floatField -e -v $worldScalePivot[1] wspY;
>        floatField -e -v $worldScalePivot[2] wspZ;
> }
>
> On Aug 16, 6:10 pm, John Creson  wrote:
>> LOD global world space attribute gives the LOD group node the ability
>> to be driven by changes to its parents' transforms.
>>
>> Before, or when the world space attribute is unchecked, the parent
>> transformations did not affect the visibility of the LOD group
>> children.   Now that it is there and checked on, changes to its parent
>> nodes cause updates to the distance attribute which is calculated
>> between the LOD node and the camera.  (it acts as you would expect it
>> to act, and more importantly, the transformations of its parents
>> (which could be joints, why not?)  trigger the update to its distance
>> attribute)
>>
>> On Mon, Aug 16, 2010 at 6:36 AM, susanta  wrote:
>> > "Have you set up the node's attribute dependencies?"
>>
>> > ...are you talking about overriding setDependentsDirty function?
>>
>> > "...but the LOD group node has a global world space attribute..."
>> > Seems like in case of LOD group node driving force is camera shape
>> > node's worldMatrix (connected to cameraMatrix of LOD group node)...as
>> > you said global world space attribute is telling how to calculate
>> >

Re: [Maya-Python] Re: World Matrix as driver

2010-08-16 Thread John Creson
LOD global world space attribute gives the LOD group node the ability
to be driven by changes to its parents' transforms.

Before, or when the world space attribute is unchecked, the parent
transformations did not affect the visibility of the LOD group
children.   Now that it is there and checked on, changes to its parent
nodes cause updates to the distance attribute which is calculated
between the LOD node and the camera.  (it acts as you would expect it
to act, and more importantly, the transformations of its parents
(which could be joints, why not?)  trigger the update to its distance
attribute)


On Mon, Aug 16, 2010 at 6:36 AM, susanta  wrote:
> "Have you set up the node's attribute dependencies?"
>
> ...are you talking about overriding setDependentsDirty function?
>
> "...but the LOD group node has a global world space attribute..."
> Seems like in case of LOD group node driving force is camera shape
> node's worldMatrix (connected to cameraMatrix of LOD group node)...as
> you said global world space attribute is telling how to calculate
> node's LOD feature and affects child node's visibility...so in this
> case really transform nodes's world matrix (in my case Bone) is not
> the driving force for DAG evalution. It is interesting though..thanks.
>
> On Aug 14, 9:08 am, John Creson  wrote:
>> I'm not sure if this might help, but the LOD group node has a global
>> world space attribute, that when checked on allows the distance to the
>> connected camera to be calculated correctly even if the LOD group node
>> is parented to other transformed transforms.
>>
>> On Fri, Aug 13, 2010 at 6:43 PM, Judah Baron  wrote:
>> > Have you set up the node's attribute dependencies?
>>
>> > On Fri, Aug 13, 2010 at 9:04 AM, susanta  wrote:
>>
>> >> No luck :(. tried to connect currentChainLength (which is the output
>> >> of my node) to another locator's tx plugonly get evalution once
>> >> (opening file, or selecting my node in Attribute editori.e.
>> >> external querry to worldMatrix plug)...here is the rough test code...
>>
>> >> class ChainLengthCalc(omx.MPxNode):
>> >>        kPluginNodeTypeName = "ChainLengthCalc"
>> >>        kPluginNodeTypeId = om.MTypeId(0xd1a9257)
>> >>        evalIndex = 0
>> >>        def __init__(self):
>> >>            omx.MPxNode.__init__(self)
>>
>> >>        def compute(self,plug,dataBlock):
>> >>            if plug == self.currentChainLength:
>> >>                        print "hello"
>> >>                        ChainLengthCalc.evalIndex+=1
>> >>                        currentLength = ChainLengthCalc.evalIndex
>> >>                        ##self._getChainLength()
>> >>                        outHandle =
>> >> dataBlock.outputValue(self.currentChainLength)
>> >>                        outHandle.setMDistance(om.MDistance(currentLength))
>> >>                        dataBlock.setClean(self.currentChainLength)
>> >>                        return om.MStatus.kSuccess
>> >>            return m.MStatus.kUnknownParameter
>>
>> >>       �...@classmethod
>> >>        def creator(cls):
>> >>            return omx.asMPxPtr( cls() )
>>
>> >>       �...@classmethod
>> >>        def initialize(cls):
>> >>            unitAttr = om.MFnUnitAttribute()
>> >>            cls.currentChainLength = \
>> >>            unitAttr.create("currentChainLength", "ccl",
>> >>                        om.MFnUnitAttribute.kDistance, 0)
>> >>            unitAttr.setKeyable(False)
>> >>            unitAttr.setWritable(True)
>> >>            cls.addAttribute(cls.currentChainLength)
>>
>> >>            mAttr = om.MFnMatrixAttribute()
>> >>            cls.drivingBoneMatrixAttr = mAttr.create( "drivingBoneMatrix",
>> >> "dbm")
>> >>            mAttr.setStorable(True)
>> >>            mAttr.setWritable(True)
>> >>            cls.addAttribute(cls.drivingBoneMatrixAttr)
>> >>            cls.attributeAffects(cls.drivingBoneMatrixAttr,
>> >> cls.currentChainLength)
>>
>> >> On Aug 13, 4:20 pm, Chad Vernon  wrote:
>> >> > You need to have the output connected to something or else Maya will
>> >> > never
>> >> > request a node compute.  It only calculates nodes when it needs to.  You
>> >> > sho

Re: [Maya-Python] Re: World Matrix as driver

2010-08-14 Thread John Creson
I'm not sure if this might help, but the LOD group node has a global
world space attribute, that when checked on allows the distance to the
connected camera to be calculated correctly even if the LOD group node
is parented to other transformed transforms.

On Fri, Aug 13, 2010 at 6:43 PM, Judah Baron  wrote:
> Have you set up the node's attribute dependencies?
>
> On Fri, Aug 13, 2010 at 9:04 AM, susanta  wrote:
>>
>> No luck :(. tried to connect currentChainLength (which is the output
>> of my node) to another locator's tx plugonly get evalution once
>> (opening file, or selecting my node in Attribute editori.e.
>> external querry to worldMatrix plug)...here is the rough test code...
>>
>> class ChainLengthCalc(omx.MPxNode):
>>        kPluginNodeTypeName = "ChainLengthCalc"
>>        kPluginNodeTypeId = om.MTypeId(0xd1a9257)
>>        evalIndex = 0
>>        def __init__(self):
>>            omx.MPxNode.__init__(self)
>>
>>        def compute(self,plug,dataBlock):
>>            if plug == self.currentChainLength:
>>                        print "hello"
>>                        ChainLengthCalc.evalIndex+=1
>>                        currentLength = ChainLengthCalc.evalIndex
>>                        ##self._getChainLength()
>>                        outHandle =
>> dataBlock.outputValue(self.currentChainLength)
>>                        outHandle.setMDistance(om.MDistance(currentLength))
>>                        dataBlock.setClean(self.currentChainLength)
>>                        return om.MStatus.kSuccess
>>            return m.MStatus.kUnknownParameter
>>
>>
>>       �...@classmethod
>>        def creator(cls):
>>            return omx.asMPxPtr( cls() )
>>
>>       �...@classmethod
>>        def initialize(cls):
>>            unitAttr = om.MFnUnitAttribute()
>>            cls.currentChainLength = \
>>            unitAttr.create("currentChainLength", "ccl",
>>                        om.MFnUnitAttribute.kDistance, 0)
>>            unitAttr.setKeyable(False)
>>            unitAttr.setWritable(True)
>>            cls.addAttribute(cls.currentChainLength)
>>
>>
>>            mAttr = om.MFnMatrixAttribute()
>>            cls.drivingBoneMatrixAttr = mAttr.create( "drivingBoneMatrix",
>> "dbm")
>>            mAttr.setStorable(True)
>>            mAttr.setWritable(True)
>>            cls.addAttribute(cls.drivingBoneMatrixAttr)
>>            cls.attributeAffects(cls.drivingBoneMatrixAttr,
>> cls.currentChainLength)
>>
>> On Aug 13, 4:20 pm, Chad Vernon  wrote:
>> > You need to have the output connected to something or else Maya will
>> > never
>> > request a node compute.  It only calculates nodes when it needs to.  You
>> > should be able to just use the worldMatrix just fine.
>> >
>> > Chad
>> >
>> > On Fri, Aug 13, 2010 at 8:11 AM, susanta  wrote:
>> > > "worldmatrix is only updated on demand.."
>> >
>> > > Yea, That also I have speculated...
>> >
>> > > "Try instead hooking up to matrix and parentmatrix plugs of the node
>> > > whose worldmatrix you want. They should get pushed to your node and
>> > > then you can just concatenate them in compute() to get the world
>> > > matrix."
>> >
>> > > My problem is little bit typical :). this is not about computing world
>> > > matrix...say like, my node is connected in this order: NodeA -> NodeB-
>> > > > NodeC->...-> NodeD->MyNode. Now what I want to achieve, instaed
>> > > of using any callback system use DAG system, to evalute myNode's
>> > > compute block while any of the node in the hierarchy is changing
>> > > trasform matrix. Now if I plugin parentmatrix / matrix from nodeD, I
>> > > think if nodeD is affected then only it will evalute mynodebut not
>> > > for other nodes up in the hierarchy. So to find a clean way I have
>> > > tried to use worldMatrix of NodeD (as worldMatrix change is true for
>> > > change in any depth) as I not want to plug with all other node's
>> > > matrix in the hierarchy. But seems like I'm wrong :(...need to find a
>> > > better solution. Any way thanks man.
>> >
>> > > On Aug 13, 3:10 pm, Adam Mechtley  wrote:
>> > > > Iirc, worldmatrix is only updated on demand (eg, you getAttr on it
>> > > > or on
>> > > a plug that depends on it). Try instead hooking up to matrix and
>> > > parentmatrix plugs of the node whose worldmatrix you want. They should
>> > > get
>> > > pushed to your node and then you can just concatenate them in
>> > > compute() to
>> > > get the world matrix.
>> >
>> > > > Sent from my iPhone
>> >
>> > > > On Aug 13, 2010, at 6:44, susanta  wrote:
>> >
>> > > > > Hi Guys,
>> >
>> > > > > I'm trying to create a custom MPX node, which is doing some
>> > > > > calculation based on a bone's scale in a hierarchy. So far my
>> > > > > compute
>> > > > > code is working properly. I want to run the compute block always
>> > > > > if
>> > > > > the any bone in the hierarchy got new world matrix (either by pos,
>> > > > > rot
>> > > > > or scale change). But what I'm getting here, worldmatrix attribute
>> > > > >

Re: [Maya-Python] Are all defined functions global functions or can we declare local functions?

2010-08-10 Thread John Creson
from myModule import *

does what you are worried about, and if called within Maya might
present a name clash situation.
You don't want to do this with maya.cmds because maya's file cmd would
overwrite Python's.
If called within another module, just brings in those functions into
that module's namespace directly.

On Tue, Aug 10, 2010 at 11:26 AM, John Creson  wrote:
> If you are using a module (offline .py script file that you import
> into your python, in maya or in another module)
> Then you are in the namespace of that module.
>
> So
>
> import myModule as mm
>
> then
>
> mm.myFunc()
>
> is in the mm namespace
>
> import myModule
>
> myModule.myFunc()
>
> is in the myModule namespace.
>
> On Tue, Aug 10, 2010 at 10:35 AM, Alan Fregtman  
> wrote:
>> Hey guys,
>>
>> Coming from Softimage I'm a little confused by Maya's way of handling
>> function declarations in scripts. In Soft, they're always local unless
>> declared global using some SDK/API stuff.
>>
>> It would appear that in Maya in any Python script (or MEL for that
>> matter) a function declaration stays in memory and is accessible
>> globally.
>>
>> I'm worried about overriding other people's or Maya's own functions if
>> I don't give it very unique names. Is there some way to declare
>> functions for local use by the main global function in the same
>> script? Am I making sense?
>>
>> Cheers,
>>
>>   -- Alan
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>

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


Re: [Maya-Python] Are all defined functions global functions or can we declare local functions?

2010-08-10 Thread John Creson
If you are using a module (offline .py script file that you import
into your python, in maya or in another module)
Then you are in the namespace of that module.

So

import myModule as mm

then

mm.myFunc()

is in the mm namespace

import myModule

myModule.myFunc()

is in the myModule namespace.

On Tue, Aug 10, 2010 at 10:35 AM, Alan Fregtman  wrote:
> Hey guys,
>
> Coming from Softimage I'm a little confused by Maya's way of handling
> function declarations in scripts. In Soft, they're always local unless
> declared global using some SDK/API stuff.
>
> It would appear that in Maya in any Python script (or MEL for that
> matter) a function declaration stays in memory and is accessible
> globally.
>
> I'm worried about overriding other people's or Maya's own functions if
> I don't give it very unique names. Is there some way to declare
> functions for local use by the main global function in the same
> script? Am I making sense?
>
> Cheers,
>
>   -- Alan
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Calling a compiled QT file in Maya

2010-08-06 Thread John Creson
Nice,

I like seeing the screen shots of UI in these threads!

On Fri, Aug 6, 2010 at 2:24 PM, David Moulder  wrote:
> LOL, oh yeah,
>
> I did one a few months back called TabIt, only registered my most used UI's
> at the moment but I do plan on expanding it in the future.
>
>
>
>
> On Fri, Aug 6, 2010 at 7:01 PM, John Creson  wrote:
>>
>> anyone had any luck trying to create a 2nd monitor mainWindow.ui
>> complete with empty docks, in which you could parent other Maya
>> eidtors, like the Outliner and the graphEditor?
>>
>> On Fri, Aug 6, 2010 at 10:23 AM, David Moulder 
>> wrote:
>> > Yes totally,
>> >
>> > Just add a signal that calls a method to add a QWidget to a QTabWidget
>> >
>> > How you create the QWidget would be up to you.  You could just create a
>> > QWidget class for each tab, or use loadUiType with a factory function.
>> >
>> > Form, Base = uic.loadUiType(uifile)
>> >
>> > 

Re: [Maya-Python] Calling a compiled QT file in Maya

2010-08-06 Thread John Creson
anyone had any luck trying to create a 2nd monitor mainWindow.ui
complete with empty docks, in which you could parent other Maya
eidtors, like the Outliner and the graphEditor?

On Fri, Aug 6, 2010 at 10:23 AM, David Moulder  wrote:
> Yes totally,
>
> Just add a signal that calls a method to add a QWidget to a QTabWidget
>
> How you create the QWidget would be up to you.  You could just create a
> QWidget class for each tab, or use loadUiType with a factory function.
>
> Form, Base = uic.loadUiType(uifile)
>
> 

Re: [Maya-Python] pm.cmds.file and referenceNode

2010-08-06 Thread John Creson
I believe, in the mel, the refNode at the end is the object of the
command, not the value being passed to the flag.

You might try:

pm.cmds.file(ref.refNode, referenceNode=True, importReference=True)

On Thu, Aug 5, 2010 at 8:49 PM, Justin Rosen  wrote:
> Has anyone else noticed a discrepancy between the file command in mel and in
> python in relation to importing file references?
> pm.cmds.file(referenceNode=ref.refNode, importReference=True)  #Where ref is
> derived from pm.listReferences()
>
> # Traceback (most recent call last):
>
> # File
> "/tmp/TOOLS_INSTALL/cent5_x86_64_py26/MayaAssets-Project/MayaAssets/library/maya/python/importComponentReference.py",
> line 127, in importComponentReferences
>
> # pm.cmds.file(importReference=True,referenceNode=ref.refNode)
>
> # TypeError: Flag 'referenceNode' must be passed a boolean argument
>
> Is Pymel a bit stricter now?  I could of sworn this used to work. I have to
> resort to the following mel
>
> pm.mel.eval("file -importReference -referenceNode " + ref.refNode)
>
> The docs say it takes a boolean, but the mel code for importing a reference
> within the reference editor uses a reference node name
> scripts/others/referenceEditorPanel.mel
>
> if ( $numNodes >= $numFiles ) {
>     int $i = 0;
>     for ( $i = 0; $i < $numNodes; $i++ ) {
>     if ( size($selRefNode[$i]) > 0 ) {
>     file -importReference -referenceNode $selRefNode[$i];
>     }
>     }
>     } else {
>     int $i = 0;
>     for ( $i = 0; $i < $numFiles; $i++ ) {
>     if ( size($selFileReal[$i]) > 0 ) {
>     file -importReference $selFileReal[$i];
>     }
>     }
>     }
>
> Justin
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Ipymel inside maya gui

2010-08-06 Thread John Creson
or, open a port in python in maya and feed the commands in through that port...
(it'll be expecting python)

On Fri, Aug 6, 2010 at 1:15 AM, Paul Molodowitch  wrote:
>> I'm new to maya and pymel. I'd like to learn to script maya using
>> pymel. I was wondering if it's possible to use ipymel inside the maya
>> gui. It seems like it would be a pretty handy tool.
>
> I've looked into this briefly, and unfortunately, I just don't think this is
> possible without a lot of work (ie, really getting into the internals of
> ipython and mucking around).  If you want to give it a shot, though, it
> would be awesome!
>
>>
>> If it is possible how? If it's not possible is there a way to run
>> ipymel in a terminal and see the results updated in the maya gui?
>
> This is probably somewhat easier - you'd have to set up a system where you
> feed commands into maya through a command port, ala Eclipse Maya, or Maxya.
>  I don't know of anyone who's actually done this yet, though...
> - Paul
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Calling a compiled QT file in Maya

2010-08-06 Thread John Creson
You could also parent it into a layout in a standard maya window, that
should act in Maya like a std maya window.

On Thu, Aug 5, 2010 at 6:44 PM, David Moulder  wrote:
> Arh, had that a few times in the past.  From what I remember it was due to
> bad inheritance (Try a QDialog).  I think I had it when I was using
> QTabWidget and I hadn't set the allowed area's correctly.
>
> -Dave
>
>
>
> On Thu, Aug 5, 2010 at 10:06 PM,  wrote:
>>
>>  Figured out the "_" thing, guess I should grab working code
>> online. Appears uic.compileUI does use pyuic4
>>
>> No, it doesnt run everytime an instance is made. Well, plan on
>> making compile Ui files when a py is not found.
>>
>> Now, the window (partically displayed) is literaly embeded in the top left
>> corner of Maya making it unuseable.
>>
>> Thanks,
>> -brian
>>
>>
>>  Original Message 
>> Subject: Re: [Maya-Python] Calling a compiled QT file in Maya
>> From: David Moulder 
>> Date: Thu, August 05, 2010 10:55 am
>> To: python_inside_maya@googlegroups.com
>>
>> To parent your window you well need to get the Maya main window and pass
>> that in as the parent widget
>>
>> > 2011
>>
>> def GetMayaMainWindow():
>>     '''
>>     :returns: The QtWidget that pertains to the Maya Main Window
>>     '''
>>     import maya.OpenMayaUI as mui
>>     import sip
>>     ptr = mui.MQtUtil.mainWindow()
>>     if ptr:
>>     return sip.wrapinstance(long(ptr), QtCore.QObject)
>>
>> Then pass the resulting QWidget into your class
>>
>> eg
>> a = Browser(GetMayaMainWindow())
>>
>> I don't know about uic.compileUI as I pre compile all my ui files with the
>> pyuic4.exe from the command line.
>>
>> Well, not exactly.  I wrote a PyQt ui to browser and convert them on
>> double click using os.system
>>
>> cmd = 'pyuic4 %s > %s' % (DesignFile, OutPutFile)
>> os.system(cmd)
>>
>> To be honest, it was on of the 1st things I did so I've never looked at
>> another way to convert files.  Does your method convert each and every time
>> you make an instance?
>>
>> -Dave
>>
>>
>> On Thu, Aug 5, 2010 at 5:18 PM,  wrote:
>>>
>>> I edited the class below to reference the class for my browser using the
>>> following lines of code to show the window:
>>>
>>> a = Browser()
>>> a.show()
>>>
>>> Two things happen.. first the window does not stay "parented" to the main
>>> Maya window and will disappear under Maya.
>>>
>>> Second... using the compiled version of calculatorform that comes with Qt
>>> works fine. However, when I used uic.compileUi to complile the
>>> calculatorform.ui. I get the following error:
>>>
>>> # Error: ... global name '_' is not defined #
>>>
>>> The compiler added a '_' that doesn't belong. For example:
>>>
>>> CalculatorForm.setWindowTitle(_( u"Calculator Form"))
>>>
>>> If I removed the '_', it will open.
>>>
>>> Also, on a ui that I created I had to comment out the following lines
>>> because:
>>> test.setCentralWidget(self.centralwidget)
>>> test.setMenuBar(self.menubar)
>>> test.setStatusBar(self.statusbar)
>>>
>>> They cause a Attribute Error such as:
>>> # Error: AttributeError ... 'Browser' object has no attribute
>>> 'setCentralWidget' #
>>>
>>> Is there a way to get a compiled version of a Ui to open without having
>>> to edit the file?
>>>
>>> Thanks,
>>> -brian
>>>
>>>
>>>  Original Message 
>>> Subject: Re: [Maya-Python] Calling a compiled QT file in Maya
>>> From: David Moulder 
>>> Date: Thu, August 05, 2010 8:09 am
>>> To: python_inside_maya@googlegroups.com
>>>
>>> I use multiple inheritance...
>>>
>>> import ui_Browser
>>> class Browser(QtGui.QWidget, ui_Browser.Ui_Form):
>>>     def __init__(self, parent=None):
>>>     super(Browser, self).__init__(parent)
>>>     self.setupUi(self)
>>>     self.setObjectName('Browser')
>>>     self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
>>>
>>> -Dave
>>>
>>> On Thu, Aug 5, 2010 at 2:39 PM, meljunky  wrote:

 Trying to get QT Ui file to work in Maya I could use the loadUI
 command for example:

 import maya.cmds as cmds
 dialog = cmds.loadUI(f=r'C:/Python26/Lib/site-packages/PyQt4/examples/
 designer/calculatorform/calculatorform.ui')
 cmds.showWindow(dialog)

 Don't expect the calculator to actually work but the UI opens in Maya.
 But, I want to be able to edit UI elements so I used uic.compileUi to
 convert the file into a Python file in hopes to make method calls to
 add and remove UI elements while the window is open.

 The first four lines are:
 from PyQt4 import QtCore, QtGui

 class Ui_CalculatorForm(object):
    def setupUi(self, CalculatorForm):
        ...

 At this point I don't know how to call the Ui_CalculatorForm class
 method setupUi since it needs a different class called CalculatorForm.

 Thanks in advance.

 --
 http://groups.google.com/group/python_inside_maya
>>>
>>>
>>>
>>> --
>>> David Moulder
>>> http://www.google.com/profiles/squish3d
>>> 

Re: [Maya-Python] Can't paste from jEdit to script editor

2010-07-22 Thread John Creson
If you're on a mac, you can install a third party copy/paste manager
and tell it to not copy (or paste?) decorations?(It think that is what
this is called...)
At this point, it just wants plain ascii

On Thu, Jul 22, 2010 at 10:37 AM, PixelMuncher  wrote:
> Now that Maxya has taken a long/perhaps permanent haitus, I'm checking
> out jEdit. When I copy text from jEdit, it won't paste into the Script
> Editor, but it will paste into another text editor (EditPlus). I can
> then copy it from EditPlus to the SE.
> Anyone know if there is a fix?
> Thanks.
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] list of nodes that will be duplicated with duplicate(upstreamNodes=1)?

2010-07-13 Thread John Creson
I mean reliable for this context,
also, possibly you don't want to include Shading Networks in this
case, since you're interested only in input connections.

On Tue, Jul 13, 2010 at 6:14 PM, John Creson  wrote:
> I'm not sure this is reliable, but you can Preview contents when you
> go to create an Asset with Transform, and choose to include all
> inputs, Including Shading Networks.
> When you Apply this preview, you'll see selected all the nodes that
> would end up in the asset had it been made.  (open Hypergraph
> connections)
>
> Default nodes will not go into assets either.
>
> On Tue, Jul 13, 2010 at 3:07 PM, Paul Molodowitch  wrote:
>> Pretty much what the title says... I was wondering if there was a way anyone
>> knew of to find out which nodes will be duplicated when you
>> use duplicate(upstreamNodes=1).  It's fairly easy to get a list of the NEW
>> nodes, by getting a list of all nodes before and comparing with a list of
>> all nodes after; but I can't find a good way to get a list of which nodes
>> will be duplicated.
>> I can try to traverse the inputs myself, of course, but I'm worried about
>> special cases - for instance, the docs say it will duplicate parents of dag
>> nodes found during traversal, but it didn't seem to do that when I tested;
>> also, it seems 'undeletable' nodes, like 'persp', won't be duplicated, but
>> only have their connections duplicated.
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>

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


Re: [Maya-Python] list of nodes that will be duplicated with duplicate(upstreamNodes=1)?

2010-07-13 Thread John Creson
I'm not sure this is reliable, but you can Preview contents when you
go to create an Asset with Transform, and choose to include all
inputs, Including Shading Networks.
When you Apply this preview, you'll see selected all the nodes that
would end up in the asset had it been made.  (open Hypergraph
connections)

Default nodes will not go into assets either.

On Tue, Jul 13, 2010 at 3:07 PM, Paul Molodowitch  wrote:
> Pretty much what the title says... I was wondering if there was a way anyone
> knew of to find out which nodes will be duplicated when you
> use duplicate(upstreamNodes=1).  It's fairly easy to get a list of the NEW
> nodes, by getting a list of all nodes before and comparing with a list of
> all nodes after; but I can't find a good way to get a list of which nodes
> will be duplicated.
> I can try to traverse the inputs myself, of course, but I'm worried about
> special cases - for instance, the docs say it will duplicate parents of dag
> nodes found during traversal, but it didn't seem to do that when I tested;
> also, it seems 'undeletable' nodes, like 'persp', won't be duplicated, but
> only have their connections duplicated.
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] referenceQuery / getReferenceEdit bug - Pymel?

2010-07-09 Thread John Creson
The other thing to keep in mind around relative namespaces...

by default, expressions are executed in relative namespace...
This is good thing because you can use hard coded node names in your
child file and reference the scene into another as many times as you
like and each expression will find its intended nodes.
This can be turned off with a line at the top of the expression
namespace -relative false

just so you know, at this point particle expressions are not by
default using relative namespaces

also, if you don't like using hard-coded names...
you can use the (node) keyword in an expression and you will be
returned the name of the expression node - with which you may do what
you like to get to the nodes you need - walking message connections
perhaps? (relative or not depending on which mode it is in at the
moment - this can be important if you need to put something in an
expression that is evalDeferred - since by the time it gets around to
executing it, you'll be back in root relative mode)

On Fri, Jul 9, 2010 at 8:52 AM, Mark Jackson  wrote:
> Are you in 2011? I've just spend the last few weeks in deep discussions with
> Autodesk over a number of bugs in the way reference edits and specifically
> namespaces are handled. In 2010 the namespaces were all based on root space
> ':' and there were some issues with editing namespaces which left the edits
> incorrect and therefore broke the files.
>
> In 2011 they added the 'relative' flag and things are way more stable. What
> it doesn't say in the docs (or not that I can find) is that the namespaces
> are relative to the namespace of the refNode itself. We've always renamed
> the refNode when switching characters so that things are consistent, I could
> never understand why, when switching the referenced Namespace there wasn't
> some name handling performed on the refNode itself so that when you looked
> in the referenceEditor, things actually made sense.
>
> Anyway, with the relative flag all the namespace handling is solid, at
> last. you just have to remember that it's all 'relative' (or at least it
> is if you want to take advantage of it)
>
> If it's of any use to anybody here's our rename snippet... Like i say, this
> is after a lot of snag catching between us and Autodesk:
>
> namespace=fileRef.namespace
>     parentNS=pCore.Namespace(cmds.file(path, q=True, pns=True )[0])
>
>     if checkNSClashes:
>     # Resolve ns clashes prior to renaming
>
> NewNameSpace=NameSpaceUtils.ResolveNameSpaceClash(NewNameSpace,DebugPrint=True)
>
>     print '\nparentSpace : %s \npath : %s \nnewNS : %s' %
> (parentNS,path,NewNameSpace)
>     try:
>     if parentNS:
>     pCore.lockNode(refNode,lock=False)
>     pCore.rename(refNode, '%s:%sRN' %
> (str(parentNS),str(NewNameSpace)))
>     pCore.lockNode(refNode,lock=True)
>     pCore.namespace(set=parentNS) # move to the child's parent
> space
>     cmds.namespace(rel=True)
>     else:
>     pCore.lockNode(refNode,lock=False)
>     pCore.rename(refNode, '%sRN' % (str(NewNameSpace)))
>     pCore.lockNode(refNode,lock=True)
>
>     # rename the namespace using the relative namespace code form
> 2011
>     cmds.file(path,e=True,ns=NewNameSpace)
>     cmds.namespace(rel=False)
>     cmds.namespace(set=':')
>
>
> Not sure if that's of any help to anybody
>
>
> cheers
>
> Mark
>
>
>
> On 9 July 2010 12:08, Erkan Özgür Yılmaz  wrote:
>>
>> Hi Paul,
>>
>> What I wanted to achieve was to replace a referenced file with another,
>> where the first reference (the replaced one) is actually a reference inside
>> the newly replaced file.
>>
>> May be it is somehow a wrong pipeline design I did. In our current
>> pipeline, we reference the rig assets to shading assets and do the shading
>> in this scene. There is no problem if the rig asset doesn't have any
>> references ( ex. the model asset is not referenced to the rig asset but
>> imported ). So referencing the rig asset to shading asset, and replacing all
>> the references in animations with the shading asset and using the
>> changeEditTarget doesn't cause any problem.
>>
>> The problem is, when you have a rig asset that has some references to (
>> lets say ) model assets, then in animation scene when I replace the rig
>> asset with shading asset I loose all the edits, even I don't have a single
>> edit that I can change the target on. In any case I should be able to get
>> all the edits done in top level reference node as failed edits, but I
>> can't...
>>
>> So as a work around, I query all the edit commands, replace the assets and
>> apply the edits by changing the namespace in the MEL commands. With this
>> workaround I got errors in "parent" commands because the long name of the
>> objects are changing, and the other edits becomes invalid.
>>
>> So that's all I think :)
>>
>> and thank you for your inter

Re: [Maya-Python] addAttributeChangedCallback

2010-07-06 Thread John Creson
maybe there is a way to ignore the callback if a mouse button is
pressed down at the time. (or the alt key, if this is the main issue).

2010/7/6 Horvátth Szabolcs :
> Hi,
>
> I'm trying to track the attribute changes of a Maya scene using
> MNodeMessage.addAttributeChangedCallback but I have a hard time
> distinguishing attribute "drags", for example when the users zooming in
> using the camera (and calling the callback million times) and attribute
> settings, when the user sets a single attribute using the channel box or
> attribute editor. I would like to avoid using time counters and threads to
> do this, but I can't seem to find a solution that works out of the box with
> the Python API.
>
> Any tips are much appreciated!
>
> Cheers,
> Szabolcs
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Qt Designer and python

2010-07-05 Thread John Creson
This isn't pretty, but maybe there is something of value here...

The Text Edit input Widget in Qt Designer comes across as a scrollField in maya.
and the changeCommand flag will be triggered whenever this field loses focus.

So, I add a Dial Widget and a Text Edit input Widget, add my
changeCommand flag to the Text Edit input Widget and add two signals,
one after the other, both from the dial, on valueChanged(int), the
first on the textEdit to setFocus(), the second back on the dial to
setFocus().

I don't like moving the focus around like this.

On Mon, Jul 5, 2010 at 3:26 AM, Jamie Macdougall  wrote:
> ah thanks... that mel wrapper looks like it will help with getting the
> values directly from qt using the #1. Is there any documentation about this
> notation?
>
> with the other question, i connected the dial to a slider for example, and
> this works fine except there appears to be no way to run any command when
> the value changes, since none of the maya controls can trigger commands in
> response to changes caused by code.
>
>
>
>
> On Sun, Jul 4, 2010 at 9:28 PM, John Creson  wrote:
>>
>> actually(refering to the original question), check out the Tips and
>> tricks for scripters new to Python section under python in the 2011
>> docs...
>>
>> You can use the createMelWrapper function to register a Python
>> function as a MEL procedure. Then, when the MEL procedure is invoked,
>> it calls the Python function, passing any arguments it receives and
>> returning the function's result.
>>
>> For more information regarding this function, refer to the melutils.py
>> file in:
>>
>> C:\Program Files\Autodesk\Maya2011\Python\lib\site-packages\maya\mel
>>
>> You are right in understanding that if you use PyQt, you will need to
>> make that llibrary available to all computers that are to use your
>> scripts.
>>
>> The next is a possible off base suggestion:  Maybe your unsupported
>> dial can control another supported widget that works in Maya as you
>> wish.
>>
>>
>> On Sun, Jul 4, 2010 at 10:37 PM, Jamie Macdougall 
>> wrote:
>> >
>> > Yeah but so messy! I'm currently using a function to query the values of
>> > the
>> > widgets, but this is even more long winded!
>> > It's weird, Qt designer combined with loadUI seems like a very powerful
>> > and
>> > fast way to build custom tools, and there is almost no documentation on
>> > how
>> > to use it.
>> >
>> >
>> > Another question...
>> > Is there any way to make unsupported widgets like the dial trigger
>> > commands
>> > in Maya?
>> > so for example making the dial control the width of a cube
>> > dynamically...
>> > with the signal/slots they can be connected to supported widgets no
>> > problems, but this will not trigger any of the valueChanged type
>> > commands.
>> >
>> >
>> >
>> > Or should I just bite the bullet and go the whole pyQt route? and if I
>> > do,
>> > will that need to be compiled on all the workstation that use the pyqt
>> > scripts?
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Sun, Jul 4, 2010 at 7:10 PM, John Creson 
>> > wrote:
>> >>
>> >> You might want to make a short mel procedure that turns around and
>> >> passes the value correctly into a python function.
>> >>
>> >>
>> >>
>> >> On Sun, Jul 4, 2010 at 8:43 PM, Jamie Macdougall 
>> >> wrote:
>> >> > Hi...
>> >> >
>> >> > Pound one (#1) puts the current widgets value into a dynamic property
>> >> > in
>> >> > Qt
>> >> > Designer
>> >> > eg.
>> >> >
>> >> > property
>> >> > -command
>> >> >
>> >> > value
>> >> > someMel #1
>> >> >
>> >> > but this #1 symbol only seems to work for mel.
>> >> >
>> >> > Is there an equivalent for python? the pound symbol gives a syntax
>> >> > error
>> >> > when the command is python.
>> >> >
>> >> > property
>> >> > +enterCommand
>> >> >
>> >> > value
>> >> > "somePython( #1 )"
>> >> >
>> >> > I've been searching for hours without luck.
>> >> >
>> >> > --
>> >> > http://groups.google.com/group/python_inside_maya
>> >>
>> >> --
>> >> http://groups.google.com/group/python_inside_maya
>> >
>> > --
>> > http://groups.google.com/group/python_inside_maya
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Qt Designer and python

2010-07-04 Thread John Creson
actually(refering to the original question), check out the Tips and
tricks for scripters new to Python section under python in the 2011
docs...

You can use the createMelWrapper function to register a Python
function as a MEL procedure. Then, when the MEL procedure is invoked,
it calls the Python function, passing any arguments it receives and
returning the function's result.

For more information regarding this function, refer to the melutils.py file in:

C:\Program Files\Autodesk\Maya2011\Python\lib\site-packages\maya\mel

You are right in understanding that if you use PyQt, you will need to
make that llibrary available to all computers that are to use your
scripts.

The next is a possible off base suggestion:  Maybe your unsupported
dial can control another supported widget that works in Maya as you
wish.


On Sun, Jul 4, 2010 at 10:37 PM, Jamie Macdougall  wrote:
>
> Yeah but so messy! I'm currently using a function to query the values of the
> widgets, but this is even more long winded!
> It's weird, Qt designer combined with loadUI seems like a very powerful and
> fast way to build custom tools, and there is almost no documentation on how
> to use it.
>
>
> Another question...
> Is there any way to make unsupported widgets like the dial trigger commands
> in Maya?
> so for example making the dial control the width of a cube dynamically...
> with the signal/slots they can be connected to supported widgets no
> problems, but this will not trigger any of the valueChanged type commands.
>
>
>
> Or should I just bite the bullet and go the whole pyQt route? and if I do,
> will that need to be compiled on all the workstation that use the pyqt
> scripts?
>
>
>
>
>
>
> On Sun, Jul 4, 2010 at 7:10 PM, John Creson  wrote:
>>
>> You might want to make a short mel procedure that turns around and
>> passes the value correctly into a python function.
>>
>>
>>
>> On Sun, Jul 4, 2010 at 8:43 PM, Jamie Macdougall 
>> wrote:
>> > Hi...
>> >
>> > Pound one (#1) puts the current widgets value into a dynamic property in
>> > Qt
>> > Designer
>> > eg.
>> >
>> > property
>> > -command
>> >
>> > value
>> > someMel #1
>> >
>> > but this #1 symbol only seems to work for mel.
>> >
>> > Is there an equivalent for python? the pound symbol gives a syntax error
>> > when the command is python.
>> >
>> > property
>> > +enterCommand
>> >
>> > value
>> > "somePython( #1 )"
>> >
>> > I've been searching for hours without luck.
>> >
>> > --
>> > http://groups.google.com/group/python_inside_maya
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Qt Designer and python

2010-07-04 Thread John Creson
You might want to make a short mel procedure that turns around and
passes the value correctly into a python function.



On Sun, Jul 4, 2010 at 8:43 PM, Jamie Macdougall  wrote:
> Hi...
>
> Pound one (#1) puts the current widgets value into a dynamic property in Qt
> Designer
> eg.
>
> property
> -command
>
> value
> someMel #1
>
> but this #1 symbol only seems to work for mel.
>
> Is there an equivalent for python? the pound symbol gives a syntax error
> when the command is python.
>
> property
> +enterCommand
>
> value
> "somePython( #1 )"
>
> I've been searching for hours without luck.
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] query shading group assigned to instanced geomerty shape node?

2010-07-03 Thread John Creson
I'm not sure I recommend this, but maybe it can help out...

Particle instancing is simpler and doesn't cause these nodes and edits
to come into existence.

Assuming your object is at 0 0 0 when reffed in,
You can create a single particle at 0 0 0
Select your referenced in object, select you particle and choose
Particles > Instancer(replacement)

This creates a instancer node (and a single instance for each particle
- in this case 1).
The instancer node needs the particle and the transform input from
your reffed object.
The instancer can be transformed like a normal transform node, plus
there are some other attributes available.

You can do this as many times as you'd like with the same particle object.




On Sat, Jul 3, 2010 at 2:17 AM, Judah Baron  wrote:
> This question is slightly off topic, but still related.
> When a shape from a referenced file is instanced a bunch of groupid nodes
> are created relating to the shading network, and it is possible to assign
> new materials to this instance. I am wondering if there is a way to prevent
> the creation of these groupid nodes and all of the related edits. We have a
> usage case wherein we know that we will never need or want to modify the
> materials of one of these "library" shapes.  We have some cleanup code that
> removes all of these edits, but I would much rather find a more elegant
> solution.
>  thanks,
> -Judah
>
> On Fri, Jul 2, 2010 at 11:00 PM, John Creson  wrote:
>>
>> If you pass in the full name to the shape node from the instance you
>> are wishing to find the shading group of, you will get the correct
>> shader returned.
>>
>> import maya.cmds as cmds
>>
>> shapeNode = 'pSphere2|pSphereShape1'
>> shadingGroup = cmds.listConnections(shapeNode + '.instObjGroups')[0]
>> print shadingGroup
>>
>>
>>
>> On Fri, Jul 2, 2010 at 3:56 PM, Ling  wrote:
>> > Hi guys:
>> >
>> >  Normally when dealing with a non-instanced shape node, it's easy to
>> > get its shading group assighnment like:
>> >
>> >  shadingGroup = cmds.listConnections(shapeNode + '.instObjGroups[0]')
>> > [0]
>> >
>> >
>> >
>> >  but when it comes to instanced the shapde nodes, one shape node
>> > might have several shader assignments.
>> >
>> >  if I do a list connection to the instanced shape node,  all the
>> > shading groups assigned to it will be listed, and don't know which one
>> > is assigned to a particular transform node's children shape node.
>> >
>> >  so how can I query which shader is assign to a given transform node?
>> >
>> >
>> >  many thanks
>> >
>> >
>> >  -ling
>> >
>> > --
>> > http://groups.google.com/group/python_inside_maya
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] query shading group assigned to instanced geomerty shape node?

2010-07-02 Thread John Creson
If you pass in the full name to the shape node from the instance you
are wishing to find the shading group of, you will get the correct
shader returned.

import maya.cmds as cmds

shapeNode = 'pSphere2|pSphereShape1'
shadingGroup = cmds.listConnections(shapeNode + '.instObjGroups')[0]
print shadingGroup



On Fri, Jul 2, 2010 at 3:56 PM, Ling  wrote:
> Hi guys:
>
>  Normally when dealing with a non-instanced shape node, it's easy to
> get its shading group assighnment like:
>
>  shadingGroup = cmds.listConnections(shapeNode + '.instObjGroups[0]')
> [0]
>
>
>
>  but when it comes to instanced the shapde nodes, one shape node
> might have several shader assignments.
>
>  if I do a list connection to the instanced shape node,  all the
> shading groups assigned to it will be listed, and don't know which one
> is assigned to a particular transform node's children shape node.
>
>  so how can I query which shader is assign to a given transform node?
>
>
>  many thanks
>
>
>  -ling
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Re: pyQT help

2010-06-27 Thread John Creson
pumpThread is meant for pre-2011 Maya.
When Maya was not Built with Qt and one needed to negotiate which
event list is in control.
It is still in the release due to some customers needing those files
available where they were in previous releases.

The advice to eliminate the pumpthread and QtGui.Application from your
script is good.

If you'd like a script that can run inside of or outside of Maya, you
might be able to do a check before starting QtGui.Application, and if
you are inside of Maya, don't start start QtGui.Application.

JohnCreson
MayaQA


On Sun, Jun 27, 2010 at 10:07 PM, Amorano  wrote:
> There is no disadvantage in 2011 per se. It really depends on what you
> want to accomplish.
>
> For example: I have a ton of utilities that access various data stores
> which need to run inside and outside of Maya.
>
> Using a mechanism like pumpthread in pre-2011 world allows my PyQT
> apps to run without blowing up or stalling Maya.
>
> Obviously they have written a better way to hook your stuff (written
> with PyQT) into 2011, but we will most likely never use it because we
> need the extra control of running it outside of Maya.
>
>
>
> On Jun 26, 1:41 pm, efecto  wrote:
>> Hi there.
>>
>> Thanks for your solution.
>>
>> Eliminating a line with pumpThread seems to have worked!
>>
>> I'm very new to pumpThread.. what's the disadvantage of not having
>> pumpThread with pyQT in Maya? Why was it causing to crash?
>>
>> Thanks!
>>
>> On Jun 26, 11:58 pm, Jimmy Caron  wrote:
>>
>>
>>
>> > try this without pumpthread and no QtGui.Application. In maya 2011 all my
>> > custom gui work like this on Window and OSX and work well.
>>
>> > import sys
>> > from PyQt4 import QtGui as qt
>>
>> > hello = qt.QLabel("Hello world!", None)
>> > hello.show()
>>
>> > On Sat, Jun 26, 2010 at 6:14 AM, efecto  wrote:
>> > > Hello tehre.
>>
>> > > Thank you for your response.
>>
>> > > I have made the environment variable and now I seem to be able to
>> > > 'import pumpThread' without any errors.
>>
>> > > However, when I try to run a script in /devkit/ import mysample.py;
>> > > mysample.mysample() it launches an UI but then maya completely
>> > > freezes. Does anyone know how to solve this problem?
>>
>> > > Cheers,
>> > > D
>>
>> > > On Jun 26, 8:33 pm, Erkan Özgür Yılmaz  wrote:
>> > > > You need to add this path:
>>
>> > > > for windows:
>> > > > C:\Program Files\Autodesk\Maya2011\devkit\other\PyQtScripts\qt
>>
>> > > > for linux:
>> > > > /usr/autodesk/maya/devkit/other/PyQtScripts/qt
>>
>> > > > to your PYTHONPATH environment variable (in the system environments or 
>> > > > in
>> > > > Maya.env file), or append it to sys.path by
>> > > > import sys
>> > > > sys.append( the_path )
>>
>> > > > just before your code
>>
>> > > > E.Ozgur Yilmaz
>> > > > Lead Technical Director
>> > > > eoyilmaz.blogspot.comwww.ozgurfx.com
>>
>> > > > On Sat, Jun 26, 2010 at 8:59 AM, efecto  wrote:
>> > > > > Hello.
>>
>> > > > > I have been trying to run the example in Maya 2011 eg) devkit\other
>> > > > > \PyQtScripts\qt\myMakeStuff.py
>>
>> > > > > but I got some problems. I have also tried from zGUI.makeStuff import
>> > > > > Ui_Dialog but got the same error.
>>
>> > > > > import sys
>> > > > > from PyQt4 import QtCore, QtGui
>> > > > > from makeStuff import Ui_Dialog
>> > > > > import maya.cmds as cmds
>> > > > > import pumpThread as pt
>>
>> > > > > Error: ImportError: No module named makeStuff
>> > > > > # Error: ImportError: No module named pumpThread #
>>
>> > > > > This simple code works though.
>> > > > > import sys
>> > > > > from PyQt4 import QtGui as qt
>> > > > > app = qt.QApplication(sys.argv)
>> > > > > hello = qt.QLabel("Hello world!", None)
>> > > > > hello.show()
>>
>> > > > > Does anyone know what I'm missing?
>>
>> > > > > Thanks!
>>
>> > > > > --
>> > > > >http://groups.google.com/group/python_inside_maya
>>
>> > > --
>> > >http://groups.google.com/group/python_inside_maya- Hide quoted text -
>>
>> - Show quoted text -
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] multiprocessing module + Maya 2011 gui = sad face

2010-06-09 Thread John Creson
In this case, are you printing into a maya gui?
Perhaps, you need to try pushing the print to the main thread, so you
don't step on Maya's event loop.

import maya.utils
import maya.cmds
def doSphere( radius ): 
maya.cmds.sphere( radius=radius )
maya.utils.executeInMainThreadWithResult( doSphere, 5.0 )

On Wed, Jun 9, 2010 at 9:48 PM, Paul Molodowitch  wrote:
> So, given the issues with the GIL lock in python, I was excited about
> using the new multiprocessing module... especially since a back port
> is also available for python 2.5.
>
> I worked beautifully when I was playing around with it from mayapy -
> but as soon as I tried to use it in a GUI maya, maya crashed
> immediately.
>
> For the curious, here's what I was testing with:
>
> import multiprocessing
> from pprint import pprint
>
> p = multiprocessing.Process(target=pprint, args=(dir,))
> p.start()
> p.join()
>
> Does anyone know if I'm doing anything wrong here? As I said, it seems
> to work fine when done from a console.  Or does maya just not like
> multiprocessing?  I know that it can have some issues with threads...
> but given that things such as subprocess seem to work fine, I had hope
> for multiprocessing...
>
> - Paul
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] KeyError: 'MObjectHandle'

2010-06-04 Thread John Creson
or maybe

cmds.quit()
utils.executeDeferred('quit()')

On Fri, Jun 4, 2010 at 6:33 PM, John Creson  wrote:
> can you quit Maya first?
>
> cmds.quit()
> quit()
>
> On Fri, Jun 4, 2010 at 6:31 PM, Chris G  wrote:
>> Is there any way to tell python to clean up for exit without
>> terminating the process ?
>> Then you could flush everything and get all your finalizers called
>> before calling sys._exit
>>
>>
>> On Fri, Jun 4, 2010 at 5:55 PM, Paul Molodowitch  wrote:
>>> Hey Yukio - I can confirm your PyNode problem - it looks like it's
>>> having a problem identifying the node type for some reason.  I'll take
>>> a closer look into it, hopefully have a fix up in the repo soon.
>>>
>>> As to your second question:
>>>
>>> YES!
>>>
>>> I made a post about that too
>>> (http://groups.google.com/group/python_inside_maya/browse_thread/thread/87e342e461b0cd14/51acba49d8c4efeb?lnk=gst&q=segmentation#51acba49d8c4efeb),
>>> and later submitted a report to Autodesk about it.  They said they
>>> were able to confirm the problem on their end as well.  Their
>>> suggestion, however, was to use os._exit(0).
>>>
>>> My response was:
>>>
>>> Hmm... well, I can confirm that os._exit will not raise a seg fault,
>>> like sys.exit(); unfortunately, it raises other problems - for
>>> instance, stdout / stderr buffers are not always correctly flushed.
>>> This is because, unforuntely, os._exit is not a "clean" exit, but
>>> quite the opposite - it does none of the standard python cleanup stuff
>>> at exit, but instead is more akin to a process kill (except you can
>>> specify an exit code).  Additionally, we still have the problem of
>>> ungraceful exits when an uncaught exception is raised.
>>>
>>> Is there no way to signal the maya application to terminate from
>>> within python?  This could be useful on it's own right, but would also
>>> solve this issue - maya.standalone.initialize could register this maya
>>> termination command to be called on exit with the atexit.register
>>> method...
>>>
>>> Anyway, if you would like this fixed, please submit it to them as well! =)
>>>
>>> - Paul
>>>
>>> On Fri, Jun 4, 2010 at 3:19 AM,   wrote:
>>>> Hi there
>>>>
>>>> we`ve got some errors with some nodes and pymel-1.0.2
>>>>
>>>> as far the following nodes will raise KeyError: 'MObjectHandle'
>>>> [u'angleDimension', u'clusterFlexorShape', u'collisionModel', u'dynHolder',
>>>> u'oldNormalConstraint', u'oldTangentConstraint']
>>>>
>>>> for example:
>>>>
>>>> import maya.cmds as mc
>>>> from pymel.core import PyNode
>>>>
>>>> testNode = mc.createNode('angleDimension')
>>>> test = PyNode(testNode)
>>>> test.name()
>>>>
>>>> or:
>>>> import maya.cmds as mc
>>>> from pymel.core import PyNode
>>>> failed = []
>>>> for node in [u'angleDimension', u'clusterFlexorShape', u'collisionModel',
>>>> u'dynHolder', u'oldNormalConstraint', u'oldTangentConstraint']:
>>>>    testNode = mc.createNode(node)
>>>>    try:
>>>>        test = PyNode(testNode)
>>>>        print test.name()
>>>>    except:
>>>>        failed.append(node)
>>>>
>>>>    mc.delete(testNode)
>>>>
>>>> print "failed: "
>>>> print failed
>>>>
>>>> anybody got the same issues?
>>>>
>>>> and now for something completely different:
>>>>
>>>> anybody having seg faults with mayapy (2011) on linux after
>>>> import maya.standalone
>>>> maya.standalone.initialize()
>>>> 
>>>> ...
>>>> quit()
>>>>
>>>> the famous Signal: 11
>>>>
>>>> cheers,
>>>> yukio
>>>>
>>>> --
>>>> http://groups.google.com/group/python_inside_maya
>>>
>>> --
>>> http://groups.google.com/group/python_inside_maya
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>

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


Re: [Maya-Python] KeyError: 'MObjectHandle'

2010-06-04 Thread John Creson
can you quit Maya first?

cmds.quit()
quit()

On Fri, Jun 4, 2010 at 6:31 PM, Chris G  wrote:
> Is there any way to tell python to clean up for exit without
> terminating the process ?
> Then you could flush everything and get all your finalizers called
> before calling sys._exit
>
>
> On Fri, Jun 4, 2010 at 5:55 PM, Paul Molodowitch  wrote:
>> Hey Yukio - I can confirm your PyNode problem - it looks like it's
>> having a problem identifying the node type for some reason.  I'll take
>> a closer look into it, hopefully have a fix up in the repo soon.
>>
>> As to your second question:
>>
>> YES!
>>
>> I made a post about that too
>> (http://groups.google.com/group/python_inside_maya/browse_thread/thread/87e342e461b0cd14/51acba49d8c4efeb?lnk=gst&q=segmentation#51acba49d8c4efeb),
>> and later submitted a report to Autodesk about it.  They said they
>> were able to confirm the problem on their end as well.  Their
>> suggestion, however, was to use os._exit(0).
>>
>> My response was:
>>
>> Hmm... well, I can confirm that os._exit will not raise a seg fault,
>> like sys.exit(); unfortunately, it raises other problems - for
>> instance, stdout / stderr buffers are not always correctly flushed.
>> This is because, unforuntely, os._exit is not a "clean" exit, but
>> quite the opposite - it does none of the standard python cleanup stuff
>> at exit, but instead is more akin to a process kill (except you can
>> specify an exit code).  Additionally, we still have the problem of
>> ungraceful exits when an uncaught exception is raised.
>>
>> Is there no way to signal the maya application to terminate from
>> within python?  This could be useful on it's own right, but would also
>> solve this issue - maya.standalone.initialize could register this maya
>> termination command to be called on exit with the atexit.register
>> method...
>>
>> Anyway, if you would like this fixed, please submit it to them as well! =)
>>
>> - Paul
>>
>> On Fri, Jun 4, 2010 at 3:19 AM,   wrote:
>>> Hi there
>>>
>>> we`ve got some errors with some nodes and pymel-1.0.2
>>>
>>> as far the following nodes will raise KeyError: 'MObjectHandle'
>>> [u'angleDimension', u'clusterFlexorShape', u'collisionModel', u'dynHolder',
>>> u'oldNormalConstraint', u'oldTangentConstraint']
>>>
>>> for example:
>>>
>>> import maya.cmds as mc
>>> from pymel.core import PyNode
>>>
>>> testNode = mc.createNode('angleDimension')
>>> test = PyNode(testNode)
>>> test.name()
>>>
>>> or:
>>> import maya.cmds as mc
>>> from pymel.core import PyNode
>>> failed = []
>>> for node in [u'angleDimension', u'clusterFlexorShape', u'collisionModel',
>>> u'dynHolder', u'oldNormalConstraint', u'oldTangentConstraint']:
>>>    testNode = mc.createNode(node)
>>>    try:
>>>        test = PyNode(testNode)
>>>        print test.name()
>>>    except:
>>>        failed.append(node)
>>>
>>>    mc.delete(testNode)
>>>
>>> print "failed: "
>>> print failed
>>>
>>> anybody got the same issues?
>>>
>>> and now for something completely different:
>>>
>>> anybody having seg faults with mayapy (2011) on linux after
>>> import maya.standalone
>>> maya.standalone.initialize()
>>> 
>>> ...
>>> quit()
>>>
>>> the famous Signal: 11
>>>
>>> cheers,
>>> yukio
>>>
>>> --
>>> http://groups.google.com/group/python_inside_maya
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Script Job event

2010-05-21 Thread John Creson
you can use the listEvents flag

scriptJob -listEvents

This causes the command to return a string array containing the names
of all existing events. Below is the descriptions for all the existing
events:


If they are there, they will show up.

On Fri, May 21, 2010 at 6:00 PM, ynedelin  wrote:
> this is excerpt from 2010 layerEditor.mel
>
>        scriptJob -compressUndo true -permanent -parent $parentLayout -event
> animLayerRebuild ("rebuildAnimLayerEditor(\""+$toolName+"\")");
>        scriptJob -compressUndo true -permanent -parent $parentLayout -event
> animLayerRefresh ("updateEditorFeedbackAnimLayers(\""+$toolName
> +"\")");
>        scriptJob -compressUndo true -permanent -parent $parentLayout -event
> animLayerAnimationChanged ("onAnimLayersAnimationChanged(\""+$toolName
> +"\")");
>        scriptJob -compressUndo true -permanent -parent $parentLayout -event
> animLayerLockChanged ("onAnimLayersLockChanged(\""+$toolName+"\")");
>        scriptJob -compressUndo true -permanent -parent $parentLayout -event
> animLayerGhostChanged ("updateEditorFeedbackAnimLayers(\""+$toolName
> +"\")");
>
> check out the -event flag values I do not see any of them in the
> ScriptJob Docs.
> Any idea if there is a list of unpublished events that can be detected
> by a script job?
>
> yury
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Re: python startup abnormally slow?

2010-04-20 Thread John Creson
Nope, that's pertinent.

I imagine the way you are working around this is putting one userSetup.py in
2009/scripts and one in 2011/scripts ?

Or are you running a check in your universal userSetup.py before
loading in PyMel?

There are some nice things about being able to have multiple
userSetup.py files, this is not one of them...

On Tue, Apr 20, 2010 at 1:58 PM, Kevin W  wrote:
> Turns out there was another userSetup.py left over from pymel 0.92 for
> Maya 2009. When I was launching 2011, it would see two userSetup.py,
> and try to import pymel 0.92 as well as the pymel 1.0 that comes with
> 2011. I now have separate userSetup.py for 2009 and 2011, although I
> should move everything over to 1.0 soon
>
> Next question will be pertinent, I swear ;)
>
> On Apr 20, 10:08 am, Chris G  wrote:
>> You could also try starting mayapy with '-v' verbose flag.
>>
>>
>>
>> On Tue, Apr 20, 2010 at 12:56 PM, John Creson  wrote:
>> > is there a __init__.py in your 'C:/PRODUCTION/SCRIPTS/python that has
>> > something inside?
>> > or perhaps there is a userSetup.py in there that is appending that
>> > folder infinitely?
>>
>> > On Tue, Apr 20, 2010 at 4:05 AM, Kevin W  wrote:
>> > > I'm trying to import some custom modules when Maya loads, but it seems
>> > > to keep maya from loading.
>>
>> > > At first I tried adding a few lines to userSetup.py
>>
>> > > import sys
>> > > sys.path.append('C:/PRODUCTION/SCRIPTS/python')
>>
>> > > I then tried
>> > > PYTHONPATH = C:\PRODUCTION\SCRIPTS\python;
>>
>> > > as a environmental variable in Windows 7 as well as a variable in my
>> > > Maya.env file.
>>
>> > > No matter which way, Maya doesn't finish loading (or start loading,
>> > > really) and I wind up killing it.
>>
>> > > I tried each method one at a time. I haven't hard any problems with
>> > > using custom paths for MEL scripts, or using environment variables to
>> > > use python interactively. When i run the two lines of python, I can
>> > > then load my modules as expected.
>>
>> > > Any thoughts?
>>
>> > > Thanks,
>>
>> > > Kevin
>>
>> > > --
>> > >http://groups.google.com/group/python_inside_maya
>>
>> > --
>> >http://groups.google.com/group/python_inside_maya
>>
>> --http://groups.google.com/group/python_inside_maya
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] python startup abnormally slow?

2010-04-20 Thread John Creson
is there a __init__.py in your 'C:/PRODUCTION/SCRIPTS/python that has
something inside?
or perhaps there is a userSetup.py in there that is appending that
folder infinitely?

On Tue, Apr 20, 2010 at 4:05 AM, Kevin W  wrote:
> I'm trying to import some custom modules when Maya loads, but it seems
> to keep maya from loading.
>
> At first I tried adding a few lines to userSetup.py
>
> import sys
> sys.path.append('C:/PRODUCTION/SCRIPTS/python')
>
> I then tried
> PYTHONPATH = C:\PRODUCTION\SCRIPTS\python;
>
> as a environmental variable in Windows 7 as well as a variable in my
> Maya.env file.
>
> No matter which way, Maya doesn't finish loading (or start loading,
> really) and I wind up killing it.
>
> I tried each method one at a time. I haven't hard any problems with
> using custom paths for MEL scripts, or using environment variables to
> use python interactively. When i run the two lines of python, I can
> then load my modules as expected.
>
> Any thoughts?
>
> Thanks,
>
> Kevin
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] What version of python is maya 2011 using

2010-04-02 Thread John Creson
No, there should be no major transition issues between these versions
of Python in Maya.

Py3k is another story, but it is not in Maya2011.

A new Maya startup flag, -3, has been added to enable Python 3000
compatibility warnings.
So, if you start maya from the command line

maya -3

you will see Python 3000 compatibiltiy warnings when running your scripts.


On Fri, Apr 2, 2010 at 2:42 PM, zoshua  wrote:
> Good info to know.
>
> ...Has autodesk/anyone written up a doc about any transition issues from 2k9
> (py 2.5) over to 2k10/11 (py 2.6)?
>
> (I am still on 2k9)
>
> +j
>
> --
> http://groups.google.com/group/python_inside_maya

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

To unsubscribe, reply using "remove me" as the subject.


Re: [Maya-Python] suppressing pymel's mel output?

2010-03-23 Thread John Creson
this seems to work better, and it doesn't remove all the mel from your
previous history in the panel, just the bit you don't want.



from pymel.core import *

def quietThis(this):
myRep = mel.eval('$temp = $temp = $gCommandReporter ')
origText = cmdScrollFieldReporter (myRep, query = True , text = True)
cmdScrollFieldReporter (myRep, edit = True , clear=True)
cmdScrollFieldReporter (myRep, edit = True , filterSourceType = "mel")
exec(this)
niceText = cmdScrollFieldReporter (myRep, query = True , text = True)
cmdScrollFieldReporter (myRep, edit = True , filterSourceType = "")
cmdScrollFieldReporter (myRep, edit = True , text = (origText+niceText))


quietThis("shader, shaderSG=createSurfaceShader('surfaceShader')")





On Tue, Mar 23, 2010 at 9:17 PM, John Creson  wrote:
> this might help, but it needs a better way to grab the name of the history 
> panel
>
> from pymel.core import *
>
> cmdScrollFieldReporter (
> 'scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|formLayout37|formLayout39|paneLayout1|cmdScrollFieldReporter1',
> edit = True, fst = "mel")
>
> shader, shaderSG=createSurfaceShader('surfaceShader')
>
> myText = cmdScrollFieldReporter (
> 'scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|formLayout37|formLayout39|paneLayout1|cmdScrollFieldReporter1',
> query = True, text=True)
>
>
> cmdScrollFieldReporter (
> 'scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|formLayout37|formLayout39|paneLayout1|cmdScrollFieldReporter1',
> edit = True, fst = "")
> cmdScrollFieldReporter (
> 'scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|formLayout37|formLayout39|paneLayout1|cmdScrollFieldReporter1',
> edit = True, text = myText)
>
>
>
>
>
> On Tue, Mar 23, 2010 at 1:31 PM, Chad Dombrova  wrote:
>> that output is caused by the mel script renderCreateNode. there's probably
>> some evalEcho's in there.
>>
>> try this:
>> renderCreateNode("-asShader","surfaceShader", "surfaceShader", "",
>> 0,0,0,1,0,"" )
>>
>> -chad
>>
>>
>> On Mar 23, 2010, at 9:47 AM, Chris G wrote:
>>
>>> Is there a way to suppress the mel code which is echoed to the history
>>> pane for something like:
>>> from pymel.core import *
>>> shader, shaderSG=createSurfaceShader('surfaceShader')
>>>
>>> Which results in:
>>> shadingNode -asShader surfaceShader;
>>> // Result: surfaceShader9077 //
>>> sets -renderable true -noSurfaceShader true -empty -name
>>> surfaceShader9077SG;
>>> // Result: surfaceShader9077SG //
>>> connectAttr -f surfaceShader9077.outColor
>>> surfaceShader9077SG.surfaceShader;
>>> // Result: Connected surfaceShader9077.outColor to
>>> surfaceShader9077SG.surfaceShader. //
>>>
>>> Thanks
>>>
>>> --
>>> http://groups.google.com/group/python_inside_maya
>>>
>>> To unsubscribe from this group, send email to
>>> python_inside_maya+unsubscribegooglegroups.com or reply to this email with
>>> the words "REMOVE ME" as the subject.
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>>
>> To unsubscribe from this group, send email to
>> python_inside_maya+unsubscribegooglegroups.com or reply to this email with
>> the words "REMOVE ME" as the subject.
>>
>

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

To unsubscribe from this group, send email to 
python_inside_maya+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.


Re: [Maya-Python] suppressing pymel's mel output?

2010-03-23 Thread John Creson
this might help, but it needs a better way to grab the name of the history panel

from pymel.core import *

cmdScrollFieldReporter (
'scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|formLayout37|formLayout39|paneLayout1|cmdScrollFieldReporter1',
edit = True, fst = "mel")

shader, shaderSG=createSurfaceShader('surfaceShader')

myText = cmdScrollFieldReporter (
'scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|formLayout37|formLayout39|paneLayout1|cmdScrollFieldReporter1',
query = True, text=True)


cmdScrollFieldReporter (
'scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|formLayout37|formLayout39|paneLayout1|cmdScrollFieldReporter1',
edit = True, fst = "")
cmdScrollFieldReporter (
'scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|formLayout37|formLayout39|paneLayout1|cmdScrollFieldReporter1',
edit = True, text = myText)





On Tue, Mar 23, 2010 at 1:31 PM, Chad Dombrova  wrote:
> that output is caused by the mel script renderCreateNode. there's probably
> some evalEcho's in there.
>
> try this:
> renderCreateNode("-asShader","surfaceShader", "surfaceShader", "",
> 0,0,0,1,0,"" )
>
> -chad
>
>
> On Mar 23, 2010, at 9:47 AM, Chris G wrote:
>
>> Is there a way to suppress the mel code which is echoed to the history
>> pane for something like:
>> from pymel.core import *
>> shader, shaderSG=createSurfaceShader('surfaceShader')
>>
>> Which results in:
>> shadingNode -asShader surfaceShader;
>> // Result: surfaceShader9077 //
>> sets -renderable true -noSurfaceShader true -empty -name
>> surfaceShader9077SG;
>> // Result: surfaceShader9077SG //
>> connectAttr -f surfaceShader9077.outColor
>> surfaceShader9077SG.surfaceShader;
>> // Result: Connected surfaceShader9077.outColor to
>> surfaceShader9077SG.surfaceShader. //
>>
>> Thanks
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>>
>> To unsubscribe from this group, send email to
>> python_inside_maya+unsubscribegooglegroups.com or reply to this email with
>> the words "REMOVE ME" as the subject.
>
> --
> http://groups.google.com/group/python_inside_maya
>
> To unsubscribe from this group, send email to
> python_inside_maya+unsubscribegooglegroups.com or reply to this email with
> the words "REMOVE ME" as the subject.
>

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

To unsubscribe from this group, send email to 
python_inside_maya+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.


Re: [Maya-Python] Re: Maya 2011 and QT

2010-03-18 Thread John Creson
Yes and Yes

On Thu, Mar 18, 2010 at 6:10 PM, shawnpatapoff  wrote:
> Just so understand it,
>
> cmds.window('myWin')
> cmds.columnLayout('myColumn')
> cmds.button('myButton')
> cmds.showWindow('myWin')
>
> Is the same but instead of using ELF it's now using QT under the hood.
> If this is the case, does that potentially mean more user end control
> than before?
>
> -shawn
>
> On Mar 18, 2:48 pm, Ofer Koren  wrote:
>> - "WIth PyQt or a C++ plugin, technically yes [embed maya qt widgets within
>> a custom PyQt widget]"
>> - "You need pyqt or a c++ plugin to get at the qt objects themselves"
>>
>> How does that work exactly? can you show an example?
>>
>> - Oferwww.mrbroken.com
>>
>> On Thu, Mar 18, 2010 at 8:02 AM, Chris G  wrote:
>> > On Thu, Mar 18, 2010 at 4:21 AM, Ofer Koren  wrote:
>>
>> >> A couple of Maya 2011/Qt questions:
>> >> - Is it possible to embed maya qt widgets within a custom PyQt widget?
>>
>> > WIth PyQt or a C++ plugin, technically yes, but how well this would work
>> > would probably be case by case because maya qt widgets aren't designed to 
>> > be
>> > put into custom ui like that.  There is a new command which will load a qt
>> > designer xml file and create a maya qt ui based on it, that approach might
>> > work better than creating a pure custom parent widget.  What did you have 
>> > in
>> > mind?
>>
>> >> - Are the Qt methods/attributes of Maya widgets accessible from python? or
>> >> is it still through string-based mel commands (where basic datatypes are
>> >> passed around instead of actual Qt objects)?
>>
>> > No, it the same commands as before, just with qt implementation under the
>> > hood.  You need pyqt or a c++ plugin to get at the qt objects themselves.
>>
>> > - chris
>>
>> > --
>> >http://groups.google.com/group/python_inside_maya
>>
>>
>
> --
> http://groups.google.com/group/python_inside_maya
>
> To unsubscribe from this group, send email to 
> python_inside_maya+unsubscribegooglegroups.com or reply to this email with 
> the words "REMOVE ME" as the subject.
>

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

To unsubscribe from this group, send email to 
python_inside_maya+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.


Re: [Maya-Python] Re: Maya 2011 and QT

2010-03-17 Thread John Creson
Just wondering...

Has anyone made a better blind data editor?

On Wed, Mar 17, 2010 at 6:00 PM, shawnpatapoff  wrote:
> I for one am pushing hard for a 2011 upgrades here at work. We're very
> python heavy and have been frustrated with Mayas old UI to the point
> that we do a lot of PyQt outside. So anything to give me more ammo
> would be very excellent as I want to be more mayacentric.
>
> Cheers.
>
> On Mar 17, 2:40 pm, John Creson  wrote:
>> these examples were created for use with non-qt versions of maya, some
>> customers still wanted them in, so they were left in Maya2011.
>>
>> I would love to get better examples, that show off some of the great
>> stuff you can do with PyQt inside Maya.
>>
>> Anyone have something they'd like to share?
>>
>> On Wed, Mar 17, 2010 at 4:09 PM, zoshua  wrote:
>> > Please tell me you are kidding!
>>
>> > --
>> >http://groups.google.com/group/python_inside_maya
>>
>>
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Maya 2011 and QT

2010-03-17 Thread John Creson
these examples were created for use with non-qt versions of maya, some
customers still wanted them in, so they were left in Maya2011.

I would love to get better examples, that show off some of the great
stuff you can do with PyQt inside Maya.

Anyone have something they'd like to share?

On Wed, Mar 17, 2010 at 4:09 PM, zoshua  wrote:
> Please tell me you are kidding!
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] maya, python, and unit testing

2010-03-17 Thread John Creson
If you'd like to avoid boilerplate testing code, you might also look
at using decorators and
py.test
there was a class at PyCon, and it's up and running again.

http://pycon.blip.tv/file/1956938/

Here are all the talks at Pycon
http://pycon.blip.tv/posts?view=archive&nsfw=dc

I'm interested in finding out more about how people are testing their pipelines.

JohnCreson

On Wed, Mar 17, 2010 at 11:14 AM, Chad Dombrova  wrote:
>> the problem is, most of my code is "create or modify something in the scene" 
>> rigging utilities, e.g., create ik/fk/elbowik setup, calculate corrective 
>> shape, calculate blendshape inbetweens for smooth interpolation. the only 
>> way i see to test them is to actually load sample scene, execute the code, 
>> then SOMEHOW test validity of the created data
>
> yeah, testing is tedious, but you pretty much hit the nail on the head as far 
> as workflow.  with a unittest class, each class has a setUp and tearDown 
> method, which you can use to ensure that you have the proper testing 
> environment setup for each test.
>
>> Anyway, the short version the question: what kind of automated testing you 
>> guys have used, how that works, and what are cons and pros?
>
> we use 'nose', which makes running the tests a lot easier.  nose will search 
> a python package for anything that looks like a test -- unittest classes, 
> doctest strings, and functions named 'test*' -- and run them.  this is much 
> more convenient than explicitly tying together all of your unittest classes 
> into a test suite.  nose also supports generators as tests, so if the problem 
> you are trying to test for can be tested in a semi-automatic way, this makes 
> life a lot easier.  for example, pymel uses generators to create loop through 
> its database of nodes and methods and create a test for every get/set method 
> pair ( ex. getFocalLength, setFocalLength ).
>
> there's also pythoscope http://pythoscope.org/ which i've never used but 
> which, if you're testing classes, can help to write a lot of your boilerplate 
> testing code.
>
> good luck!
>
> -chad
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Re: PyMEL included with Maya 2011

2010-03-11 Thread John Creson
It's True!

PyMEL is included with Maya2011

Start Maya;
open the scriptEditor;

import pymel.core as pm
...

I like namespaces :)

JohnCreson
Autodesk
MayaQA

2010/3/11 Miguel González Viñé :
> Congratulations guys!
> I was dreaming about this!
>
>
>
> 2010/3/11 Horvátth Szabolcs :
>> You guys rock! And I'm off the fence for sure.
>>
>> Cheers,
>> Szabolcs
>>
>>
>>> having trouble believing the news? it's for real. do you really think i'd
>>> make all this up? :)
>>> -chad
>>>
>>>
>>>
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] PyMEL included with Maya 2011

2010-03-09 Thread John Creson
I've been holding my breath all day!

PyMEL is here and official and everyone can make it even better.

Congratulations Chad and everyone who is working on PyMEL!

John Creson

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


Re: [Maya-Python] Maya Python and threads

2010-03-05 Thread John Creson
take a look at the pumpThread module in:

C:\Program Files\Autodesk\Maya2011\devkit\other\PyQtScripts\qt

It doesn't have to make lots of threads like that example, but it can
send one out the same way.
just make sure to use the maya.utils.executeInMainThreadWithResult
function to return any "finished" message back to Maya.
Also, have you thought about using multiprocessing module that is
included in 2.6?
The multiprocessing module will actually spawn off another python
instance to complete your task in - haven't tried this in Maya yet.

2010/3/5 Horvátth Szabolcs :
> Hi,
>
> I'd like to execute a long running command from Maya using Python as a
> separate thread, to avoid blocking the UI . The command does not have to
> interact with Maya or
> use any of Maya's API or commands, although it would be nice to get the
> output in the output window. Are there any tricks for using threading in
> Maya?
>
> Thanks in advance.
>
> Cheers,
> Szabolcs
>
> --
> http://groups.google.com/group/python_inside_maya

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


Re: [Maya-Python] Re: Generate Maya Python pi files for Wing

2010-01-07 Thread John Creson
Thanks Chad!

-JohnC

On Thu, Jan 7, 2010 at 3:29 AM, Chad Dombrova  wrote:
> sorry, i've been pretty swamped.  as adam pointed out it is currently in our 
> github repo.  the maintenance package is not included in the released zips 
> because it contains scripts we use to prepare the releases, which is only of 
> interest to pymel developers.  in the next beta of 1.0 we'll be including 
> both .py and .pi stub files, so there will no longer be any need for end 
> users to worry themselves about generating them.
>
> -chad
>
>
>
>
> On Jan 6, 2010, at 2:01 PM, ryant wrote:
>
>> I searched for maintainence in the pymel documentation and it returned
>> no results talking about the maintainence module. I also imported the
>> pymel module in maya and none of the modules show a maintainence
>> module. Can you give more detail of where to find it?
>>
>> Ryan
>>
>> On Jan 5, 12:22 pm, Miguel González Viñé  wrote:
>>> Thanks Chad,
>>>
>>> I've tried your examples and works all but c2 (a2 and b2 work too),
>>> even if I haven't set the "pi" folder in Wing preferences. It looks
>>> like Wing examine the python modules you import. I've tried it in
>>> ecclipse too and a2 and b2 works perfectly. I don't know why this
>>> doesn't work for you.
>>>
>>> In the Wing case, I think this is happening because pymel is creating
>>> functions and classes dynamically. Maybe I'm gonna say a nonsense but
>>> If instead of creating functions "on the fly", pymel creates function
>>> to a file from maya.cmds, etc, writing the help and all the code, when
>>> you install pymel, like the maintenance module but with functions and
>>> classes, it will work, at least for wing, I don't know if it'll work
>>> for ecclipse.
>>>
>>> But maybe this is a crazy thing.
>>>
>>> Best,
>>> Miguel.
>>>
>>> On Tue, Jan 5, 2010 at 8:12 PM, Chad Dombrova  wrote:
>>>
 just did some experimenting and talking with Paul.  eclipse supports
 completion of assigned variables, but only if those variables were directly
 assigned an instantiated class.
>>>
 for example, the following variables will support completion:
>>>
 a1 = str('bar')
 b1 = list()
 c1 = pm.nt.Transform('bar')
>>>
 but these will not:
>>>
 a2 = 'bar'
 b2 = []
 c2 = pm.sphere()
>>>
 however, since i'm not a wing user i don't know if what you are trying to 
 do
 is supported or not.  ipython supports completion for variables assigned in
 the latter fashion, so i know it is technically possible.  pymel is a
 complex beast, so first try playing around with built-in python types ( for
 example, the variables a1, b1, a2, and b2, above) and let us know what you
 find out.
>>>
 -chad
>>>
> Thanks!
>>>
> On Tue, Jan 5, 2010 at 6:45 PM, Chad Dombrova  wrote:
>>>
>> I should also note, for anyone working on the pymel project, that
>> "maintainence" is actually spelled "maintenance"
>>>
>> wow, that's embarrassing.  4 years of liberal arts college down the drain
>>  :)  glad we beta tested!
>> -chad
>>>
>> On Tue, Jan 5, 2010 at 10:25 AM, Ian Jones  
>> wrote:
>>>
>>> Yes. Though it won't be installed via easy_install. Only a manual one.
>>> You can download pymel and just copy the maintainence module into your
>>> path to create them with:
>>>
>>> import maintainence
>>> maintainence.stubs.pymelstubs(extension='pi')
>>>
>>> Ian
>>>
>>> I can also post
>>> 2010/1/5 Miguel González Viñé :
>>>
 Hi Chad, is it included in beta2? I can't find the script. Is there
 another beta released?
 Thanks!
>>>
 On Tue, Jan 5, 2010 at 5:45 AM, Chad Dombrova 
 wrote:
>>>
> a script is included with the development version of pymel 1.0 for
> creating reliable pi files for both maya and pymel packages.
>>>
> On Jan 4, 2010, at 11:08 PM, ryant wrote:
>>>
>> I am looking into how to generate the pi files that Wing needs for
>> auto completion. I am unsure how to use the generate_pi.py file that
>> comes with Wing to do this. The files I need to convert I believe are
>> the ones at this path:
>>>
>> C:\Program Files\Autodesk\Maya2010\Python\lib\site-packages\maya\
>>>
>> If I want to generate the maya.cmds pi file where is the .pyc file
>> for
>> maya.cmds?
>>>
>> When I use the generate_pi.py file it doesnt generate anything
>> useful.
>> Using the command prompt I type this in:
>>>
>> C:\Program Files\Autodesk\Maya2010\Python\lib\site-packages\maya>
>> python "C:\Program Files\Wing IDE 3.2\src\wingutils\generate_pi.py"
>> OpenMaya.pyc OpenMaya.pi
>>>
>> This then results in the following in the Command Prompt:
>>>
>> Traceback (most recent call last):
>>  File "C:\Program Files\Wing IDE 3.2\src\wingutils\generate_pi.py",
>> line 1028,
>> in 
>>   ProcessModule(modna

[Maya-Python] Re: Writing Commands

2009-11-04 Thread John Creson

look in

Autodesk\Maya2010\devkit\plug-ins\scripted

On Wed, Nov 4, 2009 at 1:52 PM, Chad Vernon  wrote:
> There should also be some samples in the maya devkit.
>
> On Wed, Nov 4, 2009 at 10:50 AM, Brandon Harris 
> wrote:
>>
>> Very awesome!!! thank you very much. This should get me on the right
>> track.
>>
>> On Nov 4, 12:38 pm, Adam Mechtley  wrote:
>> > Hi Brandon,
>> >
>> > I have a couple of basic ones on my website that could be
>> > helpful:http://www.6ixsetstudios.com/tools/maya/#PythonCmd_HipConstraint
>> >
>> > On Wed, Nov 4, 2009 at 12:25 PM, Brandon Harris
>> > wrote:
>> >
>> >
>> >
>> > > I've been digging around trying to get information on creating
>> > > commands using python, but haven't come up with much. So does anyone
>> > > have a basic plugin/command written in python that I could look at to
>> > > see how they are constructed. All of the information I have deals with
>> > > this are written in C++ and the conversion from C++ to python is a
>> > > difficult one for myself. Any information that can be shared would be
>> > > great. Even an incredibly simple plugin would be enough to get me
>> > > going. thanks!
>> >
>> >
>>
>
>
> >
>

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



[Maya-Python] Re: PyQt - pumpThread (threads in Maya crash)

2009-10-27 Thread John Creson

are you starting a qapp in your code?
maya2008 doesn't like living qapps and sometimes gets into fights
possibly the Browser class is doing it for you?
starting more than one qapp will quickly blip maya from your screen

and, until someone works it out, don't try pumpthread on a mac - it
doesn't work around the issue enough.

On Tue, Oct 27, 2009 at 3:27 PM, Taylor Carrasco  wrote:
> Probably a basic threading question -
>
> I'm using the default pumpThread module in the following manner...
> if sys.executable.endswith("maya.bin"):
>     import pumpThread
>
> class Browser(QMainWindow):
>     def __init__(self):
>     QMainWindow.__init__(self)
>      omitted code .
>
>
> # Launch of PyQt widget inside Maya
> pumpThread.initializePumpThread()
> QtWin = Browser()
> QtWin.show()
>
>
> On the next import of pumpThread, I get the following -
>
>
> # # Exception in thread Thread-1:
> # Traceback (most recent call last):
> #   File "/vol/apps/maya2008ext2p01_64/lib/python25.zip/threading.py", line
> 460, in __bootstrap
> # self.run()
> #   File "/vol/apps/maya2008ext2p01_64/lib/python25.zip/threading.py", line
> 440, in run
> # self.__target(*self.__args, **self.__kwargs)
> #   File "/prod/gen/python/maya/2008/pumpThread.py", line 24, in pumpQt
> # utils.executeDeferred( processor )
> # AttributeError: 'NoneType' object has no attribute 'executeDeferred'
>
> // Error: 'NoneType' object has no attribute 'processEvents'
> # Traceback (most recent call last):
> #   File "/prod/gen/python/maya/2008/pumpThread.py", line 19, in processor
> # app.processEvents()
>
>
> Then finally - when I execute my class again in Maya, Maya crashes without a
> visible error (it simply dissapears).
> Has anyone seen this sort of behavior with threads in Maya before?
>
>
> >
>

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



[Maya-Python] Re: PyQt in Maya examples

2009-10-26 Thread John Creson

Thanks David!

On Mon, Oct 26, 2009 at 9:13 AM, Sylvain Berger
 wrote:
> Thanks a lot David!
>
> On Mon, Oct 26, 2009 at 5:23 AM, David Moulder 
> wrote:
>>
>> Here it is, This version has fixed our threading errors that occurred
>> where maya wouldn't close correctly and leave 1 mayapy thread open.
>>
>> -Dave
>>
>> ###
>>
>> from PyQt4 import QtCore, QtGui
>> import maya.utils as utils
>> import sys
>> import time
>> import threading
>> import maya.cmds as cmds
>>
>> pumpedThread = None
>> app = None
>> gPump = True
>>
>> def get_app():
>>     global app
>>     return app
>>
>> def set_app(i_app):
>>     global app
>>     testAppInstance = QtCore.QCoreApplication.instance()
>>     if testAppInstance:
>>         app = testAppInstance
>>     else:
>>         app = i_app
>>
>> def get_pt():
>>     global pumpedThread
>>     return pumpedThread
>>
>> def set_pt(i_pt):
>>     global pumpedThread
>>     pumpedThread = i_pt
>>
>> def pumpQt():
>>     global app
>>     global gPump
>>     processorEv = threading.Event()
>>     def processor():
>>         app.processEvents()
>>         processorEv.set()
>>     while gPump:
>>         utils.executeDeferred( processor )
>>         processorEv.wait()
>>         processorEv.clear()
>>         time.sleep(0.01)
>>
>> def killProcess():
>>     global gPump
>>     gPump = False
>>
>> def killPumpThread():
>>     if get_app():
>>         get_app().closeAllWindows()
>>     if get_pt():
>>         while get_pt().isAlive():
>>             killProcess()
>>         set_pt(None)
>>         set_app(None)
>>
>>
>> def initializePumpThread():
>>     global gPump
>>     gPump = True
>>     if get_pt() == None:
>>     set_app(QtGui.QApplication(sys.argv))
>>     set_pt(threading.Thread( target = pumpQt, args = () ))
>>     get_pt().start()
>>
>> On Fri, Oct 23, 2009 at 8:41 PM, Sylvain Berger 
>> wrote:
>>>
>>> Where can I find your version of pumpThread?
>>>
>>> Thanks
>>>
>>> On Tue, Sep 29, 2009 at 5:24 AM, David Moulder 
>>> wrote:

 Ok,  Here's and basic example with PyQT and a QListWidget...
 Please note.  This use's a modified pumpThread module.  The default one
 from the maya dev kit has given us lots of problems.
 Thanks to some very clever people on this list we now have a working
 pumpThread module that is heavily tested here at work.

 from PyQt4 import QtCore, QtGui
 import pymel as pm
 import pumpThread

 class ExampleUI(QtGui.QDialog):
     def __init__(self, parent=None):
     super(ExampleUI, self).__init__(parent)
     # Set some basic properties on the UI
     self.setWindowTitle('ExampleUI')
     self.setObjectName("ExampleUI")
     self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

     # Add a Layout and set it to the UI
     self.mainLayout = QtGui.QVBoxLayout(self)
     self.setLayout(self.mainLayout)

     # Add a Button and set some properties.  Also add it to a
 layout.
     self.RefreshButton = QtGui.QPushButton()
     self.RefreshButton.setText("Refresh")
     self.mainLayout.addWidget(self.RefreshButton)

     # Add a list and set it to the layout
     self.SelectionList = QtGui.QListWidget()
     self.SelectionList.setMinimumSize(250,250)
     self.mainLayout.addWidget(self.SelectionList)

     # Connect the Refresh Button to a function to populate the list
 using SIGNAL's
     self.connect(self.RefreshButton, QtCore.SIGNAL("clicked()"),
 self._RefreshButtonFunc)

     def _RefreshButtonFunc(self):
     '''
     Fill the list based on a maya selection
     '''
     oSel = pm.selected()
     if oSel:
     self.SelectionList.clear()
     [self.SelectionList.addItem(s.name()) for s in oSel]
     else:
     self.SelectionList.clear()

     @staticmethod
     def Display():
     '''
     calls the window.  Typical PumpThread call
     Use's a modified pumpThread that properly set's up the thread.
     '''
     # We need a global to stop python gc the UI
     global mainWindow

     # We need pumpThread to make the UI responsive
     pumpThread.initializePumpThread()
     app = pumpThread.get_app()
     if app:
     # We can set the app to use a nice style
     app.setStyle('Plastique')
     mainWindow = ExampleUI()
     mainWindow.show()

 ExampleUI.Display()

 I'll post our final pumpThread later today.

 -Dave


 On Tue, Sep 29, 2009 at 6:42 AM, floyd1510  wrote:
>
> Hello all,
>
> I have got PyQt up and running in Maya 2009. I was wondering if
> someone could guide me to a few examples, l

[Maya-Python] Re: Use mel.ooxx to invoke mel functions...

2009-09-22 Thread John Creson

http://usa.autodesk.com/adsk/servlet/item?id=12331406&siteID=123112&SelProduct=Maya

I'm not sure what the French link might be, but there is a link in every Maya

Help > Report a Problem

also

Help > Suggest a Feature

On Tue, Sep 22, 2009 at 5:19 AM, Olivier Renouard
 wrote:
> Support got a bit convoluted here as it goes through our reseller, but as
> soon as I can figure how things changed, I'll do that.
>
> Paul Molodowitch wrote:
>
> Huh - good to know.
>
> Anyone filed a bug report yet?
>
> - Paul
>
> On Mon, Sep 21, 2009 at 1:50 AM, Olivier Renouard
>  wrote:
>
>
> At least the cause of the error has been identified, there seems to be an
> incorrect wrap of multi use flags MSyntax in Python :
>
> http://www.3delight.com/en/modules/PunBB/viewtopic.php?pid=8600#p8600
>
> Drake wrote:
>
> The current MTOR in RenderMan Studio 2 still doesn't provide python
> binding and there must be some reason but I didn't check it with their
> technical guys. I guess it is not in priority list. But there is prman
> (the renderer) for python started from prman 14.0 and we have
> experienced on it by developed a re-lighting tool based on prman's new
> re-lighting framework. Python binding works well except some re-
> lighting bug.
>
> - Drake
>
> On Sep 18, 12:07 am, Paul Molodowitch  wrote:
>
>
> Well, glad you got that sorted out. =)
>
> Still, I'm a little surprised that the PRMan plugin didn't also supply
> a python version of mtor - generally speaking, as long as the plugin
> is implemented "properly" - ie, uses MSyntax for it's command arg
> processing - it should make both a python and mel command.
>
> - Paul
>
> On Thu, Sep 17, 2009 at 3:41 AM, Drake  wrote:
>
>
>
> Hey Paul,
>
>
> Thx a lot for the detailed explanation. During the tracing of pymel's
> Mel class, I did notice the different handling of mel commands and mel
> functions and I didn't realize that I have found the solution yet.
> PRMan's mtor is command-styled and I would use pymel.mel.mtor
> ('control', 'getvalue', '-sync') for them.
>
>
> Sometimes, it is too convenient to use pymel such that we made some
> very fundamental mistakes~
>
>
> -- Drake
>
>
> On Sep 17, 12:04 am, Paul Molodowitch  wrote:
>
>
> Hey drake -
> First of all, for commands from plugins, BOTH a python command and a
> mel command should be made.  So, both of these should be valid:
>
>
> // From mel:
> mtor(...)
>
>
> # From python:
> import maya.cmds
> maya.cmds.mtor(...)
>
>
> Also, if you encounter problems with pymel.mel's wrapping, you can
> always fall back on the the default maya.mel.eval, which just
> evaluates a mel string:
>
>
> import maya.mel
> maya.mel.eval('mtor ...')
>
>
> Thus far, I've just talked about stuff in maya's standard python/mel
> - now onto pymel.  Note that I don't have access to Renderman myself,
> so I can't give definitive answers on the mtor command, but this
> should point you in the right direction.
>
>
> In pymel, you can access the maya.cmds python function as normal:
>
>
> import pymel
> pymel.mtor(...)
>
>
> Note, however, that if you did something like this:
>
>
> from pymel import *
> loadPlugin('mtor.so')
> mtor(...)
>
>
> ...you would get:
>
>
> # NameError: name 'mtor' is not defined #
>
>
> The reason here is that when you did the 'from pymel import *', the
> 'mtor' command was not defined - you will have to either re-import *
> into your namespace, or use pymel.mtor
>
>
> Making a guess at the syntax for the mtor command, the best way to
> invoke the command you were looking for would probably be something
> like this:
>
>
> mtor('control', 'getvalue', sync=True)
>
>
> If, for some reason, you have to use the MEL version of the command,
> note that pymel's 'mel' wraps things using the 'function' syntax of
> the mel command, not the 'command' syntax.  If you're not clear on the
> difference between the two, here's an example:
>
>
> // mel command syntax:
> xform -q -translation;
> // mel function syntax:
> xform("-q", "-translation");
>
>
> Thus, the correct way to invoke this command from pymel.mel would also be:
>
>
> pymel.mel.xform("-q", "-translation");
>
>
> So, if you had to call mtor from python using the mel version, you
> would likely do something like this:
>
>
> pymel.mel.mtor('control', 'getvalue', '-sync')
>
>
> Finally, as a last fallback, you can use pymel.mel.eval, which is just
> a wrapper for the standard maya.mel.eval:
>
>
> pymel.mel.eval('mtor control getvalue -sync')
>
>
> On Wed, Sep 16, 2009 at 4:48 AM, Drake  wrote:
>
>
> It's a lovely design to use 'mel.ooxx(...)' to invoke mel function as
> 'ooxx ...' but we encountered one special case as Pixar's mtor
> function. In mel, mtor's function works like these:
>
>
> mtor control getvalue -sync;
> mtor control getvalue -rg dspyName;
> mtor control setvalue -rg "dspyQuantizeOne" -value $ooxx;
> ...
>
>
> We could not directly make it work through pymel as following:
>
>
> mel.mtor("control getvalue -sync")
>
>
> Therefore, I did my own dirty hack on Mel class t

[Maya-Python] Re: pymel nurbsCurve.closestPoint(point,param *)

2009-08-28 Thread John Creson

That's right Chad, we're working on it.

-JohnC

On Wed, Aug 26, 2009 at 10:06 PM, Chad Dombrova wrote:
> That there is a bug.
> here's some background, if you care:
> pymel parses the api documentation to learn about the arguments of the api
> methods, because this cannot be gleaned through typical python inspection.
> The problem is that the api documentation contains many, many errors when it
> comes to specifying whether an argument is an input, or an output passed by
> reference c-style.  from the docs:
> [in] toThisPoint The point to test
> [in] paramAsStart If true use the value pointed to by param as a starting
> point for the search.
> [in] param pointer to a double. If non-null, on successful returns this will
> contain the parameter value of the returned point.
> [in] tolerance The amount of error (epsilon value) in the calculation
> [in] space Specifies the coordinate system for this operation
> [out] ReturnStatus Status code
> as you can see 'param' as marked as an input, but it's actually an output
> (aka a result).  the good folks at autodesk are working on fixing this.
>  Isn't that right, guys?  :)
> when pymel generates the cached 'bin' files from the docs, it uses an
> algorithm that checks names, number of outputs, descriptions, etc, to
> attempt to detect correct these mistakes.  it also contains a manually
> maintained list of overrides.  in this case, we'll have to manually fix it.
> to fix this we would correct closestPoint to always return 2 values, a tuple
> of (Point, float).
> in pymel, you should never have to pass values by reference.  if you find
> that you have to, there's something wrong.
> -chad
>
>
>
> On Aug 26, 2009, at 3:43 PM, hapgilmore wrote:
>
> First off, i'm new to pymel, but loving how much it improves python in
> maya.
>
> I have a nurbsCurve PyNode, and a point (float array) and i'd like to
> get the param value of the closest point.
>
> I cant figure out the syntax to get this to work.
>
> This works, but returns a point(float array):
> 
> point = [1,1,1]
> closestPoint = myNurbsCurve.closestPoint(point)
> 
>
> This doesn't:
> 
> point = [1,1,1]
> param = 0.0
> closestPoint = myNurbsCurve.closestPoint(point,param)
> 
>
> Neither does this:
> 
> point = [1,1,1]
> su = OpenMaya.MScriptUtil()
> paramPtr = su.asDoublePtr()
> closestPoint = myNurbsCurve.closestPoint(point,paramPtr)
> param = su.getDouble(paramPtr)
> 
>
>
>
>
> >
>

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



[Maya-Python] Re: menu created in python

2009-08-07 Thread John Creson
scripts/startup/menuItemToShelf.mel

is called to do this action,

You may be able to do something in here, like ask

whatIs myMenuItem;

and if it is unknown, assume it is Python?

On Fri, Aug 7, 2009 at 1:32 PM, sberger  wrote:

>
> So I created this menu in the main menubar in python...the commands
> attached to these python menuItem are python commands.
>
> When select the item in the menu, the python command execute
> correctly... when I do a shift+CTRL click an item to make a shelf
> button, it create a mel shelf button!!!
>
> Anyone know how to tell maya that this menuItem should create a python
> command in the shelf?
>
>
> >
>

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



[Maya-Python] Re: how add particle dynamic attr?

2009-08-04 Thread John Creson
imitating the commands when one adds per particle attrs through the UI:

import maya.cmds as cmds

cmds.addAttr("|particle1|particleShape1", ln = "radiusPP", dt =
"doubleArray" )
cmds.addAttr("|particle1|particleShape1", ln = "radiusPPO", dt =
"doubleArray" )



On Tue, Aug 4, 2009 at 1:17 PM, dodoer  wrote:

>
> hi:
>   i do not know ,in pytho ,how add partilce dynamic attt? like
> radiusPP,parentU,parentV,
>
>
>
>THANKS
> >
>

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



[Maya-Python] Re: A suggestion about writing Maya Python API Community Book

2009-07-06 Thread John Creson
**
I'm not sure if people have seen Michiel's symantec wiki Maya node
documentation project.


http://thnkr.com/b/
On Mon, Jul 6, 2009 at 4:26 AM, Farsheed Ashouri wrote:

> For start, I create a page 
> here:*Maya-Api.tiddlyspot.com/*
> This is a good wiki to start and test and gather our initial data for the
> main website.
> *Password*: *apilover*
> Just add the password and your name in *options bar*, create a *new
> tiddler* and start to write down everything you know/learn about maya api.
> After writing your topic, click "*Save To Web*".
>
>
> --
> Sincerely,
> Farsheed Ashouri,
> Lead Technical Director / Research & Development,
> Arang Studios,
> Tehran, Iran.
> Cell No: +98 936208 9858
>
>
> >
>

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



[Maya-Python] Re: Color

2009-07-06 Thread John Creson
Haven't tried this, but what about a shader that queries the per vertex
color and uses that?

Possibly using a sampler info node in there somewhere...

On Mon, Jul 6, 2009 at 8:10 AM, Omar Agudo  wrote:

>
> Hi Dean,
>
> I have tried what you said me but it doesn´t work. I have some questions,
>
> If you want to render a mesh that have different colors you need to
> assign different shaders to the mesh?
>
> Now I do this:
> 1) Create the mesh
> 2) Assign color per vertex as you told me
> 3) Assign the mesh created to the initial shading group (
> cmds.sets(Mymesh, add='initialShadingGroup') )
>
> But when I render the image I only achieve render the mesh without
> color. I don´t know what I am doing wrong, I have tried also to create
> a new shader and assign it to the mesh, but I obtain the same result.
>
> The only way I have found to do what I want to do is to create
> diferent shaders (each one with the colors I want to use) and assign
> these shaders to the parts of the mesh that have differents colors.
> But this solution is too slow, and it requires a lot of time.
>
> Is there another way to do what I am looking for?
>
> Thank you so much!
>
> Omar.
>
>
> 2009/7/6 Omar Agudo :
>  > Thank you dean! I will try this, I am very grateful because there are
> > few examples of the python-maya API. Thank you so much!
> >
> > 2009/7/5 Dean Edmonds :
> >>
> >> Whoops. There was an error in the commands that I gave you. This:
> >>
> >># Set the color of vertex 2 to be red.
> >>mc.select('myMeshShape.vtx[2]', r=1, g=0, b=0)
> >>
> >> should be this:
> >>
> >>   # Set the color of vertex 2 to be red.
> >>   mc.polyColorPerVertex('myMeshShape.vtx[2]', r=1, g=0, b=0)
> >>
> >> --
> >> -deane
> >>
> >> >>
> >>
> >
>
> >
>

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



[Maya-Python] Re: Modal dialogs

2009-06-17 Thread John Creson
Some people have had success with the full alternate thread path.  Please
share and do what makes the most sense to you.  There may have been an issue
with executeInMainThreadWithResult in certain versions making it difficult
to get needed maya information back to functions that needed it, but I'm a
little fuzzy on that right now.

Will, are you working in an alternate thread or more modal window like way?
PumpThread came into existence to referee which app is really the
mainWindow, since they didn't seem to be playing nicely.

Has anyone had luck on a Mac?

On Wed, Jun 17, 2009 at 10:44 AM, wbate  wrote:

>
> When I open a new GUI, I check to see if there already is a
> QApplication and create one only if none exists, same with the
> specific main window I want to open:
>
>   app = QtGui.QApplication.instance()
>   if app :
>  warnings.warn( "QApplication instance already exists!",
> category=UserWarning, stacklevel=1 )
>   else :
>   app = QtGui.QApplication(sys.argv)
>
>haveWindow = False
>   windowList = app.topLevelWidgets()
>   for foundWindow in windowList :
>  if foundWindow.objectName() == 'myWindowName' :
> haveWindow = True
> window = foundWindow
>
>   if not haveWindow :
>  window = QtGui.QMainWindow()
>  window.setObjectName("myWindowName")
>
> So far I have not needed globals or pumpThread...
>
> will.
> On Jun 17, 4:21 am, Pierre A  wrote:
> > Thanks for the help!
> >
> > I've found the mistake. QApplication was instantiated more than one
> > time because a little "app.quit()" was hidden somewhere... Now I have
> > two GUI behaving correctly (well, I hope so)
> >
> > By the way, if pumpThread is not the more elegant workaround, is there
> > any other ( and smarter :) ) way to do this? Why do we need to call a
> > refresh thread that calls every 0.01 sec : utils.executeDeferred
> > ( app.processEvents() )?
> > Can't we simply launch QApplicaton and all the GUI in another thread?
> > Sorry to bother you with that, I think this issue must have been
> > already pushed in the list.
> >
> > Thanks again
> > Pierre
> >
> > On 16 juin, 22:22, John Creson  wrote:
> >
> >
> >
> > > Also,
> >
> > > you can’t have more than one qt.QApplication(sys.argv) running at once.
> >
> > > In your second example, you are using pumpThread which works around
> defining
> > > the app in a bad way, but then you re-define it the way that doesn't
> make
> > > maya happy.
> >
> > > Perhaps just comment out the app= line in the second example.
> >
> > > They can all call pumpThread, since this is protected from starting
> more
> > > than once.
> >
> > > On Tue, Jun 16, 2009 at 4:10 PM, John Creson 
> wrote:
> > > > I think this may be Python cleaning up :)
> >
> > > > Once your GUIs start getting more complex, you have to use the global
> > > > application
> >
> > > > instantiation and global windows variables.
> >
> > > > If you don't use both the global application instantiation and global
> > > > windows variables,
> >
> > > > then the resultant GUI will appear and disappear very quickly as
> Python
> > > > cleans up its
> >
> > > > local variables.
> >
> > > > import sys
> >
> > > > import PyQt4 as qt
> >
> > > > app=None
> >
> > > > win=None
> > > > def windo():
> >
> > > > global app
> > > > global win
> > > > app = qt.QApplication(sys.argv)
> > > > win = qt.QLabel("Hello world!",None)
> > > > win.show()
> >
> > > > windo()
> >
> > > > On Tue, Jun 16, 2009 at 3:52 PM, Pierre A <
> pierre.auge...@heroldfamily.biz
> > > > > wrote:
> >
> > > >> Hi,
> >
> > > >> I'm experiencing a strange behavior with modal dialogs.
> > > >> Let's see the following code snippet: (Im in a method's class
> context)
> >
> > > >> def launchDialog(self):
> > > >>diag = QtGui.QDialog(self)
> > > >>ret = diag.exec_()
> > > >>print ret
> >
> > > >> I can see the dialog during a few miliseconds, then it disapears.
> The
> > > >> return value is always 0
> >
> > > >> Now, another piece of code:
> > > >> def launchDialog(self):
> >

[Maya-Python] Re: [PyQt] Modal dialogs

2009-06-16 Thread John Creson
Also,

you can’t have more than one qt.QApplication(sys.argv) running at once.


In your second example, you are using pumpThread which works around defining
the app in a bad way, but then you re-define it the way that doesn't make
maya happy.

Perhaps just comment out the app= line in the second example.

They can all call pumpThread, since this is protected from starting more
than once.

On Tue, Jun 16, 2009 at 4:10 PM, John Creson  wrote:

> I think this may be Python cleaning up :)
>
> Once your GUIs start getting more complex, you have to use the global
> application
>
> instantiation and global windows variables.
>
> If you don't use both the global application instantiation and global
> windows variables,
>
> then the resultant GUI will appear and disappear very quickly as Python
> cleans up its
>
> local variables.
>
>
>
> import sys
>
> import PyQt4 as qt
>
> app=None
>
> win=None
> def windo():
>
> global app
> global win
> app = qt.QApplication(sys.argv)
> win = qt.QLabel("Hello world!",None)
> win.show()
>
> windo()
>
>
> On Tue, Jun 16, 2009 at 3:52 PM, Pierre A  > wrote:
>
>>
>> Hi,
>>
>> I'm experiencing a strange behavior with modal dialogs.
>> Let's see the following code snippet: (Im in a method's class context)
>>
>> def launchDialog(self):
>>diag = QtGui.QDialog(self)
>>ret = diag.exec_()
>>print ret
>>
>> I can see the dialog during a few miliseconds, then it disapears. The
>> return value is always 0
>>
>> Now, another piece of code:
>> def launchDialog(self):
>>self.diag = QtGui.QDialog(self)
>>ret = self.diag.exec_()
>>print ret
>>
>> I'm just adding the dialog as a member of the class. The dialog
>> becomes modal, but exec_() returns immediately.
>>
>> I have the same problems with the convenience methods of
>> QtGui.QMessageBox and QtGui.QInputDialog, they are closed immediately
>> too...
>>
>>
>> I'm in a particular state in maya. I have two different GUI launched.
>> They both use pumpthread:
>> ## LAUNCH APP
>> window = None
>> app = None
>> def LaunchApp():
>>global app
>>global window
>>pt.initializePumpThread()
>>app = QtGui.QApplication(sys.argv)
>>window = MyWindowClass()
>>window.show()
>>
>> If only one GUI is launched, diag.exec_() doesn't disappear. :'( But I
>> really need to have multiple windows
>> I'm stuck! I don't know how to solve this. Perhaps I could instanciate
>> the QtApp in another module which would act as a singleton and share
>> the QApplication with the different GUI?
>>
>> Thanks!
>>
>> Pierre
>>
>>
>> >>
>>
>

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



[Maya-Python] Re: [PyQt] Modal dialogs

2009-06-16 Thread John Creson
I think this may be Python cleaning up :)

Once your GUIs start getting more complex, you have to use the global
application

instantiation and global windows variables.

If you don't use both the global application instantiation and global
windows variables,

then the resultant GUI will appear and disappear very quickly as Python
cleans up its

local variables.



import sys

import PyQt4 as qt

app=None

win=None
def windo():

global app
global win
app = qt.QApplication(sys.argv)
win = qt.QLabel("Hello world!",None)
win.show()

windo()


On Tue, Jun 16, 2009 at 3:52 PM, Pierre A
wrote:

>
> Hi,
>
> I'm experiencing a strange behavior with modal dialogs.
> Let's see the following code snippet: (Im in a method's class context)
>
> def launchDialog(self):
>diag = QtGui.QDialog(self)
>ret = diag.exec_()
>print ret
>
> I can see the dialog during a few miliseconds, then it disapears. The
> return value is always 0
>
> Now, another piece of code:
> def launchDialog(self):
>self.diag = QtGui.QDialog(self)
>ret = self.diag.exec_()
>print ret
>
> I'm just adding the dialog as a member of the class. The dialog
> becomes modal, but exec_() returns immediately.
>
> I have the same problems with the convenience methods of
> QtGui.QMessageBox and QtGui.QInputDialog, they are closed immediately
> too...
>
>
> I'm in a particular state in maya. I have two different GUI launched.
> They both use pumpthread:
> ## LAUNCH APP
> window = None
> app = None
> def LaunchApp():
>global app
>global window
>pt.initializePumpThread()
>app = QtGui.QApplication(sys.argv)
>window = MyWindowClass()
>window.show()
>
> If only one GUI is launched, diag.exec_() doesn't disappear. :'( But I
> really need to have multiple windows
> I'm stuck! I don't know how to solve this. Perhaps I could instanciate
> the QtApp in another module which would act as a singleton and share
> the QApplication with the different GUI?
>
> Thanks!
>
> Pierre
>
>
> >
>

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



[Maya-Python] Re: long-time lurker, first time poster with a few questions

2009-06-15 Thread John Creson
Remember that good ole' MEL based maya.cmds GUI commands work for building
GUI for Maya through Python.



On Mon, Jun 15, 2009 at 1:05 PM, Christopher Janney wrote:

> Thank you for the PyQt tip.  I'll look into that.
>
> -ctj
>
>
> On Sun, Jun 14, 2009 at 9:38 AM, Paul Molodowitch wrote:
>
>>
>> > 1.  Where can I find good info on writing GUI's in python for maya?
>>
>> I don't really know of any, I'm afraid. Basically, though, if you're
>> just using the built-in stuff, it's pretty much the same process as
>> with mel, since maya's python.cmds are just a fairly straight wrap of
>> mel.  There is one common problem with callbacks, though, which you
>> can see discussed here:
>>
>>
>> http://groups.google.com/group/python_inside_maya/browse_thread/thread/04fe55cd54ebb822/7fffe668f7b814e1#7fffe668f7b814e1
>>
>> Of course, you also have the option of using additional GUI tools,
>> such as PyQt... but I don't know too much about that myself.
>>
>> > 2.  If I use pymel, I'm assuming I have to distribute it to all the
>> artist
>> > stations, correct?
>>
>> Yup
>>
>> > 3.  Any decent docs on writing plugins with python?  The docs
>> distributed
>> > with maya
>> > are probably better suited for someone who has been writing c++ plugins
>> and
>> > is
>>
>> Unfortunately, no.  There ARE some python plugin examples, however.
>> Also, since the python plugin examples also have a c++ version, you
>> can compare the two to see how the python and c++ versions differ,
>> which might then help to make sense of examples where there's only a
>> c++ version...
>>
>>
>>
>
> >
>

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



[Maya-Python] Re: maya.cmds and time ranges

2009-06-08 Thread John Creson
nice :)

I posted to cg, but my post is waiting in limbo for a while

On Mon, Jun 8, 2009 at 9:49 PM, Chad Dombrova  wrote:

> thanks, i will roll that into pymel to get the two shorthand methods that i
> listed working.
> -chad
>
>
> On Jun 8, 2009, at 6:40 PM, John Creson wrote:
>
> I don't think this is pretty, but this works:
>
> cmds.keyframe(time=(50,(cmds.findKeyframe(which='last'))), relative=1,
> timeChange=1, option="over")
>
> This could look a little better:
>
> def endKey():
> return cmds.findKeyframe(which='last')
> def firstKey():
> return cmds.findKeyframe(which='first')
>
> cmds.keyframe(time=(50,endKey()), relative=1, timeChange=1, option="over")
>
> cmds.keyframe(time=(firstKey(),50), relative=1, timeChange=1,
> option="over")
>
>
>
> On Mon, Jun 8, 2009 at 8:02 PM, chadrik  wrote:
>
>> if that's the best we can do, then i definitely consider this a bug.  one
>> or both of these two should be made to work:
>>
>> cmds.keyframe(time=(50,), relative=1, timeChange=1, option="over")
>> cmds.keyframe(time=(50,None), relative=1, timeChange=1, option="over")
>>
>>
>> and perhaps even:
>>
>> cmds.keyframe(time=slice(50), relative=1, timeChange=1, option="over")
>>
>>
>>
>> -chad
>>
>>
>> On Jun 8, 2009, at 4:58 PM, John Creson wrote:
>>
>> Checked out the docs, it's looking for a tuple, the tricky bit is working
>> out how to give it a number that means "till the end of time"
>>
>> cmds.keyframe(time=(50,1), relative=1, timeChange=1,option="over")
>>
>>
>>
>> On Mon, Jun 8, 2009 at 6:34 PM, Chadrik  wrote:
>>
>>>
>>> i saw this post over at cgtalk and was surprised to find the answer so
>>> elusive: http://forums.cgsociety.org/showthread.php?f=89&t=772302
>>>
>>> here's the post:
>>> ---
>>> I am trying to convert this mel code to python but I can't get the
>>> time attribute working properly.
>>> mel:
>>>
>>>   keyframe -time "50:" -relative -timeChange 1 -option over;
>>>
>>>
>>> I tried this python equivalent:
>>>
>>>cmds.keyframe(time=(50:), relative=1, timeChange=1,
>>> option="over")
>>># TypeError: Invalid arguments for flag 'time'. Expected (time,
>>> [time]), got int #
>>>
>>>
>>> I also tried with quotes, without quotes, with a comma, without a
>>> comma, etc. The only time i get the python equivalent working is if i
>>> set a timeRange to time=(startInt,endInt) i would like to specify time=
>>> (startInt, *onward*)
>>>
>>>
>>> end-
>>>
>>> i was very surprised to find that neither of these worked:
>>>
>>> cmds.keyframe(time=(50,), relative=1, timeChange=1, option="over")
>>> cmds.keyframe(time=(50,None), relative=1, timeChange=1, option="over")
>>>
>>> i tested this in 2009
>>>
>>> -chad
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
>
>
> >
>

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



[Maya-Python] Re: maya.cmds and time ranges

2009-06-08 Thread John Creson
I don't think this is pretty, but this works:

cmds.keyframe(time=(50,(cmds.findKeyframe(which='last'))), relative=1,
timeChange=1, option="over")

This could look a little better:

def endKey():
return cmds.findKeyframe(which='last')
def firstKey():
return cmds.findKeyframe(which='first')

cmds.keyframe(time=(50,endKey()), relative=1, timeChange=1, option="over")

cmds.keyframe(time=(firstKey(),50), relative=1, timeChange=1, option="over")



On Mon, Jun 8, 2009 at 8:02 PM, chadrik  wrote:

> if that's the best we can do, then i definitely consider this a bug.  one
> or both of these two should be made to work:
>
> cmds.keyframe(time=(50,), relative=1, timeChange=1, option="over")
> cmds.keyframe(time=(50,None), relative=1, timeChange=1, option="over")
>
>
> and perhaps even:
>
> cmds.keyframe(time=slice(50), relative=1, timeChange=1, option="over")
>
>
>
> -chad
>
>
> On Jun 8, 2009, at 4:58 PM, John Creson wrote:
>
> Checked out the docs, it's looking for a tuple, the tricky bit is working
> out how to give it a number that means "till the end of time"
>
> cmds.keyframe(time=(50,1), relative=1, timeChange=1,option="over")
>
>
>
> On Mon, Jun 8, 2009 at 6:34 PM, Chadrik  wrote:
>
>>
>> i saw this post over at cgtalk and was surprised to find the answer so
>> elusive: http://forums.cgsociety.org/showthread.php?f=89&t=772302
>>
>> here's the post:
>> ---
>> I am trying to convert this mel code to python but I can't get the
>> time attribute working properly.
>> mel:
>>
>>   keyframe -time "50:" -relative -timeChange 1 -option over;
>>
>>
>> I tried this python equivalent:
>>
>>cmds.keyframe(time=(50:), relative=1, timeChange=1,
>> option="over")
>># TypeError: Invalid arguments for flag 'time'. Expected (time,
>> [time]), got int #
>>
>>
>> I also tried with quotes, without quotes, with a comma, without a
>> comma, etc. The only time i get the python equivalent working is if i
>> set a timeRange to time=(startInt,endInt) i would like to specify time=
>> (startInt, *onward*)
>>
>>
>> end-
>>
>> i was very surprised to find that neither of these worked:
>>
>> cmds.keyframe(time=(50,), relative=1, timeChange=1, option="over")
>> cmds.keyframe(time=(50,None), relative=1, timeChange=1, option="over")
>>
>> i tested this in 2009
>>
>> -chad
>>
>>
>>
>>
>
>
>
>
>
> >
>

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



[Maya-Python] Re: maya.cmds and time ranges

2009-06-08 Thread John Creson
oops, guess that's what you were asking...

On Mon, Jun 8, 2009 at 7:58 PM, John Creson  wrote:

> Checked out the docs, it's looking for a tuple, the tricky bit is working
> out how to give it a number that means "till the end of time"
>
>
> cmds.keyframe(time=(50,1), relative=1, timeChange=1,option="over")
>
>
>
>
> On Mon, Jun 8, 2009 at 6:34 PM, Chadrik  wrote:
>
>>
>> i saw this post over at cgtalk and was surprised to find the answer so
>> elusive: http://forums.cgsociety.org/showthread.php?f=89&t=772302
>>
>> here's the post:
>> ---
>> I am trying to convert this mel code to python but I can't get the
>> time attribute working properly.
>> mel:
>>
>>   keyframe -time "50:" -relative -timeChange 1 -option over;
>>
>>
>> I tried this python equivalent:
>>
>>cmds.keyframe(time=(50:), relative=1, timeChange=1,
>> option="over")
>># TypeError: Invalid arguments for flag 'time'. Expected (time,
>> [time]), got int #
>>
>>
>> I also tried with quotes, without quotes, with a comma, without a
>> comma, etc. The only time i get the python equivalent working is if i
>> set a timeRange to time=(startInt,endInt) i would like to specify time=
>> (startInt, *onward*)
>>
>>
>> end-
>>
>> i was very surprised to find that neither of these worked:
>>
>> cmds.keyframe(time=(50,), relative=1, timeChange=1, option="over")
>> cmds.keyframe(time=(50,None), relative=1, timeChange=1, option="over")
>>
>> i tested this in 2009
>>
>> -chad
>>
>>
>> >>
>>
>

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



[Maya-Python] Re: maya.cmds and time ranges

2009-06-08 Thread John Creson
Checked out the docs, it's looking for a tuple, the tricky bit is working
out how to give it a number that means "till the end of time"


cmds.keyframe(time=(50,1), relative=1, timeChange=1,option="over")




On Mon, Jun 8, 2009 at 6:34 PM, Chadrik  wrote:

>
> i saw this post over at cgtalk and was surprised to find the answer so
> elusive: http://forums.cgsociety.org/showthread.php?f=89&t=772302
>
> here's the post:
> ---
> I am trying to convert this mel code to python but I can't get the
> time attribute working properly.
> mel:
>
>   keyframe -time "50:" -relative -timeChange 1 -option over;
>
>
> I tried this python equivalent:
>
>cmds.keyframe(time=(50:), relative=1, timeChange=1,
> option="over")
># TypeError: Invalid arguments for flag 'time'. Expected (time,
> [time]), got int #
>
>
> I also tried with quotes, without quotes, with a comma, without a
> comma, etc. The only time i get the python equivalent working is if i
> set a timeRange to time=(startInt,endInt) i would like to specify time=
> (startInt, *onward*)
>
>
> end-
>
> i was very surprised to find that neither of these worked:
>
> cmds.keyframe(time=(50,), relative=1, timeChange=1, option="over")
> cmds.keyframe(time=(50,None), relative=1, timeChange=1, option="over")
>
> i tested this in 2009
>
> -chad
>
>
> >
>

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



[Maya-Python] Re: crash when selecting edges of a newly made subd

2009-06-08 Thread John Creson
don't know about the performance hit, but iterate through the edges adding
them to the selection list one at a time?

On Mon, Jun 8, 2009 at 2:40 PM, Paul Molodowitch  wrote:

>
> Well... it's not really what I want to do.  I need to be prepared
> (potentially) for anything an end user wants to do - if they create a
> component which has ALL of the subdiv's edges, they should be able to
> select it...
>
> - Paul
>
> On Mon, Jun 8, 2009 at 10:48 AM, John Creson wrote:
> > If it's arbitrarily large, do you really want to select everything, or do
> > you just want to iterate over each one?
> >
> > On Mon, Jun 8, 2009 at 1:11 PM, Paul Molodowitch 
> wrote:
> >>
> >> Need to do something after... it's actually for pymel's new component
> >> implementation, so there may be an arbitrarily large amount of things
> >> that users might want to do after, and I don't think
> >> '.executeDeferred" will really work. =/
> >>
> >> Thanks for the suggestion though...
> >>
> >> I think we'll just have to add some special case code to pymel's
> >> select command that checks for '.sme[*]'
> >>
> >> - Paul
> >>
> >> On Mon, Jun 8, 2009 at 7:52 AM, John Creson
> wrote:
> >> > You might try piling up the refresh and the selection at the end of
> >> > whatever
> >> > is happening before with an executeDeferred.
> >> >
> >> > import maya.utils as utils
> >> >
> >> > utils.executeDeferred("cmds.refresh();cmds.select(subd +
> '.sme[*][*]')")
> >> >
> >> > Are you trying to end what is happening at this selection, or is there
> >> > something that you need to do with the selection after you've selected
> >> > it?
> >> >
> >> > -JohnC
> >> >
> >> > On Mon, Jun 8, 2009 at 10:38 AM, Paul Molodowitch  >
> >> > wrote:
> >> >>
> >> >> I spoke too soon - still getting a crash when I'm selecting
> .sme[*][*]
> >> >> in my own code, even with a refresh.  Unfortunately, I'm not sure
> what
> >> >> the key difference between it and the test case I already posted
> is...
> >> >>
> >> >> - Paul
> >> >>
> >> >> On Fri, Jun 5, 2009 at 9:20 PM, Paul Molodowitch
> >> >> wrote:
> >> >> > Yup, no more crash.  Thanks for the workaround!
> >> >> >
> >> >> > - Paul
> >> >> >
> >> >> > On Fri, Jun 5, 2009 at 4:39 PM, John Creson
> >> >> > wrote:
> >> >> >> I just took another look at the initial construct with an emphasis
> >> >> >> on
> >> >> >> the
> >> >> >> "avoid" question...
> >> >> >>
> >> >> >>
> >> >> >> import maya.cmds as cmds
> >> >> >> import maya.utils as utils
> >> >> >>
> >> >> >> polyCube = cmds.polyCube()[0]
> >> >> >> subd = cmds.polyToSubdiv(polyCube)[0]
> >> >> >> cmds.refresh()
> >> >> >> cmds.select(subd + '.sme[*][*]')
> >> >> >>
> >> >> >> print(cmds.ls(sl=True))
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> the refresh seems to avoid this crash.
> >> >> >>
> >> >> >> Or in MEL (which also crashed without the refresh)
> >> >> >>
> >> >> >> string $polyCube[] = `polyCube`;
> >> >> >> string $subd[] = `polyToSubdiv $polyCube[0]`;
> >> >> >> refresh;
> >> >> >> select -r ($subd[0] + ".sme[*][*]")
> >> >> >> ls -sl
> >> >> >>
> >> >> >> Paul, is this acceptable to you for now?
> >> >> >>
> >> >> >>
> >> >> >> On Fri, Jun 5, 2009 at 5:18 AM, Dimitry  >
> >> >> >> wrote:
> >> >> >>>
> >> >> >>> but if I trying to select unordered vertexes i got crash
> >> >> >>>
> >> >> >>> #unitMesh= ls(selection=True)[0]
> >> >> >>> mc.select(clear=True)
> >> >> >>> select (unitMesh.vtx[6422:6429], add=True)
> >> >> >>> select (unitMesh.vtx[3273:3275, 3278:3279, 3282:3283, 3285],
> >> >> >>> add=True)
> >> >> >>>
> >> >> >>> nows somebody how possible to avoid it?
> >> >> >>>
> >> >> >>
> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >> > >
> >> >
> >>
> >>
> >
> >
> > >
> >
>
> >
>

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



[Maya-Python] Re: crash when selecting edges of a newly made subd

2009-06-08 Thread John Creson
If it's arbitrarily large, do you really want to select everything, or do
you just want to iterate over each one?

On Mon, Jun 8, 2009 at 1:11 PM, Paul Molodowitch  wrote:

>
> Need to do something after... it's actually for pymel's new component
> implementation, so there may be an arbitrarily large amount of things
> that users might want to do after, and I don't think
> '.executeDeferred" will really work. =/
>
> Thanks for the suggestion though...
>
> I think we'll just have to add some special case code to pymel's
> select command that checks for '.sme[*]'
>
> - Paul
>
> On Mon, Jun 8, 2009 at 7:52 AM, John Creson wrote:
> > You might try piling up the refresh and the selection at the end of
> whatever
> > is happening before with an executeDeferred.
> >
> > import maya.utils as utils
> >
> > utils.executeDeferred("cmds.refresh();cmds.select(subd + '.sme[*][*]')")
> >
> > Are you trying to end what is happening at this selection, or is there
> > something that you need to do with the selection after you've selected
> it?
> >
> > -JohnC
> >
> > On Mon, Jun 8, 2009 at 10:38 AM, Paul Molodowitch 
> > wrote:
> >>
> >> I spoke too soon - still getting a crash when I'm selecting .sme[*][*]
> >> in my own code, even with a refresh.  Unfortunately, I'm not sure what
> >> the key difference between it and the test case I already posted is...
> >>
> >> - Paul
> >>
> >> On Fri, Jun 5, 2009 at 9:20 PM, Paul Molodowitch
> >> wrote:
> >> > Yup, no more crash.  Thanks for the workaround!
> >> >
> >> > - Paul
> >> >
> >> > On Fri, Jun 5, 2009 at 4:39 PM, John Creson
> wrote:
> >> >> I just took another look at the initial construct with an emphasis on
> >> >> the
> >> >> "avoid" question...
> >> >>
> >> >>
> >> >> import maya.cmds as cmds
> >> >> import maya.utils as utils
> >> >>
> >> >> polyCube = cmds.polyCube()[0]
> >> >> subd = cmds.polyToSubdiv(polyCube)[0]
> >> >> cmds.refresh()
> >> >> cmds.select(subd + '.sme[*][*]')
> >> >>
> >> >> print(cmds.ls(sl=True))
> >> >>
> >> >>
> >> >>
> >> >> the refresh seems to avoid this crash.
> >> >>
> >> >> Or in MEL (which also crashed without the refresh)
> >> >>
> >> >> string $polyCube[] = `polyCube`;
> >> >> string $subd[] = `polyToSubdiv $polyCube[0]`;
> >> >> refresh;
> >> >> select -r ($subd[0] + ".sme[*][*]")
> >> >> ls -sl
> >> >>
> >> >> Paul, is this acceptable to you for now?
> >> >>
> >> >>
> >> >> On Fri, Jun 5, 2009 at 5:18 AM, Dimitry 
> >> >> wrote:
> >> >>>
> >> >>> but if I trying to select unordered vertexes i got crash
> >> >>>
> >> >>> #unitMesh= ls(selection=True)[0]
> >> >>> mc.select(clear=True)
> >> >>> select (unitMesh.vtx[6422:6429], add=True)
> >> >>> select (unitMesh.vtx[3273:3275, 3278:3279, 3282:3283, 3285],
> add=True)
> >> >>>
> >> >>> nows somebody how possible to avoid it?
> >> >>>
> >> >>
> >> >>
> >> >> >>
> >> >>
> >> >
> >>
> >>
> >
> >
> > >
> >
>
> >
>

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



[Maya-Python] Re: crash when selecting edges of a newly made subd

2009-06-08 Thread John Creson
You might try piling up the refresh and the selection at the end of whatever
is happening before with an executeDeferred.

import maya.utils as utils

utils.executeDeferred("cmds.refresh();cmds.select(subd + '.sme[*][*]')")

Are you trying to end what is happening at this selection, or is there
something that you need to do with the selection after you've selected it?

-JohnC

On Mon, Jun 8, 2009 at 10:38 AM, Paul Molodowitch wrote:

>
> I spoke too soon - still getting a crash when I'm selecting .sme[*][*]
> in my own code, even with a refresh.  Unfortunately, I'm not sure what
> the key difference between it and the test case I already posted is...
>
> - Paul
>
> On Fri, Jun 5, 2009 at 9:20 PM, Paul Molodowitch
> wrote:
> > Yup, no more crash.  Thanks for the workaround!
> >
> > - Paul
> >
> > On Fri, Jun 5, 2009 at 4:39 PM, John Creson wrote:
> >> I just took another look at the initial construct with an emphasis on
> the
> >> "avoid" question...
> >>
> >>
> >> import maya.cmds as cmds
> >> import maya.utils as utils
> >>
> >> polyCube = cmds.polyCube()[0]
> >> subd = cmds.polyToSubdiv(polyCube)[0]
> >> cmds.refresh()
> >> cmds.select(subd + '.sme[*][*]')
> >>
> >> print(cmds.ls(sl=True))
> >>
> >>
> >>
> >> the refresh seems to avoid this crash.
> >>
> >> Or in MEL (which also crashed without the refresh)
> >>
> >> string $polyCube[] = `polyCube`;
> >> string $subd[] = `polyToSubdiv $polyCube[0]`;
> >> refresh;
> >> select -r ($subd[0] + ".sme[*][*]")
> >> ls -sl
> >>
> >> Paul, is this acceptable to you for now?
> >>
> >>
> >> On Fri, Jun 5, 2009 at 5:18 AM, Dimitry 
> wrote:
> >>>
> >>> but if I trying to select unordered vertexes i got crash
> >>>
> >>> #unitMesh= ls(selection=True)[0]
> >>> mc.select(clear=True)
> >>> select (unitMesh.vtx[6422:6429], add=True)
> >>> select (unitMesh.vtx[3273:3275, 3278:3279, 3282:3283, 3285], add=True)
> >>>
> >>> nows somebody how possible to avoid it?
> >>>
> >>
> >>
> >> >>
> >>
> >
>
> >
>

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



[Maya-Python] Re: PyQt - OSX - Maya2009 crash

2009-06-06 Thread John Creson
I never had any luck with PyQt on OSX with maya2009.
It's hard to diagnose, since it crashes so early in the game.

On Sat, Jun 6, 2009 at 8:56 PM, CharlieWales  wrote:

> Looks like there is only the 32-bit version of Maya for  OSX:
>
> The 32-bit version of Autodesk® Maya® 2009 software is supported on any of
> the following operating systems:
>
>- Microsoft® Windows Vista® Business operating system (SP1 or higher)
>- Microsoft® Windows® XP Professional operating system (SP2 or higher)
>- Apple® Mac OS® X 10.5.2 operating system or higher
>
> The 64-bit version of Maya 2009 software is supported on any of the
> following operating systems:
>
>- Microsoft Windows Vista Business (SP1 or higher)
>- Microsoft Windows XP x64 Edition (SP2 or higher)
>- Red Hat® Enterprise Linux® 4.0 WS operating system (U6)
>- Fedora™ 8 operating system
>
> from here
> http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=7639522
>
>
> So you must be running a 32-bit version. At this point a can't give you any
> other info at this moment, sorry dude. I guess I was lucky installing it.
>
>
>
> 2009/6/7 Taylor Carrasco 
>
> I've got sip installed, followed riverbanks instructions thoroughly, and
>> copied those files as well when I copied PyQt4 over.
>>
>> I checked and I have a 64 bit OSX vs 10.5.7
>> 2.93 Intel Core 2 Duo. Apparently all currently shipping macs are 64 bit.
>>
>> How do I check if my Maya is 64/32 bit?
>>
>>
>>
>> On Sat, Jun 6, 2009 at 5:04 PM, CharlieWales wrote:
>>
>>>Sorry about that but I am a newbie to python and don't know much about
>>> OSX, but, are you running a 64-bit or a 32-Bit version of Maya? in windows I
>>> only could make it work in 32-bit versions of Maya, I guess it has to be
>>> with the python being compiled for 32-bit and PyQt4 also, I don't know.
>>>
>>>Also I thinks you have to have installed the "sip" module
>>>
>>> http://www.riverbankcomputing.co.uk/software/sip/intro
>>>
>>> I had to copy these files:
>>>
>>> sipconfig.py
>>> sipdistutils.py
>>> sip.pyd
>>>
>>> from my system python installation into the maya python site-packages
>>> folder.
>>>
>>> Hope it helps.
>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>

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



[Maya-Python] Re: crash when selecting edges of a newly made subd

2009-06-05 Thread John Creson
I just took another look at the initial construct with an emphasis on the
"avoid" question...


import maya.cmds as cmds
import maya.utils as utils

polyCube = cmds.polyCube()[0]
subd = cmds.polyToSubdiv(polyCube)[0]
cmds.refresh()
cmds.select(subd + '.sme[*][*]')

print(cmds.ls(sl=True))



the refresh seems to avoid this crash.

Or in MEL (which also crashed without the refresh)

string $polyCube[] = `polyCube`;
string $subd[] = `polyToSubdiv $polyCube[0]`;
refresh;
select -r ($subd[0] + ".sme[*][*]")
ls -sl

Paul, is this acceptable to you for now?


On Fri, Jun 5, 2009 at 5:18 AM, Dimitry  wrote:

>
> but if I trying to select unordered vertexes i got crash
>
> #unitMesh= ls(selection=True)[0]
> mc.select(clear=True)
> select (unitMesh.vtx[6422:6429], add=True)
> select (unitMesh.vtx[3273:3275, 3278:3279, 3282:3283, 3285], add=True)
>
> nows somebody how possible to avoid it?
> >
>

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



[Maya-Python] Re: setting one of the shape attributes using setAttr

2009-05-15 Thread John Creson
I did have a clue that variable length items might be passed as lists, or at
least I hoped they might.
The clue for me that got me going was in his error:

# RuntimeError: Error reading data element number 7: 0

That told me that some of the data elements were reading without errors
based on the nurbsCurve type.
I tried any reference I could think of, but the one that wins in the end is
the good old node description for nurbsCurve, I just didn't know it as it
stared me in the face.

But I tried passing both the knots and the cvs as lists, lists of tuples

The funky part started in when I started getting the next dataType correct,
and then it would skip a data element and complain about the following one.
I still didn't clue in for some time.  At one point I thought the cv list of
tuples might not be defined by the number preceding, as I would add another
tuple and it seemed to ask for more.  So I doubled up the list of cvs with a
copy paste and it went through.  After that I noticed that the cvs that were
created were every other one, and then I looked back at the description in
the node docs to try and understand it.

It is good to remember that Python can't just drop arguments it doesn't need
at the moment the way MEL can.  The Python version of this dataType must
account for the full description of the dataType (the un-needed W values in
this instance) so Python will parse the arg list correctly.  It can properly
ignore those elements it doesn't use, but it needs everything it needs in
its expected place in the arg list.

- JohnCreson



On Fri, May 15, 2009 at 8:25 PM, Paul Molodowitch wrote:

>
> Awesome, thanks!
>
> Out of curiosity - how did you figure that out? Is there some
> reference I'm unaware of? Or some awesome python introspection
> ability? Or just some good intuition? (In retrospect, it makes sense
> to have the variable-length items passed as lists...)
>
> - Paul
>
> On Fri, May 15, 2009 at 3:15 PM, John Creson  wrote:
> > ###
> > import maya.cmds as cmds
> > cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
> > cmds.setAttr('myNurbsCurveShape.cc',3,1,0,
> >False,3,
> >(0,0,0,1,1,1),6,
> > 4,(-2,3,0),(),(2,1,0),(),(2,-3,0),(),(-2,-1,0),(),
> > type='nurbsCurve')
> >
> >
> > #
> >
> > In the above example the 6 could also be () and the curve still seems to
> > build as expected.
> > I think the list knows how long it is...
> > I think the () after every CV may be a place holder for possible W values
> > when making rational curves.
> > (CV positions in x,y,z (and w if rational) )
> >
> > On Wed, May 13, 2009 at 1:59 PM, barnabas79  wrote:
> >>
> >> Hey - I was wondering if anyone here has tried to set a 'nurbsCurve'
> >> attribute using setAttr (or, really, any of the shape attribute types
> >> - I assume the syntax will be similar between them).
> >>
> >> Ie, the docs have this example for mel:
> >>
> >> createNode nurbsCurve -n "myNurbsCurveShape";
> >> setAttr myNurbsCurveShape.cc -type nurbsCurve 3 1 0 no 3
> >> 6 0 0 0 1 1 1
> >> 4 -2 3 0 -2 1 0 -2 -1 0 -2 -3 0;
> >>
> >> I would think that the python conversion would be:
> >>
> >> import maya.cmds as cmds
> >> cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
> >> cmds.setAttr('myNurbsCurveShape.cc',3,1,0,
> >>False,
> >>3,6,0,0,0,1,1,
> >>1,4,-2,3,0,-2,1,0,-2,-1,0,-2,-3,0,
> >>type='nurbsCurve')
> >>
> >> but this results in:
> >>
> >> # RuntimeError: Error reading data element number 7: 0
> >>
> >> These don't work either:
> >>
> >> import maya.cmds as cmds
> >> cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
> >> cmds.setAttr('myNurbsCurveShape.cc', """3 1 0 no 3
> >> 6 0 0 0 1 1 1
> >> 4 -2 3 0 -2 1 0 -2 -1 0 -2 -3 0""",
> >>type='nurbsCurve')
> >>
> >>
> >> import maya.cmds as cmds
> >> cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
> >> cmds.setAttr('myNurbsCurveShape.cc', (3,1,0,
> >>False,
> >>3,6,0,0,0,1,1,
> >>1,4,-2,3,0,-2,1,0,-2,-1,0,-2,-3,0),
> >>type='nurbsCurve')
> >>
> >>
> >> import maya.cmds as cmds
> >> cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
> >> cmds.setAttr('myNurbsCurveShape.cc', [3,1,0,
> >>False,
> >>3,6,0,0,0,1,1,
> >>1,4,-2,3,0,-2,1,0,-2,-1,0,-2,-3,0],
> >>type='nurbsCurve')
> >>
> >> ...any ideas on how to get this to work in python?
> >>
> >
> >
> > >
> >
>
> >
>

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



[Maya-Python] Re: setting one of the shape attributes using setAttr

2009-05-15 Thread John Creson
###
import maya.cmds as cmds
cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
cmds.setAttr('myNurbsCurveShape.cc',3,1,0,
   False,3,
   (0,0,0,1,1,1),6,
4,(-2,3,0),(),(2,1,0),(),(2,-3,0),(),(-2,-1,0),(),
type='nurbsCurve')


#

In the above example the 6 could also be () and the curve still seems to
build as expected.
I think the list knows how long it is...
I think the () after every CV may be a place holder for possible W values
when making rational curves.
(CV positions in x,y,z (and w if rational) )

On Wed, May 13, 2009 at 1:59 PM, barnabas79  wrote:

>
> Hey - I was wondering if anyone here has tried to set a 'nurbsCurve'
> attribute using setAttr (or, really, any of the shape attribute types
> - I assume the syntax will be similar between them).
>
> Ie, the docs have this example for mel:
>
> createNode nurbsCurve -n "myNurbsCurveShape";
> setAttr myNurbsCurveShape.cc -type nurbsCurve 3 1 0 no 3
> 6 0 0 0 1 1 1
> 4 -2 3 0 -2 1 0 -2 -1 0 -2 -3 0;
>
> I would think that the python conversion would be:
>
> import maya.cmds as cmds
> cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
> cmds.setAttr('myNurbsCurveShape.cc',3,1,0,
>False,
>3,6,0,0,0,1,1,
>1,4,-2,3,0,-2,1,0,-2,-1,0,-2,-3,0,
>type='nurbsCurve')
>
> but this results in:
>
> # RuntimeError: Error reading data element number 7: 0
>
> These don't work either:
>
> import maya.cmds as cmds
> cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
> cmds.setAttr('myNurbsCurveShape.cc', """3 1 0 no 3
> 6 0 0 0 1 1 1
> 4 -2 3 0 -2 1 0 -2 -1 0 -2 -3 0""",
>type='nurbsCurve')
>
>
> import maya.cmds as cmds
> cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
> cmds.setAttr('myNurbsCurveShape.cc', (3,1,0,
>False,
>3,6,0,0,0,1,1,
>1,4,-2,3,0,-2,1,0,-2,-1,0,-2,-3,0),
>type='nurbsCurve')
>
>
> import maya.cmds as cmds
> cmds.createNode('nurbsCurve',n="myNurbsCurveShape")
> cmds.setAttr('myNurbsCurveShape.cc', [3,1,0,
>False,
>3,6,0,0,0,1,1,
>1,4,-2,3,0,-2,1,0,-2,-1,0,-2,-3,0],
>type='nurbsCurve')
>
> ...any ideas on how to get this to work in python?
> >
>

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



[Maya-Python] Re: could someone please explain installation of mapy 2.5.6 on windows machine

2009-05-06 Thread John Creson
It's also possible to append to the sys.path in a file named userSetup.py
which can live in your local maya/scripts folder.

import sys
sys.path.append('\this\nice\path')

On Thu, May 7, 2009 at 1:06 AM, scottbvfx  wrote:

>
> Maya automatically appends PTYHONPATH to sys.path
>
> PYTHONPATH should be defined in the Maya.env file (ie. ..\Documents
> \maya\2009\Maya.env)
>
> inside of Maya.env you would have something like PYTHONPATH=C:\Users
> \scott\Documents\python
>
> *Warning: an OS environment variable PYTHONPATH will override the one
> in Maya.env. I had to find this out the hard way
>
> Hope this helps.
> -Scott
>  >
>

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



[Maya-Python] Re: python modules setup

2009-04-22 Thread John Creson
If you put an empty __init__.py file in each folder then each folder is
treated like a module

so you could
import myPythonScript as mps
mps.modeling.pyScript1.myfunc()


//but I may be missing a bit in here


On Wed, Apr 22, 2009 at 2:15 PM, sberger  wrote:

>
> Hi, I have this folder structure where I put all my python scripts.
>
> myPythonScript
>  modeling
>  pyScript1.py
>  pyScript2.py
>  animation
>  pyScript1.py
>  shading
>  pyScript1.py
>  pyScript2.py
>  pyScript3.py
>  etc..
>
> In these script when I need a function from another script I import it
> like so:
> from myPythonScripts import pyScript1
> and I acces it like this:
> pyScript1.functionX()
>
> I seems to have hit a wall now because most of the script rely on
> other script. In each script I import another one, but I think I have
> a case where scriptA is importing scriptB and scritB is importing
> scriptA, thus causing a import error.
>
> I would like to know how I can setup my modules so that I can simply
> import everything once, and that each script can easily access script
> from a different folder.
>
> I hope my question makes sense.
>
> Thanks
>
> >
>

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



[Maya-Python] Re: reverse boolean

2009-04-06 Thread John Creson
f=True

print (not f)


On Mon, Apr 6, 2009 at 3:38 PM, sberger  wrote:

>
> Hi, I am trying to reverse a boolean value.  I use this a lot in mel
> in UI creation to set the value to the reverse of another control.
> For example, in mel this works fine:
> $a = true;
> print (!$a);
>
> How can I do this in python?  I'm sure the solution is simple but for
> some reason i can't figure this one out
> >
>

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



[Maya-Python] Re: compile a scripted plugin as pyc

2009-04-01 Thread John Creson
It looks like it's using the .py file that just imports everything from the
module to encourage maya to properly load the plugin.

So, the one line Plugin file is needed so you can loadPlugin on it, which
sets maya up properly to register the plugin.  Thus navigating around the
need to loadPlugin on a .py file while wanting to distribute .pyc files.

If you're unsure of what to put into the __init__.pyc file, don't worry too
much, try with an empty file, or check out pymel's for some hints on what is
possible.  The init file allows Python to recoginse the containing folder as
a module (almost like looking at all the files within it's folder as being
part of one big text file broken up into understandable parts.)

On Wed, Apr 1, 2009 at 10:58 AM, Simon  wrote:

>
> hi John ,
>
> thanx for your answer . i already tried to "import" my plugin within the
> scripteditor , and maya created the .pyc-file but i remember maya
> reported me some errors , that he "cant import" the *.py-file ( i think
> , that is because you cannot "import" scripted-plugins)
>
> so , as you described , the pyc did not load proper in the plugin-manager .
>
> on highend3d.com i found one python plugin ( stretchIK ) , that uses pyc
>  but inside the zip from highend , there is next to the pyc also a
> __init__.pyc , and i dont know , how to create this __init__pyc in order
> to initialize the plugin proper , or if there is a better way , of
> compiling scripted-plugins , as i did not find any information on the
> net , yet , about - compiling python-plugins .
>
> here is a link to the file i mentioned , that uses a pyc-file
> http://highend3d.com/maya/downloads/plugins/animation/Stretchy-ik-4863.html
>
> so maybe anyone can explain , that would be very nice
>
> have a nice day
> Sim.On
>
>
>
>
> John Creson schrieb:
> > compiling it is not an issue, just load the plugin and Python makes
> > the .pyc in the file next to the plugin.
> > Getting Maya to load in the .pyc file is another question.
> >
> > On Wed, Apr 1, 2009 at 3:56 AM, sim.On  > <mailto:sim.mnemo...@googlemail.com>> wrote:
> >
> >
> > hi ,
> >
> > i am just curious , how to compile a scripted-plugin as pyc ?
> >
> > i know , python-pycs can be easily reverse-compiled and i read about
> > incompatibility-issues , that mkight come along , when using
> different
> > versions of python , but i still want to know "HOW TO" create a pyc-
> > plugin.
> >
> > thank you for you help and have a nice day
> > Sim.On
> >
> >
> >
> > >
>
>
> >
>

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



[Maya-Python] Re: compile a scripted plugin as pyc

2009-04-01 Thread John Creson
compiling it is not an issue, just load the plugin and Python makes the .pyc
in the file next to the plugin.
Getting Maya to load in the .pyc file is another question.

On Wed, Apr 1, 2009 at 3:56 AM, sim.On  wrote:

>
> hi ,
>
> i am just curious , how to compile a scripted-plugin as pyc ?
>
> i know , python-pycs can be easily reverse-compiled and i read about
> incompatibility-issues , that mkight come along , when using different
> versions of python , but i still want to know "HOW TO" create a pyc-
> plugin.
>
> thank you for you help and have a nice day
> Sim.On
> >
>

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



[Maya-Python] Re: Dynamic UI in pymel

2009-03-31 Thread John Creson
I don't know if this is already protected for by Pymel, but if you were to
delete a bit of UI, like a shelfButton, you might want to put the deleteUI
into an execute deferred.
The bit below edits a shelf button that has been created "butt", to add to
the script to be executed by the shelf button an extra bit that deletes the
shelf button afterwards.

without the execute deferred, crashing may occur.

deleter = 'utils.executeDeferred(\'cmds.deleteUI("%s")\');'%(butt)

script = script + deleter

butt = cmds.shelfButton(butt, edit=True, command = script)


On Tue, Mar 31, 2009 at 12:59 PM, chadrik  wrote:

>
> looks really good. the only thing i think i would change would be to
> make the window name constant.  as it is, it seems that under certain
> circumstances the self.myWin attribute might not exist when the window
> actually does.
>
>
> class myUI(object):
>winName = 'myUI'
>def __init__(self):
>
>try:
>deleteUI(self.winName)
>except:
>pass
>
>self.myWin = window(self. winName)
> columnLayout()
>
>for i in range(5):
>button('b'+str(i),l='button_'+str(i), c = Callback
> (self.checkButton,i))
>self.myWin.show()
>
>def checkButton(self,id):
>print button('b'+str(id),query=True,label=True)
>
>
> -chad
>
>
>
> On Mar 31, 2009, at 4:51 AM, marcin wrote:
>
> >
> > I've question about creating dynamic ui in pymel. Is there a way to
> > make
> > this code more pythonic in pymel ?
> >
> > from pymel import *
> >
> > class myUI(object):
> >def __init__(self):
> >
> >try:
> >deleteUI(self.myWin)
> >except:
> >pass
> >
> >self.myWin = window()
> >columnLayout()
> >
> >for i in range(5):
> >button('b'+str(i),l='button_'+str(i), c = Callback
> > (self.checkButton,i))
> >self.myWin.show()
> >
> >def checkButton(self,id):
> >print button('b'+str(id),query=True,label=True)
> >
> >
> >
> > >
>
>
> >
>

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



[Maya-Python] Re: Dynamic UI in pymel

2009-03-31 Thread John Creson
I don't know if this is already protected for by Pymel, but if you were to
delete a bit of UI, like a shelfButton, you might want to put the deleteUI
into an execute deferred.
The bit below edits a shelf button that has been created "butt", to add to
the script to be executed by the shelf button an extra bit that deletes the
shelf button afterwards.

without the execute deferred, crashing may occur.

deleter = 'utils.executeDeferred(\'cmds.deleteUI("%s")\');'%(butt)

script = script + deleter

butt = cmds.shelfButton(butt, edit=True, command = script)


On Tue, Mar 31, 2009 at 12:59 PM, chadrik  wrote:

>
> looks really good. the only thing i think i would change would be to
> make the window name constant.  as it is, it seems that under certain
> circumstances the self.myWin attribute might not exist when the window
> actually does.
>
>
> class myUI(object):
>winName = 'myUI'
>def __init__(self):
>
>try:
>deleteUI(self.winName)
>except:
>pass
>
>self.myWin = window(self. winName)
> columnLayout()
>
>for i in range(5):
>button('b'+str(i),l='button_'+str(i), c = Callback
> (self.checkButton,i))
>self.myWin.show()
>
>def checkButton(self,id):
>print button('b'+str(id),query=True,label=True)
>
>
> -chad
>
>
>
> On Mar 31, 2009, at 4:51 AM, marcin wrote:
>
> >
> > I've question about creating dynamic ui in pymel. Is there a way to
> > make
> > this code more pythonic in pymel ?
> >
> > from pymel import *
> >
> > class myUI(object):
> >def __init__(self):
> >
> >try:
> >deleteUI(self.myWin)
> >except:
> >pass
> >
> >self.myWin = window()
> >columnLayout()
> >
> >for i in range(5):
> >button('b'+str(i),l='button_'+str(i), c = Callback
> > (self.checkButton,i))
> >self.myWin.show()
> >
> >def checkButton(self,id):
> >print button('b'+str(id),query=True,label=True)
> >
> >
> >
> > >
>
>
> >
>

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



[Maya-Python] Re: Dynamic attributes marked as NOT storable are saved

2009-03-24 Thread John Creson
Thanks, I'll update the bug.

On Mon, Mar 23, 2009 at 3:40 PM, barnabas79  wrote:

>
> Some code to illustrate:
>
> http://pastebin.com/m14dfb5ea
>
> import maya.cmds as cmds
>
> # Create a scene we will save
> cmds.file(f=1, new=1)
> node = cmds.createNode("transform", name='testNode')
>
> # Add a NON-STORABLE attribute, and set it to a non-default
> cmds.addAttr(node, longName='notStorable', storable=False,
> defaultValue=0)
> cmds.setAttr(node + '.notStorable', 3)
>
> # Save our scene
> cmds.file( rename='storableTest_referenced.ma' )
> cmds.file( force=True, save=True,  type='mayaAscii')
>
> # Now, make a new scene
> cmds.file(f=1, new=1)
>
> # Reference in our old scene
> cmds.file( 'storableTest_referenced.ma', r=True )
>
> # Check that the non-storable attribute was, in fact, not stored
> refNode = cmds.ls("*testNode")[0]
> print "Stored Value:", cmds.getAttr(refNode + '.notStorable')
>
> # Set it to a non-default
> cmds.setAttr(refNode + '.notStorable', 3)
>
> # Save our referencing scene, reopen it, and check
> cmds.file( rename='storableTest_referencing.ma' )
> cmds.file( force=True, save=True,  type='mayaAscii')
> cmds.file( 'storableTest_referencing.ma', o=True )
> print "Stored Value:", cmds.getAttr(refNode + '.notStorable')
>
> On Mar 23, 12:36 pm, barnabas79  wrote:
> > Heh... ah, I see. My mistake...
> >
> > However, I originally started looking into this because I had a
> > problem with a referenced file - and it seems that there may still be
> > a bug there.
> >
> > Ie, if you make a non-storable attribute in a file, save it, then
> > reference in that file in another scene, and alter that non-storable
> > attribute, the altered value IS saved (as a reference edit).
> >
> > - Paul
> >
> > On Mar 21, 6:07 am, Dean Edmonds  wrote:
> >
> > > On Fri, Mar 20, 2009 at 17:23, barnabas79  wrote:
> >
> > > > Dynamic attributes created with addAttr that have the storable flag
> > > > set to false are still written out to the file - see:
> >
> > > >http://pastebin.com/f3b83af36
> > > [...]
> > > > # Now, re-open that scene we just saved
> > > > cmds.file('storableTest.ma', force=True, open=True)
> >
> > > > # Check that the non-storable attribute was, in fact, not stored
> > > > print "Stored:", cmds.attributeQuery('notStorable', node = node,
> > > > exists=1)
> >
> > > You misunderstand the meaning of 'non-storable'. It means that the
> > > *value* of the attribute will not be stored in the file. The attribute
> > > itself will always be stored unless you remove it from the node.
> >
> > > --
> > > -deane
> >
> >
> >
>

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



[Maya-Python] Re: Which python UI package to choose ?

2009-03-01 Thread John Creson
Pyqt is not integrated in Maya.
Python is embeded in Maya, this enables one to use Pyqt in Maya, but
licensing is a different story.
JohnCreson
On Sat, Feb 28, 2009 at 4:31 PM, yury nedelin  wrote:

> If you on 64 bit you might have problems finding python UI modules, we
> could not find one few month ago, but we are on maya 8.5 and using 2.4
> python. Not sure if maya 9 has python UI modules that work 64 bit but it is
> somthing to consider.
>
> yury
>
>
>
>
> On Sat, Feb 28, 2009 at 12:56 PM, Mathew Berglund wrote:
>
>> searching around i found this:
>>
>> http://groups.google.com/group/python_inside_maya/web/using-pyqt-with-maya?pli=1
>>
>>
>> -Mat
>>
>> /*
>> Mat Berglund
>> Technical Animator
>> Volition, THQ
>> **/
>> “I heard this lady say “I love kids.” That’s nice, a little weird though.
>> It’s like saying “I like people, for a little while.” “How old are you? 14?
>> Get away from me!””
>>
>>
>>   On Sat, Feb 28, 2009 at 2:39 PM, demetrius 
>> wrote:
>>
>>>
>>> Re: pyQt - rumor has it that they will be offering a free commercial
>>> license in March/April.  Also I think (could be wrong) Maya has pyqt
>>> integrated in the package.
>>>
>>> suyati wrote:
>>> > hi barakooda,
>>> > we use qt for most of the UI`s (building them in QT designer and
>>> > converting them to pyqt).
>>> > works good from inside maya.
>>> >
>>> > -yuk
>>> >
>>> > On Feb 28, 5:35 pm, barakooda  wrote:
>>> >
>>> >> Thank you for the fast reply !
>>> >> i see wxPython, and
>>> >> PyQt
>>> >>
>>> >> i will happy to hear more suggestions before i start to dig
>>> >>
>>> >> thank you all!
>>> >>
>>> >> Barak Koren.
>>> >>
>>> >> On 28 פברואר, 12:29, Mathew Berglund  wrote:
>>> >>
>>> >>
>>> >>> In the past i've used wxPython. But the problem is it takes over the
>>> main
>>> >>> thread. so you have to use the maya command port and send your script
>>> calls
>>> >>> over to maya. A little bit of work up front, but i like the results.
>>> I
>>> >>> haven't tried other UI's.
>>> >>>
>>> >>> -Mat
>>> >>>
>>> >>> /*
>>> >>> Mat Berglund
>>> >>> Technical Animator
>>> >>> Volition, THQ
>>> >>> **/
>>> >>> “I heard this lady say “I love kids.” That’s nice, a little weird
>>> though.
>>> >>> It’s like saying “I like people, for a little while.” “How old are
>>> you? 14?
>>> >>> Get away from me!””
>>> >>>
>>> >>> On Sat, Feb 28, 2009 at 10:26 AM, barakooda 
>>> wrote:
>>> >>>
>>>  i almost  finish my core script (build it from scratch to teach my
>>>  self maya and python
>>>  here is my first output
>>>  http://www.youtube.com/watch?v=UQhipf3f_zc
>>> 
>>>  now i want to build UI and i prefer more universsal way of making UI
>>>  and not the standard mel UI
>>> 
>>>  any ideas suggestion will be welcome!!
>>> 
>>>  thank you
>>> 
>>>  Barak Koren
>>> 
>>> > >
>>> >
>>> >
>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>

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



[Maya-Python Club:1606] Re: ok this is MEL UI issue

2009-02-06 Thread John Creson
You can query all layouts in the scene and then ask which ones have a parent
that is that window.
Something like this... but you'd probably just assign it to a know variable
in python when you created the layout in the first place.

import maya.cmds as cmds

#Create a simple window containing a single column layout
#and a few buttons.
#
window = cmds.window(title='Layout Example')
column = cmds.columnLayout()
cmds.button()
cmds.button()
cmds.button()
cmds.showWindow( window )

#If you don't know that the layout is actually a 'columnLayout' then
#you may use the 'layout' command to determine certain properties.
#
cmds.layout( column, query=True, numberOfChildren=True )
cmds.layout( column, query=True, childArray=True )
cmds.layout( column, query=True, height=True )

windowChildren=[]
layouts= cmds.lsUI(controlLayouts=True)
for layout in layouts:
if (cmds.layout(layout,q=True,p=True)== window):
windowChildren.append(layout)
print(windowChildren)



On Fri, Feb 6, 2009 at 10:09 PM, yury nedelin  wrote:

> thanks
>
> This will definitely help but getting all children from Window itself would
> be very handy.
>
> I wonder if there is a way to do it from API.
>
> Yury
>
>
>
>
> On Fri, Feb 6, 2009 at 5:27 PM, Tim Fowler  wrote:
>
>> Query the childArray of the top level layout.
>>
>> eg:
>>
>> {
>>window;
>>columnLayout MyWindowLayout;
>>button; button; button;
>>floatSlider;
>>showWindow;
>> }
>>
>> layout -query -childArray MyWindowLayout;
>> // Result: button5 button6 button7 floatSlider1 //
>>
>>
>> On Fri, Feb 6, 2009 at 7:57 PM, yury nedelin  wrote:
>>
>>> What is a good way to list all children of a Window in MEL UI?
>>>
>>> Yury
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---



[Maya-Python Club:1532] Re: MFileIO.getReferenceFileByNode stupidness

2009-02-02 Thread John Creson
Hi Chad,

You probably know this already, but  referenceQuery command seems to do this


// Please specify a reference node, referenced file, or node from a
referenced file.

cmds.referenceQuery('ballGuy:pSphere1',filename=True)

# ,Result:, C:/My Documents/maya/projects/bugs/scenes/ballGuy.ma #


On Sat, Jan 31, 2009 at 5:10 PM, Chadrik  wrote:

>
>
> MFileIO.getReferenceFileByNode is giving me only the name of the file,
> not the full path to the file.  ( e.g.  'myfile.ma', not '/path/to/
> myfile.ma' )  is this its intended behavior or is there something else
> i have to do to make this command *not* completely worthless?
>
> thanks,
> -chad
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---



[Maya-Python Club:1458] Re: supress warning message

2009-01-14 Thread John Creson
catchQuiet is built to do this, but is in mel only...
So use mel.eval
But it doesn't get to the except situation...
Though you can use it in mel to quiet an if...

*
import maya.cmds as cmds
import maya.mel as mel
circle_X = cmds.circle(c=(1.1,0,0), nr=(0,1,0), s=8)[0]
circle_Y = cmds.circle(c=(-1.1,0,0), nr=(0,1,0), s=8)[0]
try:
   mel.eval('catchQuiet ("curveIntersect  circle_X circle_Y")') #warning
messages to suppress ...
except:
   pass*

On Wed, Jan 14, 2009 at 10:28 AM, sberger  wrote:

>
> Hi, I am trying to suppress maya warning message, but the try:/except:
> clause don't supress it.
>
> Anyone know how to do this?
>
> Here is a peice of code that repro the problem
>
> import maya.cmds as cmds
> circle_X = cmds.circle(c=(1.1,0,0), nr=(0,1,0), s=8)[0]
> circle_Y = cmds.circle(c=(-1.1,0,0), nr=(0,1,0), s=8)[0]
> try:
>cmds.curveIntersect( circle_X, circle_Y ) #warning messages to
> suppress ...
> except:
>pass
>
>
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---



[Maya-Python Club:1440] Re: maya.cmds - best way to pass a list to a proc when hitting a button?

2009-01-08 Thread John Creson
Also, you could put a query into the function you are calling that finds the
list for itself without relying on the button click to pass in the list.
The query in the function could look into a string variable on a node in the
scene, or query an environment variable, or query a text field control on
the gui window.



On Thu, Jan 8, 2009 at 6:41 PM, Chris G  wrote:

> Also you can use functools.partial for this :
>
> from functools import partial
>
> def someDef(theList, someParameter):
> ...
>
> cmds.button(command=partial(someDef, someList, someParameter=2))
>
>
>
> On Thu, Jan 8, 2009 at 2:24 AM, Ofer Koren  wrote:
>
>> Another way, somewhat similar to lambdas but without those 'buggy'
>> behaviours, is to use a 'callback' object:
>> class Callback:
>>  def __init__(self,func,*args,**kwargs):
>> self.func = func
>> self.args = args
>> self.kwargs = kwargs
>> def __call__(self,*args, **kwargs):
>> return self.func(*self.args, **self.kwargs)
>>
>>
>> def someDef(theList, someParameter):
>>
>>
>> cmds.button(command = Callback(someDef, someList, someParameter = 2))
>>
>>
>>
>> (FYI - Pymel has a more robust version of this object which supports Undo:
>>  from pymel import Callback)
>>
>>
>> On Wed, Jan 7, 2009 at 7:44 PM, Matthew Chapman wrote:
>>
>>>This is a common mistake, the way you have written this python
>>> will call 'someDef(someList)' and pass its results to named argument
>>> 'command'. There are a couple ways to get this to work the way you would
>>> like. My personal choice is this
>>>
>>> # Define a function that can take any named or unnamed arguments
>>> # the * tells python to put any unnamed arguments into a list
>>> # the ** tell python to put any names arguments into a dictionary
>>>
>>> def someDef(  *args, **kwargs ):
>>> # call function or have inline code that creates someList
>>> someList = getSomeList()
>>> print someList
>>>
>>> def buildUI():
>>>  # 
>>>
>>>  # create button and pass the function it self to the argument
>>>  # command=someDef() # will pass the result where as
>>>  # command=someDef   # passes the actual function to the argument
>>>
  cmds.button(command=someDef)
>>>
>>>
>>>   If you really want to pass  in data in the call as its being
>>> defined you should use a lambda. A lambda is an unamed function. I have
>>> heard of lambdas being buggy in certain instances because of how they are
>>> defined and stored in memory in modules like pyqt. Here is how you could
>>> write is.
>>>
>>> def buildUI():
>>> # ' ' ' ' ' ' ' ' ' ' '  \/
>>>
  cmds.button(command=lambda *args : someDef(someList ))
>>>
>>>
>>> If you new the namespace of you function you could always pass it as a
>>> string to 'command'.
>>>
>>> def buildUI():
>>> # ' ' ' ' ' ' ' ' ' ' '  \/
>>>
  cmds.button(command="myModule.someDef([%s] )" % str(someList))
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>> --
>>
>>
>> - Ofer
>> www.mrbroken.com
>>
>>
>>
>
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---



[Maya-Python Club:1377] Re: warnings using python

2008-12-02 Thread John Creson
I like that,
Though you might want to wrap it yourself a little tighter so the
function to call is not so long.

2008/12/2 kurian os ™ (R)കോപ്പിയടിച്ചാല്(c)ഗോതമ്പുണ്ട! <[EMAIL PROTECTED]>:
> import maya.OpenMaya as om
> om.MGlobal.displayInfo("my grey info message")
> om.MGlobal.displayWarning("my pink warning")
> om.MGlobal.displayError("my red error message
>
> Is this one is good ??
>
> http://groups.google.com/group/python_inside_maya/msg/27c842be4005c8e3
>
> On Tue, Dec 2, 2008 at 6:52 PM, John Creson <[EMAIL PROTECTED]> wrote:
>>
>> You can write a little function that wraps this as well.
>> Then you can re-use it.
>> And it will feel more pythonic
>> ###
>>
>> import maya.mel as mel
>>
>> def pyWarn(warnString):
>>warnMe = 'warning "'+warnString + '"'
>>mel.eval( warnMe )
>>
>> pyWarn('Hey There!')
>>
>> On Tue, Dec 2, 2008 at 11:16 AM, NPuetz <[EMAIL PROTECTED]> wrote:
>> >
>> > You can use the mel module to evaluate that warning command in MEL.
>> >
>> > import maya.mel as mel
>> > mel.eval( 'warning "Hey There!"' )
>> >
>> > On Dec 2, 4:25 am, rambelly <[EMAIL PROTECTED]> wrote:
>> >> Hi Guys,
>> >>
>> >> How do I do the purple warning as in mel:
>> >>
>> >> warning("my warning message")
>> >>
>> >> in python - without quiting my script?
>> >>
>> >> At the moment I have:
>> >>
>> >> raise Warning("my warning message")
>> >>
>> >> But this produces a red error (i think because 'raise' is used).
>> >>
>> >> Thanks,
>> >> rambelly
>> > >
>> >
>>
>>
>
>
>
> --
> സ്നേഹിക്കയില്ല ഞാന്‍
> നോവുമാത്മാവിനെ സ്നേഹിച്ചിടാത്തൊരു
> തത്വശാസ്ത്രത്തെയും
>
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---



[Maya-Python Club:1374] Re: warnings using python

2008-12-02 Thread John Creson

You can write a little function that wraps this as well.
Then you can re-use it.
And it will feel more pythonic
###

import maya.mel as mel

def pyWarn(warnString):
warnMe = 'warning "'+warnString + '"'
mel.eval( warnMe )

pyWarn('Hey There!')

On Tue, Dec 2, 2008 at 11:16 AM, NPuetz <[EMAIL PROTECTED]> wrote:
>
> You can use the mel module to evaluate that warning command in MEL.
>
> import maya.mel as mel
> mel.eval( 'warning "Hey There!"' )
>
> On Dec 2, 4:25 am, rambelly <[EMAIL PROTECTED]> wrote:
>> Hi Guys,
>>
>> How do I do the purple warning as in mel:
>>
>> warning("my warning message")
>>
>> in python - without quiting my script?
>>
>> At the moment I have:
>>
>> raise Warning("my warning message")
>>
>> But this produces a red error (i think because 'raise' is used).
>>
>> Thanks,
>> rambelly
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---



[Maya-Python Club:1206] Re: Faster way of writing to an ascii file

2008-10-15 Thread John Creson

Actually, you know, it might be the constant open and close  of the file.
You can open the file for write before the double loop
use the print statement to write out inside the double loop
then close after both loops have finished if that would work for you

On Wed, Oct 15, 2008 at 1:19 PM, Alex Segal <[EMAIL PROTECTED]> wrote:
>
> I would split the f.write line into two: one to query the data and do
> the format to a string, and the second one to f.write the string.
> Commenting out first and second would give the idea of which one to
> blame for slowing down.
>
> On Wed, Oct 15, 2008 at 8:12 AM, Horvátth Szabolcs
> <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> I'm doing some data exporting using a python scripted plugin command and
>> found the file output being very slow.
>> In a specific case the file write took 90 seconds and when I commented
>> the f.write() stuff (so the command only did the queries) it dropped to
>> 15 seconds.
>> This is the structure of the write part:
>>
>> for i in range(numberOfHairs):
>> ...
>>for j in range (numberOfPoints):
>>   ...
>>f.write("\t\t%.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f
>> %.3f\n" % (A[j][0], A[j][1], A[j][2], B[j][0]-A[j][0], B[j][1]-A[j][1],
>> B[j][2]-A[j][2], C[j], D[j][0], D[j][1], D[j][2]))
>> f.close()
>>
>> Am I doing completely wrong? What can I do to speed up ascii file writing?
>>
>> Cheers,
>> Szabolcs
>>
>>
>>
>> >
>>
>
>
>
> --
> Alex "Sasha" Segal
> [EMAIL PROTECTED]
> http://www.alexsegal.net
>
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---



[Maya-Python Club:1203] Re: Faster way of writing to an ascii file

2008-10-15 Thread John Creson

Have you tried using

test = r"C:\test.txt"
tF = open(test,'w')
thatThereString = "what you said up there turned into a string"
print >>tF,(thatThereString)
tF.close()

Or is this just the same thing...
Wonder if the modulo is causing you timing issues?

On Wed, Oct 15, 2008 at 11:12 AM, Horvátth Szabolcs
<[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm doing some data exporting using a python scripted plugin command and
> found the file output being very slow.
> In a specific case the file write took 90 seconds and when I commented
> the f.write() stuff (so the command only did the queries) it dropped to
> 15 seconds.
> This is the structure of the write part:
>
> for i in range(numberOfHairs):
> ...
>for j in range (numberOfPoints):
>   ...
>f.write("\t\t%.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f
> %.3f\n" % (A[j][0], A[j][1], A[j][2], B[j][0]-A[j][0], B[j][1]-A[j][1],
> B[j][2]-A[j][2], C[j], D[j][0], D[j][1], D[j][2]))
> f.close()
>
> Am I doing completely wrong? What can I do to speed up ascii file writing?
>
> Cheers,
> Szabolcs
>
>
>
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---



[Maya-Python Club:1180] Re: Maya Crash / Backup_History / scripts in Script Editor

2008-10-07 Thread John Creson

try not to forget the MELly:

[Maya-Python Club:1114] Re: mouse pointer

2008-09-17 Thread John Creson

if you right click over the object, the context sensitive menu will
also tell you the name of the object.


On Wed, Sep 17, 2008 at 7:38 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> hi!
> is it possible to program maya so that if i take my mouse over some
> object and i should know the name of that object
>
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---



[Maya-Python Club:1097] Re: Capturing stdout from mayaBatch

2008-09-09 Thread John Creson

Do try mayapy!


On Tue, Sep 9, 2008 at 5:18 PM, John Riddle <[EMAIL PROTECTED]> wrote:
> Embarrassingly, I haven't tried to use mayapy yet =\ For now, writing the
> output to a file and reading will work. Thanks for the suggestions!
>
> -Riddle
>
> On Sun, Sep 7, 2008 at 6:10 PM, Chadrik <[EMAIL PROTECTED]> wrote:
>>
>> how about using mayapy?  then you have full access to python to do
>> whatever you want.  write it out to file, pickle it, get ridiculous
>> and use sockets, generally do whatever.
>>
>> just a side thought, i started using nuke's python, and it really made
>> me appreciate how strong the foundation of maya's python
>> implementation is.  the details were wanting, but i really took the
>> strengths of mayapy  for granted.  Nuke 5.0 had nothing like that, and
>> nuke 5.1 has only a partial solution.
>>
>> -chad
>>
>>
>>
>>
>> On Sep 5, 2008, at 12:49 PM, John Creson wrote:
>>
>> >
>> > how about writing the stdout to a file and reading that?
>> >
>> > mayabatch -log "C:\temp\mayaOut.txt" -prompt
>> >
>> > On Fri, Sep 5, 2008 at 1:40 PM, [EMAIL PROTECTED]
>> > <[EMAIL PROTECTED]> wrote:
>> >>
>> >> I'm making a call to mayaBatch to query out some scene information
>> >> without having to actually GUI-open the scene. I make the call using
>> >> os.system as was wondering if there was an easy way to store the
>> >> stdout in a variable.
>> >>
>> >> So the mayaBatch call is using -prompt and then -command to query the
>> >> info from the given scene file.
>> >>
>> >> I've seen some various methods on the web that apparently allow you
>> >> to
>> >> capture the output like subprocess and popen. My problem with these
>> >> is
>> >> that the apparently stored information in my variable output isn't
>> >> readable.
>> >>
>> >> As I'm writing this I just thought of the possibility of using the
>> >> "command" to just store the info I need in a maya variable or
>> >> optionVar or something. I might try this though I don't know if the
>> >> variable will be accessible from the batch.
>> >>
>> >> Anyways, if anyone has any advice in this matter please let me know.
>> >> The need is to get some render information from a scene without
>> >> having
>> >> to open it and make it accessible to my script running in maya.
>> >>
>> >> Thanks
>> >> -Riddle
>> >>>
>> >>
>> >
>> > >
>>
>>
>>
>
>
> >
>

--~--~-~--~~~---~--~~
Yours,
Maya-Python Club Team.
-~--~~~~--~~--~--~---