[Maya-Python] PyQt - Gui contents got resized but not the window

2019-11-22 Thread likage
Hi all, I am trying to 'scale' down the gui so as to reduce the spacing 
between my widgets whenever the tool is called.

I tried using `setFixedSize`, while it does seems to scales down to what I 
had wanted, but the window, see attached, stays as it is and it is not 
being scaled down with it.
As such, this has results in extra blank unnecessary spaces.

[image: gui_resize_issue.png]


My GUI comes from using qt-designer and the following is a small code 
portion of the GUI initialization:
class MyTool(MayaQWidgetDockableMixin, QtWidgets.QWidget):
def __init__(self, parent=None, dockable=True):
super(MyTool, self).__init__(parent=parent)

# self.ui comes from a qt-designer file
self.ui = Ui_MyTestWidget()
self.ui.setupUi(self)

# set other methods/ connections etc...
...
...

# Attempting to 'scale' down the widgets, seems to work but not for 
the window
# using self.adjustSize() does not seems to be doing anything
self.setFixedSize(890, 505)


This is how I called upon my GUI:
import main_tool
app = main_tool.MyTool()

Appreciate for any insights!

-- 
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/11579ffc-d7e2-4716-a70b-80e6dd6457a6%40googlegroups.com.


[Maya-Python] Cropping in Free Image Plane

2019-11-12 Thread likage
I have an animated image sequence, eg. the character reference is screened 
towards on the right hand side.
Since the left hand side of the sequence contains no reference/ it is 
blank, I would like to crop it out.

If I am using a polygon Plane > applied with a material that contains an 
animated image sequence.
I can use "Insert Edge Loop Tool" and define the portion for cropping > 
select the face and delete it.
And hence, I will be left with the portion of the character reference that 
I wanted,

Unfortunately I am not using polygon Plane but instead Free Image Plane and 
trying to replicate the above scenario onto the Free Image Plane..
The command "Insert Edge Loop Tool" cannot be used since it is not a 
polygon. Tried tweaking "Coverage Origin X" attribute under 'Placement 
Extras' section, while I seemingly able to 'crop' out the un-needed parts 
but it seems to have scale the image.

Wondering if anyone has tried to attempt something with a Free Image Plane 
or know of any workarounds that I can try adopting?

-- 
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/475ef6e7-8f23-483a-8939-4c56e188a06b%40googlegroups.com.


[Maya-Python] Hotkey "popup" message

2019-10-31 Thread likage
Hi everyone,

I am wondering if there is a cmds command or something, where when you hit 
a certain hotkeys, this "popup" message will be shown on the viewport?

Eg. If you press Ctrl+M, the popup menu - "The top menu bar is now hidden. 
Press Ctrl+m to show it"

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/2c4c3d89-34cf-42ac-8391-938585e180ed%40googlegroups.com.


[Maya-Python] Euler curve filer is not working for objects in animation layer

2019-10-17 Thread likage
Hi everyone, I have trouble in doing euler-filtering in a pythonic if the 
object channels is stemming from an animation layer (where the channels are 
in 'greenish-blue' instead of the red.

I tried the following:
sel = '|man_rig|hands|right_arm|right_hand_ctrl'
channels = ["translate", "rotate"]
axes = ["X", "Y", "Z"]
for channel in channels:
for axis in axes:
attribute = "{0}.{1}{2}".format(sel, channel, axis)
in_conn = cmds.listConnections(
attribute,
source=True,
plugs=True
)
cmds.filterCurve(in_conn, filter="euler")

The above code works if my object is not in animation layer(s).

When I enable 'echo all commands' in the Script Editor, it echoes out a 
long line, something as follows:
.._myAnimLayer_inputB .._myAnimLayer_inputA

How do I derive these inputA, inputB? Or if there is a better way to euler 
filter for objects whose channels are in animation layer?

-- 
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/a60c9b0d-73ec-4a4b-890a-42a4a4da3236%40googlegroups.com.


[Maya-Python] Factoring in animation layer while doing Animation baking

2019-10-17 Thread likage
I am trying to do some animation baking on some controllers in which these 
controllers were constrained to locators for additional animation refining 
purposes.

Some of the controllers are set with a keyframe in an animation layer.
Eg. ctrlA translation value in the said animation layer is at (10,10,10) 
respectively.

When I tried using 'cmds.bakeResults` onto the said controller, to do the 
animation baking, as soon I remove the locators, the controller got snapped 
to another position. 
However if I mute that animation layer, the controller got snapped back to 
the 'correct' positioning/ incurring some weird rotational values  but yet 
I would not want to remove/ merge the animation layer to the base or 
removing that 1 keyframe in that layer.

And so my question is, while using 'bakeResults', is is possible to factor 
in the values of the animation layer while making sure the controller 
'stays' as how it should be before the baking?

I tried 'cmds.bakeResults(ctrl, time=(startFrame, endFrame), 
 disableImplicitControl=False))' which does not seems to work. If I 
introduce in the argument - 'removeBakedAnimFromLayer = True', while it 
does seems to work, it is removing that 1 keyframe I have set initially.

-- 
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/74969a1e-f398-4532-bce7-f0f0d97e0d44%40googlegroups.com.


Re: [Maya-Python] Algorithm to display euler curves?

2019-09-12 Thread likage
Hey Marcus,
I apologize for my poor description..

I have attached some screenshots where I am trying to use Python to 
determine following:

[image: before_filter.jpg]


Notice some of the curves are showing a 'plateau' alike curve... These are 
the curves I am trying to derive  via python method. 




-- 
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/227d78a0-e098-41e8-8b80-e9795fef3e0e%40googlegroups.com.


[Maya-Python] Algorithm to display euler curves?

2019-09-11 Thread likage
I have a rig with 100+ controllers (some of them are animated etc), without 
opening up Graph Editor, in programming terms, how can I determine if x 
number of controllers need to be applied with 'Euler Curve'?

Is there a way that I can check without blindly using `cmds.filterCurve` 
towards all rig controllers?
I had like to print out the list of 'affected' curves and show it to Users 
so that they can look into those curves to take a second look at them...

-- 
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/aa2469df-c0a0-4acc-9368-670cfc996899%40googlegroups.com.


[Maya-Python] Re: Need help with QSlider collating as 1 undo

2019-08-02 Thread likage
I managed to make some leeway however I am still having issues with it.

# Connections that I have set for my slider
self.ui.planeSizeHorizontalSlider.sliderPressed.connect(self.slider_pressed)
self.ui.planeSizeHorizontalSlider.sliderReleased.connect(self.
slider_released)
self.ui.planeSizeHorizontalSlider.valueChanged.connect(self.
plane_size_slider)


def slider_pressed(self):
cmds.undoInfo(openChunk=True, chunkName='SlideTest')

def slider_released(self):
cmds.undoInfo(closeChunk=True, chunkName='SlideTest')

def plane_size_slider(self, value):
img_plane_node = self.get_current_img_plane()
value /= 10.00
self.ui.planeSizeLineEdit.setText(str(value))
self.set_plane_size(img_plane_node, value)

def set_plane_size(self, node, value):
width = cmds.getAttr("{0}.width".format(node))
height = cmds.getAttr("{0}.height".format(node))
ratio =  height / width

# This got regiters as additional actions...
cmds.setAttr("{0}.maintainRatio".format(node), 0)
cmds.setAttr("{0}.width".format(node), value)
cmds.setAttr("{0}.height".format(node), value * ratio)
cmds.setAttr("{0}.maintainRatio".format(node), 1)

However my undo queue is incorrect. Current queue stemming from the above 
code (where the queue is empty to begin with) where I perform 2 slides...
# 1:  # 
# 2:  # 
# 3:  # 
# 4:  # 
# 5: SlideTest # 
# 6:  # 
# 7:  # 
# 8:  # 
# 9:  # 
# 10: SlideTest #

Even so, when I do try to do an undo, it only works the first time and 
nothing was changing thereafter. I presume the 'empty' entries are coming 
from the `setAttr` in which I am expecting my undo queue to be something as 
follows:
# 1: SlideTest # 
# 2: SlideTest # 


Appreciate in advance for any replies.

-- 
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/01551416-e7b9-4288-b5fe-3689addec693%40googlegroups.com.


[Maya-Python] Re: Need help with QSlider collating as 1 undo

2019-08-02 Thread likage
any insights, anyone?

-- 
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/4e3e79fe-4e0e-4b7c-bbc8-7df996163d69%40googlegroups.com.


[Maya-Python] Need help with QSlider collating as 1 undo

2019-07-31 Thread likage
Hi all, I need some insights on this gui signals + undo.

In my tool, there is a QLineEdit and a QSlider in which both are connected/ 
linked to each other, where if you made changes in the QLineEdit, it will 
updates the QSlider, likewise if you made changes on the QSlider, it will 
updates the values in the QLineEdit.

Currently I am having issues with QSlider where I am trying to collate the 
actions (as User slides it) as 1 undo action.

Here is my code:
# The signal for the slider
self.ui.planeSizeHorizontalSlider.valueChanged.connect(self.plane_size_slider)


def plane_size_slider(self, value):
img_plane_node = self.get_current_img_plane()
value /= 10.00
self.ui.planeSizeLineEdit.setText(str(value))
self.set_plane_size(img_plane_node, value)

def set_plane_size(self, node, value):
width = cmds.getAttr("{0}.width".format(node))
height = cmds.getAttr("{0}.height".format(node))
ratio =  height / width

with UndoManager(): # UndoManager is a contextmanager
cmds.setAttr("{0}.maintainRatio".format(node), 0)
cmds.setAttr("{0}.width".format(node), value)
cmds.setAttr("{0}.height".format(node), value * ratio)
cmds.setAttr("{0}.maintainRatio".format(node), 1)

While in viewport, the imagePlane does gets scaled accordingly as I perform 
changes on the slider for visual purposes, but when it comes to undo, it 
seems to be to factoring into account of all the values that I have made 
(eg. the slider value was initially at 0 and I slide it to 10, and so 10 
actions/ undos)

My question here is, if there are ways in which I can tell my QSlider to:

   - still uses valueChanged (so that User can still visualize the scaling)
   - but collate the 'sliding' as one action/ undo instead?

I tried using `sliderReleased`  but it only seems to scale the item after 
it has been released.

# The signal for the slider
self.ui.planeSizeHorizontalSlider.valueChanged.connect(self.plane_size_slider)
self.ui.planeSizeHorizontalSlider.sliderReleased.connect(self.plane_size_slider)

def plane_size_slider(self, value):
img_plane_node = self.get_current_img_plane()
value /= 10.00
self.ui.planeSizeLineEdit.setText(str(value))

def plane_size_slider_release(self):
img_plane_node = self.get_current_img_plane()
value = float(self.ui.planeSizeLineEdit.text())
self.set_plane_size(img_plane_node, value)

def set_plane_size(self, node, value):
width = cmds.getAttr("{0}.width".format(node))
height = cmds.getAttr("{0}.height".format(node))
ratio =  height / width

with UndoManager(): # UndoManager is a contextmanager
cmds.setAttr("{0}.maintainRatio".format(node), 0)
cmds.setAttr("{0}.width".format(node), value)
cmds.setAttr("{0}.height".format(node), value * ratio)
cmds.setAttr("{0}.maintainRatio".format(node), 1)



-- 
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/71125b08-4335-4378-83bc-b38f68e30f9a%40googlegroups.com.


[Maya-Python] Pythonic access of the view transform button in viewport2.0

2019-07-19 Thread likage
Hi all, I am trying to get the state of the 'viewTransform' button (as 
depicted here 
)
 
whenever viewport2.0 is used.

I was not able to find much information online as I am trying to toggle 
this button/ state across all model panels (the main viewport and tear off 
panels if any)

And ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/f78e9182-dc91-4c0f-9850-d2a2c6343b6b%40googlegroups.com.


[Maya-Python] Making image plane size to stick/ move together in ortho cameras when zooming

2019-07-17 Thread likage
Hi everyone, I have a question regarding the use of image plane and it 
being 'constrained' to ortho cameras.

This is what I am trying to achieve:
* In persp, go to the menu View > Import Plane > Import Image
* Try doing a zoom in/out with the middle mouse button
* Note that the image plane sizing does not seems to shrink/ enlarge as you 
are doing the zooming

I tried to do the same for the other 3 ortho cameras. Using front camera as 
the above, I performed the same steps as above.
* While performing the zooming, the image plane size did get smaller (if 
you zoom out), or bigger (if zoomed in)

