[Maya-Python] feed user input value back to an attribute

2014-03-11 Thread Jason Huang
Hi everyone,

I am new to the forum. Please bear with me if my question sounds too vague.

Trying to create a simple spreadsheet-like interface to list the value of 
selected attribute and be able to update/feed the user input value back to 
the attribute shown in Attribute Editor. 

Here is the mock up code.

import maya.cmds as cmds

cmds.window(title = test window, w=400, h=600, mxb=False, mnb=False)
mainLayout = cmds.columnLayout(w=400, h=600)
cmds.tabLayout(imw=5, imh=5)
vrayMtlList = cmds.ls(type = VRayMtl)
cmds.columnLayout(Material matte ID, w=400, h=600)

for vrayMtl in vrayMtlList:
if cmds.objExists(vrayMtl + .vrayMaterialId):

currentMatteID = cmds.getAttr(vrayMtl + .vrayMaterialId)

matteIdValue = cmds.intFieldGrp(numberOfFields = 1, label=vrayMtl + 
_matteID, value1 = currentMatteID)

cmds.showWindow()

I was able to get a simple GUI with integer fields show up with current 
VRay material multimatte ID displayed. 
I want the Attribute Editor multimatte be updated when users type in new 
multimatte ID and press the Enter or hit a Button, but could not figure 
out how. 
I have tried to define a function to be called in the intFieldGrp or see if 
I missed a flag that can achieve this easily.

Any input would be much appreciated.

Thanks!



-- 
You received this message because you are subscribed to the Google Groups 
Python Programming for Autodesk Maya group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/88d4173a-9674-4bd6-9354-aa8fc4373705%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] 'module' object has no attribute

2018-02-21 Thread Jason Huang
Hi all,

I got stuck at the beginning of creating a UI interface and couldn't figure 
out what was missing.

ENV: Maya 2018 update 2, Windows 10.

script name: assetManager.py (saved in Maya 2018 scripts folder)
from Qt import QtWidgets, QtCore, QtGui
import pymel.core as pm 

class ObjectManager(QtWidgets.QDialog):
def __init__(self):

super(ObjectManager, self).__init__()

def showUI():
ui = ObjectManager()
ui.show()
return ui

In Maya script editor: (python panel)
import assetManager
reload(assetManager)

ui = assetManager.showUI()

Maya errors out: 
# Error: AttributeError: file  line 1: 'module' object has no 
attribute 'showUI' # 

I am following a course and the same code demo-ed in the course video works 
fine in teacher's Maya session.

Thanks,
Jason

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/c31b5c6f-15d1-4203-ae10-6eb59dfa2362%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] 'module' object has no attribute

2018-02-21 Thread Jason Huang
Hey Zeth, 

Sorry for the late response. Much appreciated for the attached script. It 
seems to be super handy tool. I am able to download the attachment just 
fine. Will definitely give that a go and let you know.

cheers,
Jason

On Wednesday, February 21, 2018 at 12:43:07 PM UTC-8, zeth willie wrote:
>
> Hey Jason-
>
> I've attached a script that I wrote a while back that may be useful for 
> stuff like this. Put it in your scripts folder (instructions for executing 
> in the header) and it will help manage your python paths (add, remove, 
> reorder). The first tab lets you save/load paths for quickly loading common 
> paths you use, the second tabs show the item in your python path in order 
> and lets you change a few things. Nothing too fancy, but might be helpful 
> for seeing what's going on.
> I assume dropping a file here isn't an issue. I'm sure I have it handy 
> online (somewhere other than in a big repo on github) if this doesn't work
>
> Zeth
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/345fe13d-8532-47dd-b5b0-f76a08a470d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] 'module' object has no attribute

2018-02-21 Thread Jason Huang
Thanks Marcus. Just tried that and apparently it's executing from the Maya 
2017 scripts folder
print(assetManager)


If I remove the assetManager.py from Maya 2017 scripts folder, everything 
is fine.
Is there a way to tell Maya 2018 to execute from the 2018 script folder 
instead of the 2017?