And so, my question here is if there is a way that I can make it 'stick' or 
having the same effect as the one in persp??

Currently I am creating the image planes with the use of cmds.imagePlane + 
cmds.parentConstraint but the output is the same as I have derived above.

-- 
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/a7fa5d2f-f244-482f-8fbc-817ce85bcc2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Precaching image sequences in Maya

2019-07-12 Thread likage
Hi Justin,

Tried out the method you have suggested, it does works to a certain extent 
but not exactly what I am looking for (I apologize for the way I have 
phrase my question now that I re-read it)

It is more of "I wanted the image sequences to play smoothly on the go".. 
But even so, I realized that even with the use of image planes, my scene 
was somewhat choppy/ lagging to begin with due to the x number of rigs used 
within the scene, eg. tried to scrub within a 10 frames range, at some 
frames, it took slightly longer than the other.

I suppose, in cases like this, Maya is trying to display the number of 
items in the scene and the imagePlanes/ sequences got affected by it as 
well?

-- 
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/14076e08-795f-4ab2-b88a-43b7de7181f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Precaching image sequences in Maya

2019-07-12 Thread likage
Are there any ways to pre-cache image sequences as they are used in 
imagePlanes?

Currently, I am using the `ffmpeg` command in which it converts a video 
source, eg. .mov into an image sequence. While the image may be generated 
in 720, there are times where my maya scene will becomes slows (I have more 
than 1 imagePlane/ sequences...)

Adding on, I am using more than just .jpg, in which there may be times I 
may be using either .png or .exr too.

-- 
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/c598c1e7-86ad-4cd6-b030-1bf65811a2af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] scriptJob event for editing attributes within graphEditor

2019-07-11 Thread likage
Is there a scriptJob event that will allows me to:

   - detect whenever a change is made in graphEditor
   - and knowing which attribute it has been modified?

I tried using the following:
def ge_track():
print 'changes made in graph editor'

test = cmds.scriptJob(event=["graphEditorParamCurveSelected", ge_track])

While it does detects whenever I highlighted a said key of an attribute 
(whether did I modify the value or not), but I could not tell which 
attribute it was effected on.

-- 
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/a68eb9b8-28de-4aa0-be97-9c4183f4c9f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Placement of contextmanger usage within code

2019-07-10 Thread likage
I have created a contextmanager that tracks/registers for undo and I have 
some questions, mostly on what is the best way to use/ code it as I am 
unsure which is the best approach.

In my utils.py file, I place the contextmanger class within, along with 
other utility functions that are used in main.py file.
Here is a snippet of it.

main.py
class MyTool(MayaQWidgetDockableMixin, QtGui.QWidget):
def__init__(self,parent=None):
...
self.undo_manager = utils.UndoManager()
self.ui.resetButton.clicked.connect(self.reset_keys)

def reset_keys(self, attr_list):
# with self.undo_manger:
utils.remove_keys(attr_list)


utils.py
class UndoManager(object):
def __init__(self):
  pass

def __enter__(self):
cmds.undoInfo(openChunk=True)

def __exit__(self, type, value, traceback):
cmds.undoInfo(closeChunk=True)

def remove_keyed(attr_list):
with UndoManager:
for attr in attr_list:
cmds.cutKey(attr)


My question here is, where is the most appropriate place for me to place 
the use of `UndoManager`, in utils.py or in main.py (in coding standards)? 
And/Or if the use of the contextmanager that I have wrote or use is correct?

Currently, I have been placing them in utils.py, and in my other files, I 
also did use `self.undo_manager` as the convention to track/register the 
actions for undo. So far it seems to work but would like to keep my code 
'clean' and tidy.


-- 
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/e6867fab-b2ec-47ad-96c8-5a0a59395f99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] (Real) Time update/ actions between Gui and Maya

2019-07-10 Thread likage
I manged to get this figured out. Thank you all for the help :)

-- 
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/76824d6b-a418-423a-a5b4-430fb627d038%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] (Real) Time update/ actions between Gui and Maya

2019-07-08 Thread likage
I tried to move the `cmds.undoInfo` into list_item_click() method where the 
chunk will be opened and closed upon the renaming (after the 
self.validate_naming) and before I perform any undo, I tried to print out 
the list of undo in the queue, in which it returns me as follows:

cmds.undoInfo(query=True, printQueue=True)

# Returns the following result:
...
# 39:  # 
# 40:  # 
# 41:  # 
# 42:  # 
# 43: MyTool_chunkName # 
# 44:  # 
# 45:  # 
# 46:  # 
# 47:  # 
# 48:  # 
# 49:  # 

At the very least I had thought I would be able to capture this process as 
1 action. Is there a way to remove all these 'empty' undo actions?

-- 
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/b752c70e-e87b-4c6d-bd1b-307dbc4fd45f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] (Real) Time update/ actions between Gui and Maya

2019-07-08 Thread likage
Hi Justin, thank you for getting back.

As for the DockWidget() class method you have provided, sadly it does not 
seems to be working for me. Getting the same issue (signal not getting 
called) as soon as `self.ui.setupUi(self)` is implemented.
-

I tried using the following in my main.py for the `cmds.undoInfo` as 
follows:

def create_custom_script_jobs(self):
...
cmds.undoInfo(chunkName='MyTool_chunkName', openChunk=True)

def remove_custom_script_jobs(self):
...
cmds.undoInfo(chunkName='MyTool_chunkName', closeChunk=True)


It seems that I am the undo actions are not getting compress into 1 
action... Am I doing it wrong?
Also tried implementing the above code in my execution code, not seeing any 
diff...

-
Noted on the global usage for script jobs tracking.

As for the selections, I made it that way because, I need to achieve 2 
things.
1. Whatever that is selected in the Maya context (image planes in this 
case), if found in the tool context, selects the said item in the tool 
(which is under QListWidget).
2. Selection made in the tool context - QListWidget (again, only the image 
plane selection), will be selected in the Maya context if found.

Basically a bi-directional selection between my tool and Maya. As you have 
suggested, upon the removal of the `cmds.select` in the `plane_selected()` 
seems to have did the trick in the key selection in Graph Editor! Thank you.

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


Re: [Maya-Python] (Real) Time update/ actions between Gui and Maya

2019-07-05 Thread likage
Thought I placed my files here as I could not really figure out the undo or 
the graph editor selection...

main.py - https://pastebin.com/aQL9Fvue
refplanes.py - https://pastebin.com/zzKkFYxc
utils.py - https://pastebin.com/SXidXLTH
refplanes_ui.py - https://pastebin.com/qCGGqZEF

Appreciate in advance if anyone could shed any lights on it.

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/a4cd6401-5ec7-468b-92ea-86edcb9f41bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] (Real) Time update/ actions between Gui and Maya

2019-07-05 Thread likage
Could you kindly elaborate more on `rename wasn't wrapped in an Undo 
group`? I am not quite understanding here...
I did not create any 'groups' (cmds.undoInfo) if you are referring to 
that...

And unfortunately, there seems to be another issue where - when trying to 
select any keys in the Graph Editor (it did a super quick select and 
unselect action), seemingly caused by the scriptjobs I have created...

-- 
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/9cfbf62f-17f1-4722-8656-23cefed88cc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] (Real) Time update/ actions between Gui and Maya

2019-07-05 Thread likage
Thank you Justin. Will try out your method.
I have 2 questions here:

1. For the approach I have adopted - 'using scriptJob to track tool 
closure' , is that still applicable/advisable?

2. And one more question - For the `undo` that I have implemented, eg. 
perform an un-renaming process, I noticed that it takes me to press the 
'undo' combination 7 times just to get the name of the node back to its 
initial naming, instead of the 1 time that I am expecting

Any insights on this?

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


Re: [Maya-Python] (Real) Time update/ actions between Gui and Maya

2019-07-04 Thread likage
Got it, thanks!

Is there a way in which I can also use script job to detects when my custom 
tool is closed?
I am using `MayaQWidgetDockableMixin` in which the `closeEvent` is not 
calling (`dockCloseEventTriggered` does gets called and executed if the 
tool is docked) and it is not removing the scriptjobs that I have created..

-- 
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/42b20895-e304-4b11-9902-e9d48d0bf24e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] (Real) Time update/ actions between Gui and Maya

2019-07-03 Thread likage
Hi, I have not. I was not aware of the above 2 you have mentioned. This may 
sounds very noobish of me - but how do I use them?

Additionally, I could be wrong on this but while I was googling around, 
trying to find a way, I chanced upon Model View Controller (something that 
I was not aware of too).
It seems that this case of MVC may or may not be applicable in my cause, 
but what is the best scenario to use MVC then?

-- 
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/8a569a28-2fa2-43a7-ba54-9bc5152008cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] (Real) Time update/ actions between Gui and Maya

2019-07-03 Thread likage
Hi everyone, I am trying to make a real-time update, eg. a renaming between 
maya scene and my tool. Previously I made a thread about it, but seeing 
that it is a bit confusing, I have decided to make a new thread and repost 
it with coding on what I am trying to achieve.

Currently I am able to effect changes from my tool and modify the naming in 
the scene. But in the event if I perform an undo in the maya scene itself, 
the undo changes are not effected back into the tool.

Here is my code:

class Example(QtGui.QWidget):
def __init__(self, parent=None):
super(Example, self).__init__()
self.initUI()
self.setup_connections()

def initUI(self): 
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Rename')

self.list_widget = QtGui.QListWidget()
self.add_loc_btn = QtGui.QPushButton("Add new Locator")

vlayout = QtGui.QVBoxLayout()
vlayout.addWidget(self.list_widget)
vlayout.addWidget(self.add_loc_btn)
vlayout.addStretch(1)
self.setLayout(vlayout)

def setup_connections(self):
self.add_loc_btn.clicked.connect(self.add_locator)
self.list_widget.itemDoubleClicked.connect(self.list_item_dbl_click)
self.list_widget.itemChanged.connect(self.list_item_click)

def add_locator(self):
new_loc = cmds.spaceLocator()
loc_fp = cmds.ls(new_loc[0], long=True)
loc_item = QtGui.QListWidgetItem(str(new_loc[0]))
loc_item.setData(32, loc_fp[0])
loc_item.setFlags(
loc_item.flags() |
QtCore.Qt.ItemIsUserCheckable |
QtCore.Qt.ItemIsEditable
)
self.list_widget.addItem(loc_item)

def list_item_dbl_click(self):
current_item = self.list_widget.currentItem()
self.prev_name = current_item.text()
self.rename_counter = 1

def list_item_click(self, test):
success = False
current_item = self.list_widget.currentItem()
list_item_row = self.list_widget.currentRow()
new_name = current_item.text()

if self.validate_naming(new_name):
locator = current_item.data(32)
if cmds.objExists(locator) and self.rename_counter == 1:
cmds.select(locator)
cmds.rename(new_name)

# reset counter back to 0
self.rename_counter = 0
success = True

else:
# Set back to its initial naming before rename
current_item.setText(self.prev_name)

if success:
list_item = self.list_widget.item(list_item_row)
self.list_widget.setCurrentItem(list_item)

def validate_naming(self, name_input):
if re.search("^\s*[0-9]", name_input):
LOG.warning("Input naming cannot be started off with numbers!")
return False
return True


myWin = Example()
myWin.show()

Here are some steps to reproduce:

   - Click on the ‘Add new Locator’ button
   - It will creates a locator1 in the scene and populated in the list 
   widget
   - Double click on the locator1 in the list widget and input in a new 
   name. Eg. ‘myLocator’
   - Go back to Maya and tried pressing ‘Ctrl+Z’ (undo)
   - While it does changes the name ‘myLocator’ back to ‘locator1’ in Maya 
   context, I would also like it to be ‘updated’ in my Gui.
   
How should I go about doing this?
P.S: I was also trying to find a way to peform undoing in the Gui which 
will also in turns effects the changes in the Maya scene if possible.

-- 
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/63af8ecf-5d67-4004-a076-34fc68019d9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Using undo between Qt Gui and Maya

2019-07-02 Thread likage
Hi Michael, sorry for the late response on this. 
While I understand your first point, but for the other point - `have your 
GUI update when the values it is tracking in Maya change (eg when someone 
undoes something in Maya)`, how do I go about doing it?

Is that something to be implemented in my GUI itself/ to create a new 
filter or something?

I tried to do something as follows (for a selection case):

if event.type() == QtCore.QEvent.WindowActivate:
# get current scene selection
sel = cmds.ls(sl=True, l=True)[0]
# where myListWidgets contains all the locators
for index in range(self.ui.myListWidget.count()):
# `.data(32) is storing the full path of the locators
if sel == self.ui.myListWidget.item(index).data(32):
self.ui.myListWidget.setCurrentRow(index)

However, it will only selects the items in the list widget if I focus back 
to my window...

-- 
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/f12ec7e9-131b-4b00-87e0-9f803c0ba1a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Using undo between Qt Gui and Maya

2019-06-26 Thread likage
Adding on, my Gui was created using qt designer

-- 
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/ca3c2874-02d0-46e1-9cf5-7cbcd59e4b5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Using undo between Qt Gui and Maya

2019-06-26 Thread likage
Hi everyone,

I have a Gui created from using Qt where it has widgets that creates 
locators (populated as part of a list item in QListWidget) and interacts 
with some of its attributes (eg. the TranslateXYZ + Local PositionXYZ)

In maya context, you will be able to perform n times of undo. But my 
question here is how can I make undo to happen within the Gui?
Currently, if I have made changes in (assuming by default the line edit 
starts with 0):

   - Set 10 in the translate x line edit
   - Set 5 in the translate y line edit

If I tried to press 'Ctrl+Z' where the translate y line edit is in focus, 
it is able to change the value from 5 to 0.
However if I go to the translate x line edit, nothing happens and the value 
still stuck at value of 10.

Or if I have made a button that says "Key Selected", while it does keys the 
attribute, however when using Undo, I have to hit Ctrl+Z multiple just so 
to 'remove' the key that I have set.

Is there a better way in which I can try adopting that allows me to do undo 
more efficiently?

-- 
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/f45639cb-6794-4a16-b42c-377218b80246%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] visibility attribute is using stepped tangent when I code it to use linear

2019-06-24 Thread likage
Hi everyone, I am trying to set some keyframes on the attributes 
pythonically but noticed that only the "visibility" attribute is touched 
upon, both the `inTagentType` and `outTagentType` are not factored into 
account.

Eg. in my code, I have sent them to be keyframed with linear tangents, but 
for the visibility attribute, it comes out as stepped.
Here is a snippet of my code:

from maya import cmds
loc = cmds.spaceLocator(name="test")
loc_tx = "{0}.translateX".format(loc[0])
loc_vis = "{0}.visibility".format(loc[0])

# At Frame 1
cmds.currentTime(1)
cmds.setKeyframe(loc_tx, inTangentType="linear", outTangentType="linear")
cmds.setKeyframe(loc_vis, inTangentType="linear", outTangentType="linear")

# At Frame 10
cmds.currentTime(10)
cmds.setAttr(loc_tx, 10)
cmds.setKeyframe(loc_tx, inTangentType="linear", outTangentType="linear")
cmds.setAttr(loc_vis, 0)
cmds.setKeyframe(loc_vis, inTangentType="linear", outTangentType="linear") 
# This will still returns me in stepped tangent

The only method that I can conform the visibility curve to use linear 
tangent is to run the following line after the above code block:
(it is almost the same code when I uses `setKeyframe`)
cmds.keyTangent(loc_vis, edit=True, inTangentType='linear', 
outTangentType='linear')

Am I missing something in my code? Or how can I enforce it to use `linear` 
as the in/outTangentType whenever I am setting a keyframe...

-- 
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/2aa8b125-c02f-4427-8f2b-9544d446a977%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Multiple actions in 1 QAction

2019-06-20 Thread likage
Hi everyone, I created a tool using Qt Designer, where it has 3 QLineEdits 
that is catered for translateX, translateY and translateZ. 
For each QLineEdit, I have created a context menu that allows me to set a 
keyframe for one of the above attribute depending on User's choice.

So instead of writing 3 separate functions that catered to each attribute, 
I thought of 'recycling' them by using 1 method, but I am having issues 
with it as I am not very sure if it will be possible since I am using a 
single QAction.

class MyTool(QtGui.QWidget):
def __init__(self, parent=None):
super(MyTool, self).__init__(parent = parent)
# Read off from convert uic file.
self.ui = Ui_MyWidget()
self.ui.setupUi(self)

# translateX
self.ui.xLineEdit.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)

self.ui.xLineEdit.customContextMenuRequested.connect(self.custom_menu)
# translateY
self.ui.yLineEdit.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)

self.ui.yLineEdit.customContextMenuRequested.connect(self.custom_menu)
# translateZ
self.ui.zLineEdit.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)

self.ui.zLineEdit.customContextMenuRequested.connect(self.custom_menu)

self.popMenu = QtGui.QMenu(self)
set_key_action = QtGui.QAction("Set Key at Current Frame", self)

# I am having issues here..
set_key_action.triggered.connect(self.set_key)

self.popMenu.addAction(set_key_action)

...
...

def set_key(self, attr):
# assuming I am trying to effect this locator1 that already exists 
in the scene
current_item = "|locator1" 
cmds.setKeyframe("{0}.{1}".format(current_item, attr))

def custom_menu(self, point):
self.popMenu.exec_(QtGui.QCursor.pos())

I thought of using `functools` so that my code will be something like :
class MyTool(QtGui.QWidget(:
def __init__(self, parent=None):
...
...
functools.partial(self.set_key, "tx")

def set_key(self, attr):
if attr == "tx":
# setkeyframe to translateX
elif attr == "ty":
# setkeyframe to translateY

Again, because it is only a single QAction and hence I was stumped... Or 
will it be better for me to stick in using 3 separate functions instead?

-- 
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/a3c45192-ec1e-4a85-87de-63ac2de131a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Checking what controllers uses pre/post infinity

2019-05-24 Thread likage
What is the best way that I can check if (a) controllers are using pre/post 
(cycle) infinity?

Currently I am using the following:
# Get the first frame used in all controllers
first_frame = cmds.findKeyframe(controller_selections, which="first")
# Get the last frame used in all controllers
last_frame = cmds.findKeyframe(controller_selections, which="last")

# Execute my method to set key towards all controllers (see below for the 
cmds.bakeResults)
anim_bakeout(controller_selections, (first_frame, last_frame))

as a way to enforce all controllers within a rig are keyed at all frames.
for ctrl in controller_selections:
cmds.bakeResults(
ctrl,
hierarchy="both",
preserveOutsideKeys=True,
simulation=True,
time=(first_frame, last_frame)
)


This is done so that it does not messed up the `cmds.bakeResults` should I 
should be baking a certain frame range.

However, while doing the above pre-checking, if my rig in scene does have a 
lot of controllers (eg. a creature rig which has about 300+ controllers), 
the process can be slow?

-- 
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/c504fc76-eea8-4daf-8830-883a0270d993%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Maya bugs/ issues page

2019-03-28 Thread likage
Hi all,

I may be missing something when I went over to the Autodesk forum, but I am 
wondering if there is a page that enables me to see what bugs/issues has 
been reported? Something similar to Jira?
It was some years ago that I saw a similar page, not sure if the said page 
still exists or if it does belongs to Autodesk...

-- 
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/d7eb628c-4f63-438f-8855-860b8d89c6ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Trying to run a linux command in Maya

2019-03-04 Thread likage
Got it, many thanks for the replies :D

-- 
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/a17e5a95-a44a-4fab-812d-2646d6d29e3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Trying to run a linux command in Maya

2019-03-04 Thread likage
Hi Justin,

I have managed to get it to work by using the absolute path but with those 
commands saved in another .py file within the list of python paths that 
MAYA is reading from..
As such, my python file is as follows:
import subprocess

def main():
process = subprocess.Popen(['/bin/meld'], stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
stdout, stderr = process.communicate()


One more question though - while I am able to execute my program, I could 
not work on my current maya session until this `meld` tool is closed.
Wondering if this is a common thing when trying to run an external program 
in Maya, or if it is possible to get `meld` to work in the background?

-- 
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/bf395230-be1b-44ee-ade7-e4d04739c43d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Trying to run a linux command in Maya

2019-03-01 Thread likage
Hi everyone, I am trying to launch a terminal command (I am using Linux) in 
Maya.

In the terminal, if I typed in `meld`, it launches an editor.
If I try to incorporate the following in Maya context, by using the 
following:

subprocess.call(['meld'], shell=True)

or `shell=False`, or remove the `shell` argument.. No editor is showing up.

Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/292d677e-a469-4f04-81cf-3ddbde468235%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Maya preferences question

2019-01-28 Thread likage
Adding on, I asked this, because, initially there is already a .conf file 
of this tool that I was working on, and while I made some changes towards 
the tool (eg. the window size), even in a new Maya session, the .conf file 
does not seems to be overwriting with the new window size unless I remove 
the 'old' conf file and re-launching the tool..

-- 
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/7859043b-7caf-483e-b9bb-4d56fb42ada1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Maya preferences question

2019-01-28 Thread likage
Hi all, I have a question about Maya preferences

Does saving of Maya Preferences (File > Save Preferences) may in any ways 
interfere :

   - with .conf files?
   - one of the 'best' method to resolve maya crashes (removing of the 
   prefs folder)?

About the latter point, there are times that I have to use between Maya 
2017 and 2018 to test out some of the tools that I am writing, not sure if 
this could be part of a typical maya issue or whatnot..

-- 
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/01d1c2c1-0e86-4e43-94ad-d9ee08858063%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] New items are not added into QMenu

2019-01-15 Thread likage
Thanks for the information, Justin.
After re-arranging the `self.separator` I managed to get the newly created 
items to be slotted into the specified position of mine.

While this seems to be working, as I tried to implement in the same makings 
into my actual tool, I keep getting `RuntimeError: Internal C++ object 
(PySide2.QtWidgets.QAction) already deleted.`, seemingly the 
`self.separator` got killed off in the midst of it.
The code structure in my actual tool is almost the same as the one that I 
have posted in this thread, with the exception that I have 'watered' down 
the code in this thread in hopes of keeping it short and simple.

Even so, wondering if you may any advice to this? Read online for this 
issue is to make it into a variable in which I did, but still it did not 
work. 
However, if I do the following:
def mousePressEvent(self):
   self.separator =  self.qmenu.addSeparator()
...

items can still be created and added into the menu, but this time round, 
each will be created with both the item and the separator altogether

-- 
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/c2eedb45-b913-4430-a6f8-e39a5a2d3a78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] New items are not added into QMenu

2019-01-15 Thread likage
Hi, thanks for getting back to me. It seems that the newly added items are 
added to the end (bottom) of the QMenu instead of in-between the 'Add new 
item' and the 'Default Item'..

Also as mentioned in my first post, is it possible to create different 
QMenus for different tabs?
Eg. I create 'item01' for TabA and I created 2 new items - 'item01a' and 
'item01b' for TabB...  And based on which tabs that I perform a right-mouse 
click on, it will show the update menu

-- 
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/8b47ffc7-6ff5-4171-bf3d-c21e944219eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] New items are not added into QMenu

2019-01-14 Thread likage
Hi everyone, I have a tool which utilizes QTabWidget and the tabs are 
populated with a list of keys from within a dictionary.
Each of the QMenu are equipped with 3 default options, with one of the 
option called `Add new item` where when User uses that option, a prompt 
dialog will popped up and adds in the user-inputted naming as a new menu 
option into the current QMenu of the tab (where the right mouse click 
happens on)

The problems that I am encountering right now is:
1. 2 of the default items in the QMenu are getting added more than once, 
depending on the number of right mouse clicks made on the tool within the 
session
2. no new item are added into the QMenu - after I added in a new name for 
the prompt > when performing another right-click, the menu is still showing 
the default items plus 2 additional default items as mentioned in #1

Even so, wondering if this is a possible scenario for tabs + qmenu(s)?
I asked this because when doing a google search online, it seems that QMenu 
is generally used as a generic menu (eg. multiple buttons adopts the same 
menu etc)

Or should I be adopting to use a different widget for my case?

This is my code - https://pastebin.com/raw/4nakpnm8

-- 
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/b9cccfda-a8c5-4f00-bcd2-689ea4777640%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] clicked signals around a QLabel

2018-12-18 Thread likage
Hi Justin,

jumping back onto this thread... So, I managed to get a QPushButton, 
converted into a QGraphicsProxyWidget, and have it implemented into a 
horizontal QGraphicsLinearLayout together with the title.

But, currently I have an issue where this horizontal layout though is being 
added into a vertical QGraphicsLinearLayout, the button got 'pushed' out as 
I was using `insertStretch` on the title.
Wondering if you know of any ways in which I can either force a width 
limit, or set the button to a fixed postion?

-- 
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/4c748042-a398-44b1-97ec-845a3aea9d0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] clicked signals around a QLabel