On Wednesday, February 21, 2018 at 7:18:40 AM UTC-8, Marcus Ottosson wrote:
>
> Try print(assetManager) to find out where the file actually resides on 
> disk, and make sure it’s the file you expect.
> ​
>
> On 21 February 2018 at 15:10, Jason Huang <jasonhu...@gmail.com 
> > wrote:
>
>> Hi all,
>>
>> I got stuck at the beginning of creating a UI interface and couldn't 
>> figure out what was missing.
>>
>> ENV: Maya 2018 update 2, Windows 10.
>>
>> script name: assetManager.py (saved in Maya 2018 scripts folder)
>> from Qt import QtWidgets, QtCore, QtGui
>> import pymel.core as pm 
>>
>> class ObjectManager(QtWidgets.QDialog):
>> def __init__(self):
>>
>> super(ObjectManager, self).__init__()
>>
>> def showUI():
>> ui = ObjectManager()
>> ui.show()
>> return ui
>>
>> In Maya script editor: (python panel)
>> import assetManager
>> reload(assetManager)
>>
>> ui = assetManager.showUI()
>>
>> Maya errors out: 
>> # Error: AttributeError: file  line 1: 'module' object has 
>> no attribute 'showUI' # 
>>
>> I am following a course and the same code demo-ed in the course video 
>> works fine in teacher's Maya session.
>>
>> Thanks,
>> Jason
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to python_inside_maya+unsubscr...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/c31b5c6f-15d1-4203-ae10-6eb59dfa2362%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/c31b5c6f-15d1-4203-ae10-6eb59dfa2362%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/b0645cb5-11a4-439a-8dac-891675411e17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] 'module' object has no attribute

2018-02-21 Thread Jason Huang
Thank you for the tips Marcus. As checking the PYTHONPATH, I guess the 
problem was I have an older version of assetManager.py saved in the 2017 
scripts folder and that directory is part of the PYTHONPATH directories 
Maya will look for modules. Maya 2018 might parse the 2017 scripts 
directory and execute the older version of assetManager.py first.

cheers,
Jason

On Wednesday, February 21, 2018 at 8:08:44 AM UTC-8, Marcus Ottosson wrote:
>
> Yes, try something like this.
>
> import sys
> sys.path.insert(0, r"C:\Users\jason\Documents\maya\2018\scripts")import 
> assetManager
>
> sys.path is a list of all directories Python will look for modules, prior 
> to importing it for the first time. It’s a somewhat forceful way of 
> achieving it however, it’s likely something is not right with your setup.
>
> Have a look at what your PYTHONPATH looks like.
>
> import os
> print(os.getenv("PYTHONPATH"))
>
> PYTHONPATH (may) contain paths that is eventually parsed into sys.path.
>
> If it contains anything, then that is where Python will look for your 
> modules. Next is having a look at your maya.env file of your user 
> directory, that can safely be empty. If neither of those have any content, 
> then something more murky is happening. Maya should be able to find scripts 
> from its own scripts directory without any interference. If all else fails, 
> remove/move your Documents\maya directory elsewhere, such that Maya can 
> create a new one without any customisations.
> ​
>
> On 21 February 2018 at 15:56, Jason Huang <jasonhu...@gmail.com 
> > wrote:
>
>> Thanks Marcus. Just tried that and apparently it's executing from the 
>> Maya 2017 scripts folder
>> print(assetManager)
>> > 'C:\Users\jason\Documents\maya\2017\scripts\assetManager.pyc'>
>>
>> If I remove the assetManager.py from Maya 2017 scripts folder, everything 
>> is fine.
>> Is there a way to tell Maya 2018 to execute from the 2018 script folder 
>> instead of the 2017?
>>
>>
>> On Wednesday, February 21, 2018 at 7:18:40 AM UTC-8, Marcus Ottosson 
>> wrote:
>>>
>>> Try print(assetManager) to find out where the file actually resides on 
>>> disk, and make sure it’s the file you expect.
>>> ​
>>>
>>> On 21 February 2018 at 15:10, Jason Huang <jasonhu...@gmail.com> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I got stuck at the beginning of creating a UI interface and couldn't 
>>>> figure out what was missing.
>>>>
>>>> ENV: Maya 2018 update 2, Windows 10.
>>>>
>>>> script name: assetManager.py (saved in Maya 2018 scripts folder)
>>>> from Qt import QtWidgets, QtCore, QtGui
>>>> import pymel.core as pm 
>>>>
>>>> class ObjectManager(QtWidgets.QDialog):
>>>> def __init__(self):
>>>>
>>>> super(ObjectManager, self).__init__()
>>>>
>>>> def showUI():
>>>> ui = ObjectManager()
>>>> ui.show()
>>>> return ui
>>>>
>>>> In Maya script editor: (python panel)
>>>> import assetManager
>>>> reload(assetManager)
>>>>
>>>> ui = assetManager.showUI()
>>>>
>>>> Maya errors out: 
>>>> # Error: AttributeError: file  line 1: 'module' object 
>>>> has no attribute 'showUI' # 
>>>>
>>>> I am following a course and the same code demo-ed in the course video 
>>>> works fine in teacher's Maya session.
>>>>
>>>> Thanks,
>>>> Jason
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Python Programming for Autodesk Maya" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to python_inside_maya+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/python_inside_maya/c31b5c6f-15d1-4203-ae10-6eb59dfa2362%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/python_inside_maya/c31b5c6f-15d1-4203-ae10-6eb59dfa2362%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from th