2018-12-07 Thread likage
I am slightly confused now...
I apologize in advance, not an excuse but this is my first time dealing 
with QGraphicsXXX and have it integrated with the 'normal' widgets..

In the BaseWidget script - filled_round_rect(), it appears that the icon 
creation is made there and so I added this part in:

def filled_round_rect():
   ...
   ...
   painter.fillPath(rounded_rect, colour)

# I added the following line
   self.pixmapItem = QtGui.QGraphicsPixmapItem(self.type_icon())

if self.ICON:
   top_right = self.boundingRect().topRight()
   painter.drawPixmap(
   top_right.x() - 35,
   top_right.y() + 5,
   self.pixmapItem # I replace this with self.type_icon()
   )


and got the following error... I had thought that it will work, as the 
BaseWidget is within QGraphicsScene?

# TypeError: # 'PySide2.QtGui.QPainter.drawPixmap' called with wrong 
argument types:
#   PySide2.QtGui.QPainter.drawPixmap(float, float, 
PySide2.QtWidgets.QGraphicsPixmapItem)
# Supported signatures:
#   PySide2.QtGui.QPainter.drawPixmap(PySide2.QtCore.QPoint, 
PySide2.QtGui.QPixmap)
#   PySide2.QtGui.QPainter.drawPixmap(PySide2.QtCore.QPoint, 
PySide2.QtGui.QPixmap, PySide2.QtCore.QRect)
#   PySide2.QtGui.QPainter.drawPixmap(PySide2.QtCore.QPointF, 
PySide2.QtGui.QPixmap)
#   PySide2.QtGui.QPainter.drawPixmap(PySide2.QtCore.QPointF, 
PySide2.QtGui.QPixmap, PySide2.QtCore.QRectF)
#   PySide2.QtGui.QPainter.drawPixmap(PySide2.QtCore.QRect, 
PySide2.QtGui.QPixmap)
#   PySide2.QtGui.QPainter.drawPixmap(PySide2.QtCore.QRect, 
PySide2.QtGui.QPixmap, PySide2.QtCore.QRect)
#   PySide2.QtGui.QPainter.drawPixmap(PySide2.QtCore.QRectF, 
PySide2.QtGui.QPixmap, PySide2.QtCore.QRectF)
#   PySide2.QtGui.QPainter.drawPixmap(int, int, PySide2.QtGui.QPixmap)
#   PySide2.QtGui.QPainter.drawPixmap(int, int, PySide2.QtGui.QPixmap, int, 
int, int, int)
#   PySide2.QtGui.QPainter.drawPixmap(int, int, int, int, 
PySide2.QtGui.QPixmap)
#  PySide2.QtGui.QPainter.drawPixmap(int, int, int, int, 
PySide2.QtGui.QPixmap, int, int, int, int)


-- 
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/7d37d380-c1ae-447c-a47d-aacd19976bc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] clicked signals around a QLabel

2018-12-06 Thread likage
Hi Justin,

Thank you for getting back. I had thought using the above example may help 
me out but turns out not. :(
And so, I have decided to paste the code here in hopes of some guidance/ 
insights if any...

BaseWidget 
GraphicsWidget 

[image: example_widget.jpg]
The above 2 codes are used to created a widget (see attached) where I am 
trying to induce a 'clicked' connection towards that play icon.

And it appears that I am unable to use either QPushButton or a QLabel to 
replace it, by doing so, it will cause an error.



-- 
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/985acba2-be81-422b-bd51-b84e149f530f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] clicked signals around a QLabel

2018-12-06 Thread likage
Hi all,

I am trying to create a 'clicked' signal where it will only be triggered if 
User clicks anywhere within the icon.
In the following code:

class TestWin(QtGui.QWidget):
def __init__(self, parent=None):
super(TestWin, self).__init__(parent)
self.init_ui()

def init_ui(self):

lyt = QtGui.QVBoxLayout()
btn = QtGui.QPushButton('test button')

lbl = QtGui.QLabel()
icon_path = '/Desktop/people.png'
lbl.setPixmap(icon_path)   

lyt.addWidget(btn)
lyt.addWidget(lbl)

self.setLayout(lyt)

# Signals
btn.clicked.connect(self.btn_click)
lbl.mousePressEvent = self.lbl_click

def btn_click(self):
print 'I am clicking on the button...'

def lbl_click(self, event):
print 'I am clicking on the label...'


my_win = TestWin()
my_win.show()

As soon as I resize the window bigger, clicking on any blank space will 
still prints the message 'I am clicking on the label'

I also tried using event filtering where as follows:

class TestWin(QtGui.QWidget):
def __init__(self, parent=None):
super(TestWin, self).__init__(parent)
self.init_ui()

def init_ui(self):
...
...

# Signals
btn.clicked.connect(self.btn_click)
lbl.installEventFilter(self)

def btn_click(self):
...

def eventFilter(self, source, event):
if event.type() == QtCore.QEvent.MouseButtonPress:
print "The sender is:", source.text() # Returns me blank
return super(TestWin, self).eventFilter(source, event)

but the `source.text()` is returning me nothing.

Any insights are appreciated!


-- 
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/4913a8b5-eb22-4ffd-a3d2-268dc029ab8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] How to undock tool when using MayaQWidgetDockableMixin

2018-11-22 Thread likage
Hi all, many thanks for getting me back on this.

I am implementing some new functions in this tools that was previously written 
by someone, and I would not want to break any of its code if possible as this 
tool comprises of several scripts. 

Even so, is there a way that I can get by with using the mixin class? 

@Phil, wondering if you could kindly provide me a simple example for the hack 
that you mention of? 

-- 
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/13da5be3-da78-40ee-8be5-e3405c8659e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] How to undock tool when using MayaQWidgetDockableMixin

2018-11-22 Thread likage
Hi all,

I am using `MayaQWidgetDockableMixin` and for some reasons when using Maya 
2018, some of the signals are not working when the tool is closed.
While I have managed to find a way to resolve this which is by sending the 
tool to be docked upon first execution. By doing so, whether I closed it 
while it was docked or when I tear it off and closed the tool, the closed 
signals will then be called.

This is how I did it by using the `setDockableParameters` argument in the 
following manner:
self._window.setDockableParameters(
   dockable=True, x=x_pos, y=y_pos, allowedArea='left', area='left'
   )

My question would be - How can I tear off my tool when it is first docked?
I tried doing the following:
# Check if window is docked or not
if not self._window.isFloating():
  """
  Details for `raise_()`:
  Raises the widget to the top.  Will raise the parent widget if it is a 
QDockWidget.
  Overrides standard QWidget.raise_()
  """
self._window.raise_()

It does not seems to be tearing off the said tool at all. but instead the 
tool remains docked.


Appreciate in advance if anyone may have any ideas.

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


[Maya-Python] Undocking panel using Python

2018-11-21 Thread likage
If there is a panel that I have make it docked, what is the pythonic command 
that I can used to undock it?

I can find the said panel by using workspaceControl command to check if it does 
exists but I am unable to find the command that allows undocking.. 

-- 
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/1888b999-c7d2-4932-8450-bc5f5c460860%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Method to collates all errors for Conditions Checking

2018-10-23 Thread likage
Got it, thank you.

I did not read the post correctly and thought it was a case of just dict 
type instead of defaultdict.

-- 
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/445125c7-2e29-4fb8-af66-b601d7d208f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Method to collates all errors for Conditions Checking

2018-10-23 Thread likage
I have 2 questions, should have done more testing on my end..

1. I am trying to understand the use of `.append'. I know that it adds 
things to list, but when I was looking thru the documentation page 
- https://docs.python.org/2/library/collections.html, even in the example, 
it is mostly `dict_name['key name'].append(value)` but nowhere near the 
method you have used.. Am I looking at the wrong doc?

2. For Method #2 you have proposed, instead of using a defaultdict(list), I 
used a normal dictionary {} and I got the KeyError message.
Is this because when using normal dictionary, generally it should be 
`dict_name['key name'] = value`, and since we are not doing this way and 
hence the error?

Pardon the noob questions as I am trying to make sense of things

-- 
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/3a7ad9d5-118b-4617-9806-e5189992b15d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Method to collates all errors for Conditions Checking

2018-10-23 Thread likage
I was not aware that you could use `append = test_dict["Input 
Issue"].append` as you have demonstrated in Example #2.
Learnt something new today :D

-- 
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/0d3950d2-41a1-4618-91b3-643d9836b00a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Method to collates all errors for Conditions Checking

2018-10-23 Thread likage
Hi Justin, thanks for the reply.
I use msg{A,B,C} because if any one of the condition passed, the msg will 
get appended with the next in-line error.

Eg. If only frame range fails, my `test_dict` will return as follows:
{'Frame Range Issue': [None,
   'Value of Start/Min Frame is larger than the value 
of End/Max Frame.'],
 'Namespace Issue': [None, None],
 'Selections Issue': [None,
  'Value of Start/Min Frame is larger than the value of 
End/Max Frame.']}

And hence my usage of A,B,C to differentiate them as I can't reuse the same 
variable in which I am using defaultdict to differentiate them in this case.

appending string literals to the dictionary directly
>
Could you kindly elaborate more on this?

In general, I am trying to find out what is the best practice to go about 
doing them :)
 






-- 
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/c40099fc-dce8-4987-a367-77c3616bae50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Method to collates all errors for Conditions Checking

2018-10-23 Thread likage
Hi all, I am trying to see what is the best way that I can collate results 
into a QMessageBox.

This is my code:
test_dict = defaultdict(list)

# Old : msg = ""
msgA = msgB = msgC = None

# Inputs
if all((input_01, input_02)) == False:
msgA = "One or both of the Input fields is/ are empty!"
elif input_01 == input_02:
msgA = "Inputs used in both fields are the same!"
else:
msgA = validate_inputs(
(input_01, input_02)
)
test_dict["Input Issue"].append(msgA)

# Frame Ranges
start = int(start_frame)
end = int(end_frame)
if (start > end) or (end < start):
msgB = (
"Value of Start/Min Frame is larger than the value of "
"End/Max Frame."
)
elif start == end:
msgB = (
"Frame Values are the same"
)
test_dict["Frame Range Issue"].append(msgB)

# Selections
if user_selections:
msgC = validate_user_selections(
input_01,
user_selections
)
test_dict["Selections Issue"].append(msgC)

# Iterates and prints out all error at a go
if test_dict:
err_popup = QtGui.QMessageBox()
err_popup.setIcon(QtGui.QMessageBox.Critical)
err_popup.setWindowTitle("Errors found!")
err_popup.setText("Please rectify the following errors found.")

err_popup.setDetailedText(
"\n".join("{}\n * {}".format(k, '\n\t'.join(v)) for k, v in 
test_dict.items())
)
"""
# This will prints out in the following format if there are values 
found in each key

Input Issue
xxx
xxx
Frame Range Issue
xxx
Selections Issues
xxx

# If there are no values (no errors) in Frame Range, it will be 
ouputted as
Input Issue
xxx
xxx
Selections Issues
xxx
"""

err_popup.setStandardButtons(QtGui.QMessageBox.Ok)
err_popup.exec_()

"""
# Old - Only prints one error that it found in a top-down manner
if msg:
err_popup = QtGui.QMessageBox()
err_popup.setIcon(QtGui.QMessageBox.Critical)
err_popup.setWindowTitle("Errors found!")
err_popup.setText(msg)
err_popup.setStandardButtons(QtGui.QMessageBox.Ok)
err_popup.exec_()
"""


In my Gui, there are a bunch of inputs, mainly QLineEdits and I have 
factored in some conditions checking so that if something is incorrectly 
inputted, it will prompts up a window.
In my old code, as you have seen, it will only prints and prompts the 
QMessageBox, one condition at a time. And so, say if there are 2 errors - 
"Inputs" and "Selections", it will only shows "Inputs"

Whereas, I am now trying to implement and have it iterated all the 
conditions and shows all errors at one go.

As such, is there a better way that I can go about doing this? While I am 
no Python expert but the use of `msgA`. `msgB`, `msgC` does not looks very 
nice in this context...

Many thanks in advance for any replies :)

-- 
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/d4a69a96-087e-489c-b294-0a07d609c67f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Sub menus in shelf button

2018-10-10 Thread likage
Hello, I need some help with Mel in which I am trying to attach a sub-menu 
onto a shelf button.

If the shelf button is toggled by left-mouse click (also the default), a 
menu will be shown.
And if it is toggled with a right-mouse click, a different menu will be 
shown.

This is my code:
shelfButton
-enableCommandRepeat 1
-enable 1
-noDefaultPopup
-width 34
-height 34
-manage 1
-visible 1
-preventOverride 0
-align "center"
-label "Set Rig Options"
-labelOffset 0
-font "tinyBoldLabelFont"
-image "myTestIcon.png"
-backgroundColor 0.25 0.25 0.25
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-sourceType "python"
-command "import moduleA; menuA=moduleA.dropdown_from_selection(); 
moduleA.showMenu(menuA)";

// When right-mouse click is toggled.
popupMenu -b 3;
// I need to give the label a name, otherwise Maya will 
auto-provide a name such as 'menuitem1993' etc.
menuItem -l "MenuB Label" -sourceType "python" -command "import 
moduleB; menuB= moduleB.dropdown_from_selection(); 
moduleB.show_menu(menuB)";

FYI - both menus - menuA and menuB are created/ generated using QMenu.

However, in the case of right-mouse click, it has to go through the label, 
before the actual menu is shown. Is there anyway, in which I can bypass 
this label, or if there is a better way in which I can handle both left and 
right mouse click?

-- 
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/27a4524c-3b9a-4c58-8d7c-1d34718e2375%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Creating a QTreeView hierarchy from a given list of strings

2018-09-11 Thread likage
Hi Justin, thank you for getting back.

I added your code into my get_contents() function.
It seems that only an item is being stored? Tried doing a `print 
it.text()`, it is only returning me `camera` as the result instead of the 
full path..
As such, only that item is being appended with icon..

Wondering if I had done it wrong in any case?

-- 
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/a15b269f-180f-485a-88c3-8afd78fabbc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Creating a QTreeView hierarchy from a given list of strings

2018-09-10 Thread likage
Got it, many thanks for it, Justin!

I have another question, the following is the working code:
class MyModel(QtGui.QStandardItemModel):
def __init__(self, parent=None):
super(MyModel, self).__init__(parent)
self.get_contents()
self.assets_column = 0

def get_contents(self):
self.clear()
contents = [
'|Base|character|Mike|body',
'|Base|character|John',
'|Base|camera'
]

base_grp_icon = QtGui.QIcon('/user_data/base_grp_icon.png') # For 
|Base
char_grp_icon = .QIcon('/user_data/char_grp_icon.png') #  For 
|Base|character
char_icon = .QIcon('/user_data/char_icon.png') # For 
|Base|character|John
cam_icon = QtGui.QIcon('/user_data/cam_icon.png') # For |Base|camera

for content in contents:
parent = self.invisibleRootItem()


# content here will be `|Base|character|Mike|body` instead of 
it iterating each and every item in that path
# node_type = cmds.nodeType(content)
# if node_type == "baseMain":
# icon = base_grp_icon
# if node_type == "charGrp":
# icon = char_grp_icon
# if node_type == "charMain":
# icon = char_icon
# if node_type == "camMain":
# icon = cam_icon


for word in content.split("|")[1:]:
child_items = [parent.child(i) for i in 
range(parent.rowCount())]
for item in child_items:
if item.text() == word:
it = item
break
else:
it = QtGui.QStandardItem(word)
parent.setChild(parent.rowCount(), it)
parent = it


If I had wanted to append icons for each row, what is the best way that I 
can do?
Those paths that you have seen in the code, are custom node types and if I 
do `cmds.nodeType` as seen in that commented code portion, I will only be 
able to iterate it based on the items found within the `contents` instead 
of every item within...

-- 
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/28092299-d377-41ad-ac96-2e1c7f5544bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Creating a QTreeView hierarchy from a given list of strings

2018-09-07 Thread likage
Hi all, 

Given a list of strings, I am trying to populate the items in a tree view.
Here is my code:


class MyModel(QtGui.QStandardItemModel):
def __init__(self, parent=None):
super(MyModel, self).__init__(parent)
self.get_contents()

def get_contents(self):
self.clear()
contents = [
'|Base|character|Mike|body',
'|Base|character|John',
'|Base|camera'
]

for content in contents:
count = content.count('|')
for index in range(count):
index = index + 2
split_path = content.split('|')[0:index]
self.add_item(split_path)

def add_item(self,name):
item1 = QtGui.QStandardItem(name)
self.appendRow([item1])


However, the hierarchy that I have got in my Tree View are not collapsible 
(those with the small arrow icons by the side) and each row is appended 
with values and editable (if double click), in which I do not want.

An example of the output from my code:

|Base
|Base|character
|Base|character|Mike
|Base|character|Mike|body
|Base
|Base|character
|Base|character|John
|Base
|Base|camera


where there are a few repeatable rows...

And this is what I am expecting:

|-- Base
|--|-- character
|--|--|-- Mike
|--|--|--|-- body
|--|-- character
|--|--|-- John
|--|-- camera



Any insights?

-- 
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/c59b034f-9786-4215-a807-4753642bb2d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Creating a Tree hierarchy using PyQt

2018-09-07 Thread likage
Hi all,

I have a list of node's full dag path as follows:
|Base|character|Mike|body
|Base|character|John
|Base|camera


I am trying to populate them in a Tree View hierarchy using PyQt based on 
the above queried paths so that the tree view will be something as follow:
|-- Base
|--|-- character
|--|--|-- Mike
|--|--|--|-- body
|--|--|-- John
|--|-- camera

but instead in my UI, I got:
|Base
|Base|character
|Base|character|Mike
|Base|character|Mike|body
|Base
|Base|character
|Base|character|John
|Base
|Base|camera

where some of the hierarchy are created twice and they are populated as a 
value in each row instead of the 'small arrow' sign where you can expand 
them to view the next hierarchy.

This is my code:
class MyModel(QtGui.QStandardItemModel):
def __init__(self, parent=None):
super(MyModel, self).__init__(parent)
self.get_contents()

def get_contents(self):
self.clear()
#contents= 
predicate_helpers.get_expanded_objects_of_behaviour("rig")
contents = [
'|Base|character|Mike|body',
'|Base|character|John',
'|Base|camera'
]

for content in contents:
count = content.count('|')
for index in range(count):
index = index + 2
split_path = '|'.join(content.split('|')[0:index])
self.add_item(split_path)

def add_item(self,name):
item1 = QtGui.QStandardItem(name)
self.appendRow([item1])

Can anyone kindly provide me any insights?

-- 
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/36fbcfda-0e55-4901-af8a-baff7585ffbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] OptionVar is not saving/ loading correctly

2018-08-14 Thread likage
Hi Justin, many thanks for the reply, that seems to have do the trick.

Wondering if you could also share any insights into `# RuntimeError: Object 
'chk_box' not found. #` whenever I tried to relaunch/ rerun the code? 

-- 
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/e0ec520e-6b6c-4dae-9946-dfa83cd80b96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] OptionVar is not saving/ loading correctly

2018-08-14 Thread likage
I am using `optionVar` to store inputs made within the maya ui commands.
And these storing will only be effected if the tool gui is closed (the 
cross 'x' button within the window) and I am having issues with that...

I am having some issues with the loading and saving when using `optionVar`.

In my current code, I have set it to query the boolean value, where it read 
it as False, when the UI is loaded, it checked the check box which is a 
True value that is wrong...
Additionally, for the saving of inputs upon window closure, it does not 
seems to be able to 'save' the data at all. And when relaunching the code, 
I will get `# RuntimeError: Object 'chk_box' not found. # `

def testWin():
default_options = cmds.optionVar(
stringValue=(
("checkbox_state", False),
)
)

# This will returns me False
print cmds.optionVar(q="checkbox_state")


w = cmds.window()
col = cmds.columnLayout()
chk_state = bool(cmds.optionVar(q="checkbox_state"))
# But it will checked the checkbox though it should be False initially
chkBox = cmds.checkBox("chk_box", label="checkbox state Testing", 
value=bool(chk_state))

btn = cmds.button('print', c=print_state)

return w

def print_state(*args):
state = cmds.checkBox("chk_box", query=True, value=True) # Returns me 
the current state - True/ False
print state

def win_closure(*_):
#cmds.checkBox("chk_box", query=True, value=True) # Returns me nothing
cmds.optionVar(stringValue=("checkbox_state", cmds.checkBox("chk_box", 
q=True, value=True)))
print "window " + w + " was deleted"

win = testWin()
cmds.scriptJob(uiDeleted = (win, win_closure), runOnce=True)
cmds.showWindow(win)


-- 
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/4fc79cee-c18b-4c76-bb87-3dee2ee4f1a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Get the action command of the previous custom tool used

2018-08-13 Thread likage
Hi Marcus,

Many thanks for getting back! I will give it a try.
For my case and your solution, is making my tool the plugin the only way to 
go?

Additionally, regarding your code, where does "initializePlugin" and 
"uninitializePlugin" are called? Is it a default function that is handled 
by install()?

-- 
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/5be1afa0-c6c3-4a41-b3f2-10826e979480%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Get the action command of the previous custom tool used

2018-08-10 Thread likage
I have run a custom tool in a maya scene.
Say, if I am going to perform `z` (undo) via the keyboard, I would want to 
set the evaluation mode to be 'off' if the previous action is/ belongs to 
my custom tool.

I tried using `cmds.scriptJob(listJobs=True)`, while the entire contents 
are somewhat similar, before/ after using the undo key, with the exception 
of the last line, I am unable to script in a proper manner that will sets 
off the evaluation mode.

What any other ways can I proceed with this?

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


[Maya-Python] How to check if objects have more than 1 keyframe in the time slider

2018-08-07 Thread likage
What is the best way to check and see if an object (or multiple objects) 
have more than 1 animated keyframes as denoted by the red ticks in the time 
slider...

I tried using "cmds.keyframe(sl=False, q=True, tc=True)", however that 
returns me the amount of attributes that are keyframed etc.

My objective here will be, if an object is found to have 1 or no animated 
keyframes/ the red ticks, skip it. 

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


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

2018-07-26 Thread likage
Adding in a bit more information.

My objective initially is to have a shelfButton to have 2 different 
selection menus.
1. If User clicks on the shelf button, it will shows menuA...
2. If User clicks on the shelf button while pressing "ALT" key, it will 
shows menuB...

My initial code, where it keeps giving off the error of unable as mentioned 
in my first post...
shelfButton
-enableCommandRepeat 1
-enable 1
-noDefaultPopup
-width 34
-height 34
-manage 1
-visible 1;


// menuA options (only left mouse click on the shelf button)
popupMenu -button 1 -postMenuCommand "import lod_select; lod_menuA = 
lod_select.make_dropdownA(); lod_select.show_menu(lod_menuA)";


// menuB options (alt key + left mouse click on the shelf button)
popupMenu -button 1 -alt 1 -postMenuCommand "import lod_select; lod_menuB = 
lod_select.make_dropdownB(); lod_select.show_menu(lod_menuB)";




Seeing that this is not working, thought I made the shelfButton to have a 
default command that it will load menuA.
This seems to work to my cause, however it seems that while trying to 
access menuB options, I will need to select 2 time before the menuB options 
are presented to me.

If I click on the shelf button, it will shows a menu titled "menuitem1993", 
clicking on that, will it then be showing me the actual menu items of 
menuB,.. How can I bypass this "menuitem1993" creation?

shelfButton
-enableCommandRepeat 1
-enable 1
-noDefaultPopup
-width 34
-height 34
-manage 1
-visible 1
 -sourceType "python"
 -command "import lod_select; lod_menuA = lod_select.make_dropdownA(); 
lod_select.show_menu(lod_menuA)";


// menuB options (alt key + left mouse click on the shelf button)
popupMenu -button 1 -alt 1;
menuItem -sourceType "python" -command "import lod_select; lod_menuB = 
lod_select.make_dropdownB(); lod_select.show_menu(lod_menuB)";

-- 
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/a5c6f898-c0cd-4f07-a5b6-1835805aef2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2018-07-26 Thread likage
Doesn't seems to work... Getting the same error...