Re: [Maya-Python] 'module' object has no attribute

2018-02-21 Thread Jason Huang
ha...you are right. The 2017 scripts directory indeed shows up in front of 
the 2018 one based on the order listed. Seems like my Maya 2018 is going a 
bit bananas... :) 
Now I know what's going on and a solution. Thank you, Marcus!

On Wednesday, February 21, 2018 at 9:12:19 AM UTC-8, Marcus Ottosson wrote:
>
> Ah, well you can spot the order in which directories are evaluated by 
> looking at the order of paths in sys.path. You should find that the 2017 
> folder is before the 2018 folder. This shouldn’t be Maya’s doing, but 
> rather something happening elsewhere. 2018 shouldn’t know about 2017, nor 
> any other version before it.
>
> Ps. I use the word “should” rather than “is” because sometimes Maya simply 
> goes bananas. :)
> ​
>
> On 21 February 2018 at 17:03, Jason Huang <jasonhu...@gmail.com 
> > wrote:
>
>> Thank you for the tips Marcus. As checking the PYTHONPATH, I guess the 
>> problem was I have an older version of assetManager.py saved in the 2017 
>> scripts folder and that directory is part of the PYTHONPATH directories 
>> Maya will look for modules. Maya 2018 might parse the 2017 scripts 
>> directory and execute the older version of assetManager.py first.
>>
>> cheers,
>> Jason
>>
>> On Wednesday, February 21, 2018 at 8:08:44 AM UTC-8, Marcus Ottosson 
>> wrote:
>>>
>>> Yes, try something like this.
>>>
>>> import sys
>>> sys.path.insert(0, r"C:\Users\jason\Documents\maya\2018\scripts")import 
>>> assetManager
>>>
>>> sys.path is a list of all directories Python will look for modules, 
>>> prior to importing it for the first time. It’s a somewhat forceful way of 
>>> achieving it however, it’s likely something is not right with your setup.
>>>
>>> Have a look at what your PYTHONPATH looks like.
>>>
>>> import os
>>> print(os.getenv("PYTHONPATH"))
>>>
>>> PYTHONPATH (may) contain paths that is eventually parsed into sys.path.
>>>
>>> If it contains anything, then that is where Python will look for your 
>>> modules. Next is having a look at your maya.env file of your user 
>>> directory, that can safely be empty. If neither of those have any content, 
>>> then something more murky is happening. Maya should be able to find scripts 
>>> from its own scripts directory without any interference. If all else fails, 
>>> remove/move your Documents\maya directory elsewhere, such that Maya can 
>>> create a new one without any customisations.
>>> ​
>>>
>>> On 21 February 2018 at 15:56, Jason Huang <jasonhu...@gmail.com> wrote:
>>>
>>>> Thanks Marcus. Just tried that and apparently it's executing from the 
>>>> Maya 2017 scripts folder
>>>> print(assetManager)
>>>> >>> 'C:\Users\jason\Documents\maya\2017\scripts\assetManager.pyc'>
>>>>
>>>> If I remove the assetManager.py from Maya 2017 scripts folder, 
>>>> everything is fine.
>>>> Is there a way to tell Maya 2018 to execute from the 2018 script folder 
>>>> instead of the 2017?
>>>>
>>>>
>>>> On Wednesday, February 21, 2018 at 7:18:40 AM UTC-8, Marcus Ottosson 
>>>> wrote:
>>>>>
>>>>> Try print(assetManager) to find out where the file actually resides 
>>>>> on disk, and make sure it’s the file you expect.
>>>>> ​
>>>>>
>>>>> On 21 February 2018 at 15:10, Jason Huang <jasonhu...@gmail.com> 
>>>>> wrote:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I got stuck at the beginning of creating a UI interface and couldn't 
>>>>>> figure out what was missing.
>>>>>>
>>>>>> ENV: Maya 2018 update 2, Windows 10.
>>>>>>
>>>>>> script name: assetManager.py (saved in Maya 2018 scripts folder)
>>>>>> from Qt import QtWidgets, QtCore, QtGui
>>>>>> import pymel.core as pm 
>>>>>>
>>>>>> class ObjectManager(QtWidgets.QDialog):
>>>>>> def __init__(self):
>>>>>>
>>>>>> super(ObjectManager, self).__init__()
>>>>>>
>>>>>> def showUI():
>>>>>> ui = ObjectManager()
>>>>>> ui.show()
>>>>>> return ui
>>>>>>
>>>>>> In Maya script editor: (python panel)
>>>>>> import