On Thursday, July 26, 2018 at 1:53:11 PM UTC-7, simon payne wrote:
>
> Yup, as Robert says. You can cast a python command though :
>
> -postMenuCommand = “python ‘myCommand()’”
>
> Simon
>
> Sent from my iPhone
>
> On 26 Jul 2018, at 21:22, Robert White > 
> wrote:
>
> I believe the problem you're running into here, is that the popupMenu 
> -postMenuCommand expects the command to be in mel, because you're 
> triggering it from mel.
>
>
> On Thursday, July 26, 2018 at 3:01:24 PM UTC-5, likage wrote:
>>
>> I was trying to convert a popupMenu command from Python to Mel..
>>
>> When using Python:
>> cmds.popupMenu( button=1, postMenuCommand="import lod_select; lod_menu = 
>> lod_select.make_dropdown(); lod_select.show_menu(lod_menu)")
>>
>>
>> However, when I tried converting the above command into MEL, I get an 
>> error:
>> # Keeps getting error output of "Invalid use of Maya object "lod_menu"
>> popupMenu -button 1 -postMenuCommand "import lod_select; lod_menu = 
>> lod_select.make_dropdown(); lod_select.show_menu(lod_menu)";
>>
>>
>> Any ideas?
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to python_inside_maya+unsubscr...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/python_inside_maya/6114e628-0030-4a87-813a-c9b0dc03125d%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/python_inside_maya/6114e628-0030-4a87-813a-c9b0dc03125d%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/342319d0-07ff-47f8-9acd-6f9bf1c45a02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2018-07-26 Thread likage
I see... Any possible way that I can make it to evaluate in Python?


On Thursday, July 26, 2018 at 1:22:18 PM UTC-7, Robert White wrote:
>
> I believe the problem you're running into here, is that the popupMenu 
> -postMenuCommand expects the command to be in mel, because you're 
> triggering it from mel.
>
>
> On Thursday, July 26, 2018 at 3:01:24 PM UTC-5, likage wrote:
>>
>> I was trying to convert a popupMenu command from Python to Mel..
>>
>> When using Python:
>> cmds.popupMenu( button=1, postMenuCommand="import lod_select; lod_menu = 
>> lod_select.make_dropdown(); lod_select.show_menu(lod_menu)")
>>
>>
>> However, when I tried converting the above command into MEL, I get an 
>> error:
>> # Keeps getting error output of "Invalid use of Maya object "lod_menu"
>> popupMenu -button 1 -postMenuCommand "import lod_select; lod_menu = 
>> lod_select.make_dropdown(); lod_select.show_menu(lod_menu)";
>>
>>
>> Any ideas?
>>
>

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


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

2018-07-26 Thread likage
I was trying to convert a popupMenu command from Python to Mel..

When using Python:
cmds.popupMenu( button=1, postMenuCommand="import lod_select; lod_menu = 
lod_select.make_dropdown(); lod_select.show_menu(lod_menu)")


However, when I tried converting the above command into MEL, I get an error:
# Keeps getting error output of "Invalid use of Maya object "lod_menu"
popupMenu -button 1 -postMenuCommand "import lod_select; lod_menu = 
lod_select.make_dropdown(); lod_select.show_menu(lod_menu)";


Any ideas?

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


[Maya-Python] Window UI is not displaying correctly if using checkbox to display/ hide additional ui(s)

2018-07-18 Thread likage
I have this UI using maya commands in which I am having problem with one of 
the checkbox.
Here is the code:
WINID = "mineUI"

def ui():
# Make sure that the UI isn"t already active
if cmds.window(WINID, exists=True):
cmds.deleteUI(WINID)

cmds.window(WINID, title="My window testing", width=365, height=135,
sizeable=False)

# Add a Layout
cmds.columnLayout(adjustableColumn=True)
cmds.rowColumnLayout(numberOfColumns=3, columnAttach=[1, "right", 0],
 columnWidth=[2, 250])

# Add text field for character to constraint
cmds.text(label="Constraint From: ")
constraint_from = cmds.textField("constraint_from")
cmds.button(label=" <<< ")

# Add text field for constraint_to
cmds.text(label="Constraint To: ")
constraint_to = cmds.textField("constraint_to")
cmds.button(label=" <<< ")

# Add checkbox for constraint offset
cmds.text(label="")
cmds.checkBox("offset", label="Maintain offset", value=False)
cmds.text(label="")

# Add checkbox for time
cmds.text(label="")
cmds.checkBox("time", label="Specify frame range", value=False,
  changeCommand=_frame_range)
cmds.text(label="")

# Add labels for frame range
cmds.text("start", label=" Start Frame ", visible=False, height=1, 
width=1)
cmds.textField("start_frame", visible=False, height=1, width=1)
cmds.text("space1", label="", visible=False, height=1, width=1)

# Add text field for frame range
cmds.text("end", label=" End Frame ", visible=False, height=1, width=1)
cmds.textField("end_frame", visible=False, height=1, width=1)
cmds.text("space2", label="", visible=False, height=1, width=1)

# Add button for select all the controls
cmds.text(label="")
cmds.button(label=" Select all controls to constraint ")
cmds.text(label="")

# Fill first column
cmds.text(label="")
cmds.button(label=" Constraint and Bake ")
cmds.text(label="")

# Display the window.
cmds.showWindow(WINID)


def _frame_range(*args):
switch = cmds.checkBox("time", value=True, query=True)
if switch:
# Labels
cmds.text("start", edit=True, visible=True, height=20, width=65)
cmds.text("end", edit=True, visible=True, height=20, width=65)

# Text Fields
cmds.textField("start_frame", edit=True, visible=True, height=20,
   width=250)
cmds.textField("end_frame", edit=True, visible=True, height=20,
   width=250)

# Fix Window size
# This line is not here in my initial code.
cmds.window(WINID, edit=True, resizeToFitChildren=True)

else:
# Labels
cmds.text("start", edit=True, visible=False, height=1, width=1)
cmds.text("end", edit=True, visible=False, height=1, width=1)

# Text Fields
cmds.textField("start_frame", edit=True, visible=False, height=1,
   width=1)
cmds.textField("end_frame", edit=True, visible=False, height=1, 
width=1)

# Fix Window size
cmds.window(WINID, edit=True, width=365)
cmds.window(WINID, edit=True, height=135)


ui()


If the "Specify frame range" is checked, it will displays the text field 
boxes etc correctly. However if you uncheck and checked it again, you will 
notice that the 2 buttons, namely "Select all controls to constraint" and 
"Constraint and Bake" are somewhat hidden.

But if you re-click on the Window Title, it seems to "expand" the window 
and displays it correctly.

My question here would be - Are there any other ways in which I can make 
the window to display correctly (checked, unchecked and checked the frame 
range checkbox)?

-- 
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/3f86b2f2-6f6c-4fbe-aec8-d4ad87c767ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Creating marking menus in Python

2018-07-05 Thread likage
I am trying to create a custom set of marking menu in a pythonic manner and 
have it booted up during setup.
Afaik, marking menu(s) are generally creating using MEL.

Wondering if anyone here has managed to do so? Could you kindly advise?

I am using Maya 2017.

-- 
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/4a4adbe6-f5dc-4e32-be28-093ec307e4ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Forcing Script Editor custom changes in Maya 2017

2018-05-28 Thread likage
Hi Justin,

Thanks for getting back. Noted about Qt hacks, had thought it will be 
possible as I was using userSetup.py which seems to have resolve the issue 
I had on hand.
Am trying to see if the change I made, can be implemented/ enforce into 
Maya.

May not be ideal to apply a python event filter then. Thanks again :D


On Monday, May 28, 2018 at 12:45:58 PM UTC-7, Justin Israel wrote:
>
> This is probably the same issue one faces when trying to make custom Qt 
> hacks on a 3d viewport. They will work the first time, but new viewport 
> instances will not have the changes. One approach is to use an event filter 
> that checks for QEvent::ChildAdded. This even is fired when the parent 
> (main window?) has a new child widget. You can test if the widget is a 
> script editor and apply changes to it. 
> Be aware, as Marcus just recently pointed out in another thread, applying 
> a python event filter to a high traffic widget like the main window or 
> application can have performance impacts. So you may need to do it in C++ 
> if the parent is main window. 
>
> On Tue, May 29, 2018, 5:21 AM likage > 
> wrote:
>
>> Hi all,
>>
>> I am trying to "fix" the spacing/ fonts in the Script Editor of Maya 2017 
>> version as I am used to the format and style of Maya 2016 versions and 
>> before.
>> After some searching, I created the script for the change as well as 
>> created a userSetup.py that will load and executes the script that I did 
>> whenever a new Maya 2017 is boot up.
>>
>> Currently I have a problem in which, while it seems to run correctly for 
>> the first run, but as soon as I close the current script editor and re-open 
>> it, the space/ font etc, got reverted back to the default state. While I 
>> can rectify the issue by creating a new shelf button with the code I did, 
>> are there any ways that I can force Maya to only load the custom settings 
>> that I have done?
>>
>> This is the script that I have done:
>> # script name : script_editor_fix.py
>>
>> from maya import OpenMayaUI as omui
>> from PySide2 import QtWidgets
>> from shiboken2 import wrapInstance
>>
>>
>> def get_maya_ui_element(ui_element):
>> omui.MQtUtil.mainWindow()
>> ptr = omui.MQtUtil.findControl(ui_element)
>> widget = wrapInstance(long(ptr), QtWidgets.QWidget)
>> return widget
>>
>>
>> def change_ui_font(ui_element):
>> widget = get_maya_ui_element(ui_element)
>>
>> widget.setStyleSheet(
>> "font-family: {0}; font-weight: {1}; font-style: {2}; font-size: 
>> {3}px;".format(
>> "FreeMono",
>> "normal",
>> "normal",
>> 12
>> )
>> )
>>
>>
>> def main():
>> change_ui_font(ui_element="scriptEditorPanel1Window")
>>
>> This is the userSetup.py that I have done:
>> # script name : userSetup.py
>> from maya import cmds
>> import script_editor_fix
>>
>> cmds.evalDeferred("script_editor_fix.main()", lowestPriority=True)
>>
>>
>> -- 
>> 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/f359fe16-c462-4f70-ae31-ef8e2ecd984f%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/f359fe16-c462-4f70-ae31-ef8e2ecd984f%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/ebd4715a-8913-4b1c-b1f0-6c3910f5cd88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Forcing Script Editor custom changes in Maya 2017

2018-05-28 Thread likage
Hi all,

I am trying to "fix" the spacing/ fonts in the Script Editor of Maya 2017 
version as I am used to the format and style of Maya 2016 versions and 
before.
After some searching, I created the script for the change as well as 
created a userSetup.py that will load and executes the script that I did 
whenever a new Maya 2017 is boot up.

Currently I have a problem in which, while it seems to run correctly for 
the first run, but as soon as I close the current script editor and re-open 
it, the space/ font etc, got reverted back to the default state. While I 
can rectify the issue by creating a new shelf button with the code I did, 
are there any ways that I can force Maya to only load the custom settings 
that I have done?

This is the script that I have done:
# script name : script_editor_fix.py

from maya import OpenMayaUI as omui
from PySide2 import QtWidgets
from shiboken2 import wrapInstance


def get_maya_ui_element(ui_element):
omui.MQtUtil.mainWindow()
ptr = omui.MQtUtil.findControl(ui_element)
widget = wrapInstance(long(ptr), QtWidgets.QWidget)
return widget


def change_ui_font(ui_element):
widget = get_maya_ui_element(ui_element)

widget.setStyleSheet(
"font-family: {0}; font-weight: {1}; font-style: {2}; font-size: 
{3}px;".format(
"FreeMono",
"normal",
"normal",
12
)
)


def main():
change_ui_font(ui_element="scriptEditorPanel1Window")

This is the userSetup.py that I have done:
# script name : userSetup.py
from maya import cmds
import script_editor_fix

cmds.evalDeferred("script_editor_fix.main()", lowestPriority=True)


-- 
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/f359fe16-c462-4f70-ae31-ef8e2ecd984f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Get objects that are not uv

2017-07-20 Thread likage
Hi all,

I have this model in which some of the geometries within are not uv-ed.
As in, you select the geometry >> open up uv editor >> it is blank.

And so it is causing some problems with a script I am doing. Are there any 
ways in which I can use python to check for such geos with the blank uvs?

FYI, there is only 1 uv set for this model.

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/3135a1ec-65b3-4c35-8464-950af78b958a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Check and grab the latest value of a certain condition using dictionary

2017-07-10 Thread likage
I have created a dictionary in which it stores the information as follows:
dict = {'model_v001': 'In Progress',
 'model_v002': 'In Use',
 'model_v003': 'In Progress',
 'model_v004': 'In Progress',
 'model_v005': 'Approved',
 'model_v006': 'Pending'}



I am trying to achieve that, from the contents in the dictionary, in which 
the conditions are as follows:

   - Grab latest 'Approved' versions if there are any
   - Grab latest 'In Porgress' versions if there are any and if no 
   'Approved' versions are found
   - Grab latest 'Pending' versions if there are any, only if no 'Approved' 
   and 'In Progress' versions are found
   

Using the above example, I should be grabbing `model_v005` as it is the 
latest Approved.
So if the `model_v004`and `model_v005` status are reversed, `model_v004` 
will be grabbed instead.

keys = dict.keys()
valid_status = ['Element Approved', 'Element in Pipe']
if dict[keys[0]] in valid_status:
#Use this version
print 'Using this version'
else:
#iterate and check the 'previous' version?

What is the best way to go around this?

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


[Maya-Python] Image is not appearing in menuItem

2017-06-21 Thread likage
I have created a shelf icon using `shelfbutton` and I am adding a drop down 
menu which is created using the `popupMenu` and `menuItem`.
Good news is that, everything is working as I expected it to be.

This is not a biggie but when I tried to incorporate the command `image 
(-i)` flag for menuItem, it seems that the image is not loading at all.

shelfButton
-enableCommandRepeat 0
-enable 1
-width 34
-height 34
-label "Quick Access"
-image "quick_access.png"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-sourceType "python"
popupMenu -b 1;
menuItem -stp "python" -i "/user_data/model_picker.png" -l "Model 
Picker" -c "import model_picker; model_picker.main()";

For the image path, I did try using `"model_picker.png"` and making sure 
that the image is in the icons folders. Also no errors are thrown when I 
run it, and so I am not sure if my images does gets called, or perhaps 
there are something that I have did wrongly.

Any ideas?

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


[Maya-Python] Creating a curve-based wireframe

2017-05-31 Thread likage
I am trying to 'extract and convert' all the edges of the polygon (based on 
selection) into curves, then parent the curves as one. This is like a 
curve-based wireframe model.

While Maya has a functionality that allows all edges to be converted into 
curves, but the functionality - "Polygon Edges to Curves", it works but not 
very ideal in my case as I would want all the created curves to be combined 
into one.

import maya.cmds as cmds
import pymel.core as pm

edges = cmds.filterExpand(cmds.polyListComponentConversion(te=1),sm=32,ex=1)
cur_list = []
for edge in edges:
vtx = cmds.ls(cmds.polyListComponentConversion(edge,fe=1,tv=1),fl=1)
p1 = cmds.pointPosition(vtx[0])
p2 = cmds.pointPosition(vtx[1])
created_curve = cmds.curve(d=1,p=(p1,p2))
cur_list.append(created_curve)

# Select all the newly created curves
for cur in cur_list:
cmds.select(cur, add=True)

# Get list of objects
shape_list = pm.ls(pm.listRelatives(c=True))
grp_list = pm.ls(pm.group(em=True, n='curve#'))
list_all = []
for obj in grp_list:
list_all.extend(shape_list)
list_all.extend(grp_list)

# Parent (shape) objects to one Curve
pm.select(list_all)
pm.parent(r=True, s=True)


While this code of mine does work, but if I tried to use it on a higher 
subdivision polygon, for example, create a normal pSphere and sets both its 
"Subdivisions Axis" and "Subdivisions Height" to 100, and execute the code 
I wrote.
What happens here is that:

   - Maya seems to be hanging
   - Took a very long while to be process (seems to be more than 1 hour 
   plus before that current maya session of mine crashes.)
   
What can be done to minimize this long processing time? I am assuming that 
part of this 'long' time is due to the commands that I am using it to 
derive the vertex and creating them?

-- 
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/71af008c-fbce-46a8-b150-887888e300bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Catch the end of viewport 2.0 processing process

2017-05-31 Thread likage

>
> The cmds equivalent of MEventMessage is 
>
> cmds.scriptJob(event='idle', fn)
>
> I haven't used it for a very long time but I think the fn might need to be 
> a string representing MEL code.
>
> Or you might be better off with evalDeferred:
>
> cmds.evalDeferrred('print "a"')
> cmds.evalDeferrred('print "b"', lowPriority=True)
> cmds.evalDeferrred('print "c"', lowestPriority=True)
>
>
> None of this is exactly what you want, I know. I looked into it briefly 
> last year and didn't see any simple way to do it.
>

Hi Michael, thanks for the information, appreciate it. No worries about 
that, I was simply looking to see if there is a way to 'catch' the end of 
the vp2 processing...
It also does seems a bit hard in my case if I am dealing with different 
poly counts, just realizing that when I was opening a very heavy scene file 
as the 'viewpoint 2.0 processing' message pops up every now and then as I 
tried to unhide new geometries or doing some viewport navigation. 

-- 
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/abc4b263-e3b3-4df3-92fe-26d814218ec5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Catch the end of viewport 2.0 processing process

2017-05-30 Thread likage
I should have posted my code, here goes:

def set_vp2_settings():
cmds.setAttr('hardwareRenderingGlobals.vertexAnimationCache', 2)
cmds.setAttr('hardwareRenderingGlobals.hwInstancing', 1)
cmds.setAttr('hardwareRenderingGlobals.threadDGEvaluation', 1)
cmds.setAttr('hardwareRenderingGlobals.maxHardwareLights', 1)
cmds.setAttr('hardwareRenderingGlobals.transparencyAlgorithm', 0)

def main():
# Apply viewport 2.0 settings
print 'Apply custim settings for Viewport 2.0'
set_vp2_settings()
# Disabling viewport
#mel.eval("paneLayout -e -manage false $gMainPane")


# Switch to Viewport 2.0
print 'Switching to use Viewport 2.0'
mel.eval('ActivateViewport20;')

# Enable back viewport
#mel.eval("paneLayout -e -manage true $gMainPane")
print 'Done!'


main()



When I am running the code, it will print out all the print statements 
including the last one - Done!, but as soon as the last print statement is 
done, it is then I will be seeing 'Viewport2.0 Processing' on the bottom 
lefthand corner, which may take about a min to 2.
I tried disabling and re-enabling the viewport, still, viewport 2.0 only 
seems to get processed after the whole code execution.

In my main() function, I am expecting the `mel.eval('ActivateViewport20;')` 
to finish the processing before it prints the `Done!` statement, and hence 
I am asking about 'catching' ot..

-- 
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/5485a235-6fd0-43e3-90c0-ee6919b4f38c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Catch the end of viewport 2.0 processing process

2017-05-30 Thread likage
I am trying to get the end if processing time taken when switching to 
viewport2.0.

In my code, I start off by doing custom settings in renderer then switching to 
viewport 2.0

However when switch, it took a while for Maya to process, like 3 to 5 seconds 
before I see the message 'viewport 2.0 is processing'..

Is there any way that I can catch once the processing is done before I execute 
my next function?

-- 
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/6250edca-c63b-457f-b92a-8c17bab06e48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] ImportError when running terminal command in maya standalone

2017-05-15 Thread likage
Hi everyone, I am trying to run a terminal command while using 
maya.standalone and run into some problems.
There is this terminal command in which if I run `someCommand my_file.txt`, 
it works correctly, as I expecting it to be.

When I tried to incorporate it into my script:
os.system('someCommand /user_data/some_file.txt')


I was prompted with the following error when I tried to execute it with 
Mayapy command:

Traceback (most recent call last):
  File "/server/scripts/someCommand", line 6, in 
import os
ImportError: No module named os


Tried using `subprocess` but same error persists. How can I rectify this 
and why is it that `os` module error occurs?
In my python file, `os` is working for sure..



-- 
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/97fa1bf8-0ada-4f1f-a6c2-f1e72b8940c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Use AbcExport plugin externally to convert obj to abc

2017-05-15 Thread likage
I keep getting the following error:

ERROR, imageIsFile, can't read `/user_data/custom_scripts/'. Is a directory

File read in  0.024 seconds.
Error: Failed to open IFF file for reading : 
/user_data/.tmp//maya108600x7fff97d2ea00.iff

Despite loading in the obj plugin, the error ensues.. Not sure why it keeps 
calling for this .iff file

This is my code:
import os
import maya.standalone
from sys import argv
maya.standalone.initialize()
 
import maya.cmds as cmds
 
def main():   
obj_file_path = argv[1]
print obj_file_path

# Check for path validity
check_open_path = os.path.isfile(obj_file_path)
if not check_open_path:
raise IOError('Input file path does not exists. Please check or 
make sure that full path is used.')
return

cmds.loadPlugin('objExport.so')
cmds.file(obj_file_path, i=True, type='OBJ')

if __name__ == "__main__":
main()


-- 
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/9601acca-ea68-4f65-b715-1339ed489f9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Use AbcExport plugin externally to convert obj to abc

2017-05-15 Thread likage
Hi everyone,

sorry for the delay in reply.

Yes I am pretty much unaware of mayapy, first time hearing this. Trying to 
search for some tutorials online that may guide me through this.
But if you have any links, please do share it with me :)

Currently I am not sure what is the ideal way to proceed this, as mentioned 
in my first post - all I have been doing is import obj into scene and 
export it as abc.
I am trying to achieve this first before implementing any other factors 
into it. Pretty noob in this aspect.

@Nicholas: I do not even know how to access the python side for alembic!


-- 
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/84926bf3-69d9-4913-9109-7ccb0341e124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Use AbcExport plugin externally to convert obj to abc

2017-05-05 Thread likage
Hi all, I am trying to convert objects (.obj) into alembics (.abc)

While I am able to perform this by importing my objs into a maya scene and 
export it as alembic, is there a way in which I can run it externally out 
of Maya session? 
Such that I can try running it as a command line or somewhat, by making use 
of the AbcExport plugin within Maya?

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


[Maya-Python] Re: Finding and selecting fliiped (red-colored) UVs

2017-05-05 Thread likage
Alright, I have misunderstand. 

Yes I think I will stick to the cmds command as it is faster and easier to 
maintain like you have mentioned.
Appreciate for the information on the API and PyMel etc. :)

Cheers!

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


[Maya-Python] Re: Finding and selecting fliiped (red-colored) UVs

2017-05-02 Thread likage

>
> Using maya.cmds you'd probably want to execute the MEL commands that do 
> the same actions Andres detailed. I'm not sure how to do that but if you 
> turn on "Echo All Commands" in the Script Editor and do some digging in the 
> MEL scripts that ship with Maya, you might be able to figure it out.
>
> Using PyMel, or the C++ or Python API, I think you could do it faster than 
> the script you linked by using the isRightHandedTangent function of 
> PyMel's Mesh or the API's MFnMesh class. (You can pass UV ids to that 
> function.) You'd still have to iterate through all UV IDs but you let Maya 
> do the vector math for you. You would then probably select the left-handed 
> UVs for the user to flip. Flipping them in script would be more complex 
> because you'd have to account for cases where a UV shell folds on itself.
>

Hi Michael, yes I am able to use the solution given by Andres and convert 
them using *maya.cmds.polyMultiLayoutUV.*
By the way, how are you able to tell that the script I have linked is using 
the *isRightHandedTangent* function (I have hardly used PyMel, mostly I am 
using maya.cmds)?

I have also managed to find another script that uses both PyMel and Maya 
Api altogether. Tried running it (though there are some errors), I think it 
run similarly to the script I have linked previously but it is still slow, 
nowhere fast as the solution provided by Andres.

< Script02  - Uses 
PyMel + Maya Api >

To my knowledge, I had thought that using of maya api will makes the 
process faster? Wondering if the cause of slowness could be due to PyMel - 
read that PyMel is more in ease of use over execution speed






-- 
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/2d350fe8-8347-46c6-89bf-78e3b9a9eaa7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Finding and selecting fliiped (red-colored) UVs

2017-05-01 Thread likage
Hi Andres, thanks for getting back.

The settings you have given works like a charm! Was not aware of such a 
setting as I only knows of selecting the faces and flipping them manually.
Though I have yet to check all the UVs in general if they are working 
correctly/ have changed anything in its initial setup.

I have managed to found a code from cgsociety 
, though it is using 
pymel, its execution speed seems to be wa longer as compared to the 
solution derived by Andres as it seems to be iterating every single uv it 
can find... 

Even so, I am still curious if there is a pythonic way (using maya.cmds) to 
do it?

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


[Maya-Python] Finding and selecting fliiped (red-colored) UVs

2017-05-01 Thread likage
Hi all, I have several models in my scene that contains flipped uvs (those 
colored in red when opening in UV editor) and each mesh contains a mixture 
of red and blue ones (blue are the correct uvs)

While I can manually select each/ all of these red colored uvs and flip 
them inidvually per mesh, it is a hassle as I will need to select only the 
red-color ones since I will need to go through each of them.

I tried to write a python script but unable to find any commands in the 
maya cmds documentation that will allow me to find and select these red 
uvs/faces.

Wondering if anyone know of any similar commands that I can use?