Re: [Maya-Python] 'module' object has no attribute

2018-02-23 Thread Jason Huang
Works like a charm, Zeth. I am able to add, delete, move order of python 
paths in a nice little GUI. Awesome! Thanks so much!

-Jason

On Wednesday, February 21, 2018 at 12:43:07 PM UTC-8, zeth willie wrote:
>
> Hey Jason-
>
> I've attached a script that I wrote a while back that may be useful for 
> stuff like this. Put it in your scripts folder (instructions for executing 
> in the header) and it will help manage your python paths (add, remove, 
> reorder). The first tab lets you save/load paths for quickly loading common 
> paths you use, the second tabs show the item in your python path in order 
> and lets you change a few things. Nothing too fancy, but might be helpful 
> for seeing what's going on.
> I assume dropping a file here isn't an issue. I'm sure I have it handy 
> online (somewhere other than in a big repo on github) if this doesn't work
>
> Zeth
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/15d8f524-a608-4e35-bd63-68b128e83c5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] set VRay rect light target position via Python

2018-09-17 Thread Jason Huang
Hi all,

I am trying to set a VRay rect light's target at the world origin. 

I first try to modify the mel code to Python. With moving a rect light's 
target in the viewport, I got the code below as a starting point.
setAttr "VRayLightRectShape1.targetPos" -type double3 14.13 -108.221315 -
203.228502 ;

However, when I execute this as MEL, the target isn't moving at all.
setAttr "VRayLightRectShape1.targetPos" -type double3 0.0 0.0 0.0 ;

I have also tried anyway in Python the following code.
cmds.setAttr('VRayLightRectShape1.targetPos', 0.0, 0.0, 0.0, type="double3")
There is no error but nor is the light's target moving to the world origin.

Is there a way to access a Rect light's target and set its translate or an 
efficient way to set a rect light pointing at the world origin or a locator?


Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/7050a496-b852-46c2-85b9-32151253ce8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.