-- 
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/3024e95f-d331-44af-bd5e-085ffa4af9bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: Older cmiVFX training videos released free (3 tutorials)

2017-03-23 Thread likage
Nice, thanks for sharing your lessons and knowledge, Justin!

I'm sure students/ newcomers alike to coding will appreciate it! :)

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


[Maya-Python] Create item on mesh via mouse cursor position

2017-03-15 Thread likage
I am trying to do something as follows:

   - Within the viewport
   - Mouse cursor hover onto a pPlane for example (at any position)
   - Prior to the mouse cursor/ position, as user clicks on their mouse, it 
   will create a locator right at the mouse cursor position that user has 
   specified

Optional : But I plan to include using modifier keys too, but for now I am 
trying to get the first 3 points working

To be honest, I have got no idea where to start. Could someone kindly 
enlighten me on this?
I tried searching online where some uses Maya API or cmds.draggerContext 
(Tried using the example in the docs but it is failing on me), and as I do 
not quite understand API, I was hoping if anyone can kindly guide me on 
what I should try proceeding

-- 
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/757cae4c-4319-4a51-9a61-259a1b8c1a66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2017-03-14 Thread likage
Interesting... Thanks for the information, guys!
Never thought that with a simple example that I have used, it can failed 
almost immediately.

>From the flags, though it mentions of `script` I had assumed that it will 
worked with a normal method too..

-- 
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/1789febb-1aed-4918-b25d-141fd48b0656%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2017-03-14 Thread likage

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

Okay, so it works. And my question is why? 

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


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

2017-03-14 Thread likage
While it works for the example, I tried applying the same concept into my 
actual code, I am getting the errors..
self.btn_add = cmds.symbolButton( width=60, height=20, annotation='Add 
object(s)', image='add.xpm', command=self.add_btn_callback("item_list") )

def add_btn_callback(self, "list"):
# Do the exec when add button is clicked

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


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

2017-03-13 Thread likage
I am trying out using maya symbolcheckbox and I run into a few issue. In my 
actual code, I have a 'add', 'remove' and 'clear' button and so if any of 
these 3 buttons are clicked onto, it will called its own functions. In my 
code, it was written something as follow:

self.btn_add = cmds.symbolButton( width=60, height=20, annotation='Add 
object(s)', image='add.xpm', command=lambda * args:self.btnCallback("add", 
"item_list") )

def uiListCallback(self, *args):
mode = args[0]

text_list = args[1]
if mode == "add":
# do this
elif mode == "remove"
# do that


But when I tried to create a function for each action, I keep getting 
errors.
This is simple example, but it illustrates the problem I had.

However, if I execute the following code:
def greet():
print 'hello'

def main():
cmds.window()
cmds.columnLayout()
cmds.symbolCheckBox(image='circle.png', changeCommand=greet())
cmds.showWindow()
main()

I will get `# Error: TypeError: file  line 9: Invalid 
arguments for flag 'changeCommand'.  Expected string or function, got 
NoneType # `

But if I did it in another way:
def greet():
print 'hello'

def main():
cmds.window()
cmds.columnLayout()
# () was added into greet under the command flag
cmds.symbolCheckBox(image='circle.png', command=greet())
cmds.showWindow()
main()

While I get a popup, but as soon as I click on it, I will get this error - 
`# Error: greet() takes no arguments (1 given) # `

Where am I doing it wrong?

-- 
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/eeb056cb-04b7-4989-82eb-88fe0b5b62f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: conforming lines to 80 characters limits

2017-02-27 Thread likage
I have another question - what about the function line?

Eg.
Class Something(object):
def __init__(self, rotate=((0, 0), (0, 0), (0, 0)), scale=((1, 1), (1, 1), (
1, 1)), u_jitter=(0,0), v_jitter=(0,0)):

The character limit stops at the last open bracket of the scale parameter : 
`..., scale=((1, 1), (1, 1), (` 
Should/ Can it be break into two?

-- 
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/0af2c859-544f-483d-8eab-394a5ba3466d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: conforming lines to 80 characters limits

2017-02-26 Thread likage
Noted, thank you all!

-- 
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/aa759802-0d24-4679-9c91-bf4c521ea531%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] conforming lines to 80 characters limits

2017-02-26 Thread likage
Hi all, 

I am trying to conform my code to fit into length width of 80 characters, 
pep8 style


Suppose if I have a code like this:
class something():
def __init__(self):
...
self.uiSetupNormalSmooth = cmds.radioButton(label='Geometry normal',
align='right',
onCommand=lambda*args:
self.setupCallback("uiSetupNormalCol", True))


My question here is, for the onCommand line, the limit of 80 characters 
(from left to right) stops ar .`..self.s`, my question here would be how or 
what is the best way to conform this line?

Will it be like this:
self.uiSetupNormalSmooth = cmds.radioButton(label='Geometry normal',
align='right',
onCommand=(lambda*args:
   self.
setupCallback("uiSetupNormalCol", True)))

-- 
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/bf0a3f06-3327-4b67-a948-a637b487fff7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Check if object exists in world before using parent command

2017-02-23 Thread likage
This is my outliner, eg. '|hie1|cube1' and 'cube2'

If I select cube1 and did:
cmds.parent("|hie1|cube1", world=True)


This will unparent my cube1 out of hie1 and into 'world' level? Sorry, 
can't think of a better term.

But if I did the same thing to cube2:
cmds.parent("cube2", world=True)

I will get an error:
# Warning: Object, 'cube2', skipped. It is already a child of the parent, 
'world'. # 
# Error: Maya command error
# Traceback (most recent call last):
#   File "", line 2, in 
# RuntimeError: Maya command error # 


Even as I used `try...except...` it does not stops my tool function but you 
can explicitly see in the status line that there is a quick flash of red 
color before it disappears.

Is there any command that enables me to check if the object is already in 
'world' or better ways to get around this problem?

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


Re: [Maya-Python] Count, filter out duplicates in keys while doing the same for values

2017-02-23 Thread likage
Hi Justin,

Sorry for the late reply.

It works like a charm, thanks!


On Thursday, February 16, 2017 at 8:04:50 PM UTC-8, Justin Israel wrote:
>
> Untested, but that looks to be almost exactly the same logic as what I 
> gave you for tracking the counts for each user/product. But instead of 
> tracking a counter you would just accumlate the size:
>
> user_ver_count = defaultdict(lambda: defaultdict(int))
> user_ver_size = defaultdict(lambda: defaultdict(int))
>
> ...for vers_name, artist_alias in gen_dict.iteritems():
> ...
> user_ver_count[artist_alias[0]][strip_version_name] += 1
> user_ver_size[artist_alias[0]][strip_version_name] += artist_alias[1]
>
> ​
>
> Also, this line is impossible to read:
>
> users = ', '.join('{0} [{1} ({2}]'.format(alias, 
> convert_size_query(sum(int(i) for i in asset_size_dict.get(alias))), 
> user_ver_count[alias][version_name]) for alias in 
> asset_user_dict[version_name])
>
> ​
>
> It doesn't hurt to break up your logic into individual lines, to help others 
> that can and will end up reading your code. And also to set obscure members 
> of a list into a nicely named local variable  :-)
>
> Justin
>
> ​
>
> On Fri, Feb 17, 2017 at 1:50 PM likage <dissid...@gmail.com > 
> wrote:
>
>> This time round, I tried using tuple like you have mentioned. see,s to be 
>> working well but I got an issue, where if there is an existing user, it 
>> will collate and summed up the overall data size under 1 user...
>>
>> In the pastebin, I am expecting item_C to be `kilo [3 (1]` but it seems 
>> to add up the values derived from item_B in kilo's case
>>
>> http://pastebin.com/raw/qBxxaszK
>>
>> -- 
>> 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/705d5dd5-8be5-4449-8149-2f5a9af7b77e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/705d5dd5-8be5-4449-8149-2f5a9af7b77e%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/ccd99399-493e-4616-8c2f-a5ba656e172b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Count, filter out duplicates in keys while doing the same for values

2017-02-16 Thread likage
This time round, I tried using tuple like you have mentioned. see,s to be 
working well but I got an issue, where if there is an existing user, it 
will collate and summed up the overall data size under 1 user...

In the pastebin, I am expecting item_C to be `kilo [3 (1]` but it seems to 
add up the values derived from item_B in kilo's case

http://pastebin.com/raw/qBxxaszK

-- 
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/705d5dd5-8be5-4449-8149-2f5a9af7b77e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Count, filter out duplicates in keys while doing the same for values

2017-02-14 Thread likage
Thank you Justin for your help. 
My bad, it does seems I have omitted out a portion of where/how gen_dict 
comes about but in any case, it comes from an iterator. And since I am only 
getting 2 parameters - namely the object name and the user name affiliated 
with it, I made it into a dictionary, as this is the best solution I can 
come up with.

Even so, if this time round I had wanted to add in an additional parameter, 
say the size of each item such that it is (this is not a dict yet):
(1 MiB) "item_C_v001" : "jack"
(5 MiB) "item_C_v002" : "kris"
(1 MiB) "item_A_v003" : "john",
(1 MiB) "item_B_v006" : "peter",
(2 MiB) "item_A_v005" : "john",
(1 MiB) "item_A_v004" : "dave"

While I am able to make my output as follows:
Item Name | No. of Vers.  | User
item_A| 3 | dave(1, 1MiB), john(2, 3MiB)
item_B| 1 | peter(1, 1MiB)
item_C| 2 | jack(1, 1MiB), kris(1, 5MiB)

My code is as follows: http://pastebin.com/G8WVzE3e

Wondering if you could take a look and see if my method is a good way of 
doing so? 
I am having some difficulties of seeing how I can get the dictionaries I 
have created to 'link' / make use of each other, because say if I am trying 
to sort it by data size in descending order, it is not working even if I 
try to sort it by the values..
Pardon me if my code is not fanciful


-- 
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/557625a8-3f4f-412f-aced-e16ce966d37d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Count, filter out duplicates in keys while doing the same for values

2017-02-14 Thread likage
I have this dictionary.

gen_dict = {
 "item_C_v001" : "jack",
 "item_C_v002" : "kris",
 "item_A_v003" : "john",
 "item_B_v006" : "peter",
 "item_A_v005" : "john",
 "item_A_v004" : "dave"
}

while I am able to filter out the version makings and the users to:

Item Name | No. of Vers.  | User
item_A| 3 | dave, john
item_B| 1 | peter
item_C| 2 | jack, kris


Currently I am trying to input how many versions each user own so that it 
will be something like this:

Item Name | No. of Vers.  | User
item_A| 3 | dave(1), john(2)
item_B| 1 | peter(1)
item_C| 2 | jack(1), kris(1)


but I am having problems with it.
This is the code I have used for filtering..

from collections import defaultdict

gen_dict = {
 "item_C_v001" : "jack",
 "item_C_v002" : "kris",
 "item_A_v003" : "john",
 "item_B_v006" : "peter",
 "item_A_v005" : "john",
 "item_A_v004" : "dave"}

user_dict = defaultdict(set)
count_dict = {}
for item_name, user in gen_dict.iteritems():
user_dict[item_name[:-3]].add(user) # Sure you want -3 not -5?
count_dict[item_name[:-3]] = count_dict.get(item_name[:-3], 0) + 1
for name, num in sorted(count_dict.iteritems()):
print "Version Name : {0}\nNo. of Versions : {1}\nUsers : {2}".format(
   name, num, ', '.join(item for item in user_dict[name]))


what can I do to input that and any other ways to refine my code?

-- 
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/401522d4-a96a-4063-9755-863a93de490c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Animation keyframe exporting

2016-12-20 Thread likage
Thanks, it works!

I have a few questions..

1. `all_data[sel] = {}`, why can't I wrote it as `all_data[sel] = None`? I 
tried and I got an error that states ''NoneType' object does not support 
item assignment'
I asked this because since I have no values to append in the first place, 
wouldn't using None be more practical? Or, do correct me if I am wrong, 
since we are dealing with dictionaries, initializing an empty dict is then 
the correct way?

2. Do I still need to have `attr_data = {}` still needs to be placed under 
the `for time ... end_frame +1))` line? Would that not cause it to be loop 
continuously? P.S, Again, I tried placing it outside of the `for` statement 
as initially seen in my post, and it works too..

3. This is slightly unrelated but what can I do to refine writing logic 
process? There are times in which I seem to get it (but it is in a big 
chunk where it can be further refine), and times like this, where I am 
unable to..


-- 
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/ec6429bb-8cad-4509-8485-83974dfa3e87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   >