[Maya-Python] Best way to get notified when Maya scene is saved, or undo is called?

2014-02-05 Thread Michael Boon
I'm making a Qt GUI, and I need to update it when certain things in the Maya scene change. What's the best way to get a callback, Qt signal or some other notification when - the Maya file is saved under a new name - a new Maya scene is opened - undo or redo are executed ? I'm not very

Re: [Maya-Python] Best way to get notified when Maya scene is saved, or undo is called?

2014-02-06 Thread Michael Boon
Thanks all. I did as Cuchullain and Mark suggested and that works well. I had no idea that these API MMessage() functions even existed. -- You received this message because you are subscribed to the Google Groups Python Programming for Autodesk Maya group. To unsubscribe from this group

[Maya-Python] Pause whole script until after evalDeferred

2014-08-04 Thread Michael Boon
Hi all, I'm trying to load a DX11 shader. In the process I have to make sure VP2.0 is on and the renderer is set to DX11. editor = panel.getModelEditor() pm.evalDeferred(pm.runtime.ActivateViewport20()) renderer = pm.modelEditor(editor, q=True, rendererDeviceName=1)

Re: [Maya-Python] Pause whole script until after evalDeferred

2014-08-04 Thread Michael Boon
import QtGui QtGui.qApp.processEvents() On 4/08/2014 6:38 PM, Michael Boon boon...@gmail.com javascript: wrote: Hi all, I'm trying to load a DX11 shader. In the process I have to make sure VP2.0 is on and the renderer is set to DX11. editor = panel.getModelEditor

Re: [Maya-Python] Pause whole script until after evalDeferred

2014-08-04 Thread Michael Boon
Ha, I take that back too. I hadn't realized I needed to do pm.modelEditor(editor, e=True, rendererName=vp2Renderer) I guess the apparent need for evalDeferred was a red herring due to something changing when I ran my script multiple times yesterday. So, this works: editor =

[Maya-Python] Hypershade swatches in Qt GUI

2014-09-28 Thread Michael Boon
Hi, does anyone know if it is possible to have a Qt GUI pane that contains Maya material swatches? I'd be happy to have an instance of the Hypershade window (but Maya won't let me create a second one). If there was a way to get the same material swatches/icons the Hypershade uses, I'd be happy

[Maya-Python] Re: aligning one vector to another vector (python)

2014-11-02 Thread Michael Boon
I'm not really clear on what you're trying to do, but Pymel's Vector class has a method that might help: Vector.rotateBy(axis, angle) Alternatively, you can definitely use a matrix. Maybe look at TransformationMatrix.setToRotationAxis Or maybe you already figured it out :) On Tuesday, 21

[Maya-Python] Re: aligning one vector to another vector (python)

2014-11-02 Thread Michael Boon
Just occurred to me that you might simply want to make vector A point in the same direction as vector B. OK so sticking with Pymel. A and B are Pymel Vectors: A = B.normal() * A.length() On Monday, 3 November 2014 11:42:23 UTC+11, Michael Boon wrote: I'm not really clear on what you're

Re: [Maya-Python] Maya Window UI create Event?

2014-11-03 Thread Michael Boon
Arvid, did you have any luck with this? I'm trying to do the same thing and haven't figured out how yet. On Monday, 27 October 2014 10:47:49 UTC+11, Justin Israel wrote: I've never actually create and registered a custom event before. But I assume you would have to do the same thing,

Re: [Maya-Python] Adding controls to the Hypershade

2014-11-03 Thread Michael Boon
() if 'hyperShadePanel' in child.objectName(): doStuff() (I didn't see any events occurring on the QApplication.) On Monday, 3 November 2014 12:12:08 UTC+11, Justin Israel wrote: On Mon, Nov 3, 2014 at 1:29 PM, Michael Boon boon...@gmail.com javascript: wrote

Re: [Maya-Python] Adding controls to the Hypershade

2014-11-05 Thread Michael Boon
the eventFilter on the MayaMainWindow? On Tuesday, November 4, 2014 4:43:41 AM UTC+1, Michael Boon wrote: Thanks very much. I think I have the basic concept working now. To get a callback when the Hypershade is opened and closed, I've installed an eventFilter on the Maya main window

Re: [Maya-Python] Adding controls to the Hypershade

2014-11-11 Thread Michael Boon
Your code is much more concise but I don't think it will change the functionality. I think that both forms refer to the same static field of the class. For example: from PySide import QtCore event = QtCore.QEvent(QtCore.QEvent.ChildPolished) QtCore.QEvent.Type.ChildPolished ==

Re: [Maya-Python] Adding controls to the Hypershade

2014-11-11 Thread Michael Boon
Ugh, sorry, I assumed my response would get threaded. It was a reply to one of Justin's posts. Thanks for everyone's help with this. This group really is priceless. On Wednesday, 12 November 2014 10:15:59 UTC+11, Michael Boon wrote: Your code is much more concise but I don't think

[Maya-Python] Qt and Maya both want the main thread...what to do?

2015-03-23 Thread Michael Boon
Hi, I have a few PySide tools that are multi-threaded and in general they work well. However, I can't figure out how to correctly make Maya do complex operations while keeping my Qt GUI responsive. Both systems insist on only being run from the main thread. The Qt documentation

Re: [Maya-Python] Qt and Maya both want the main thread...what to do?

2015-03-23 Thread Michael Boon
for a cancel button to work during the time this is running in the main gui thread. But if your Maya operation never yields, then there isn't really anything you can do. On Tue, Mar 24, 2015 at 4:15 PM Michael Boon boon...@gmail.com javascript: wrote: Thanks for the response. I don't think

Re: [Maya-Python] Qt and Maya both want the main thread...what to do?

2015-03-23 Thread Michael Boon
gui thread, your best bet is to defer them until after your gui can finish responding to the user interaction. On Tue, Mar 24, 2015 at 1:57 PM Michael Boon boon...@gmail.com javascript: wrote: Hi, I have a few PySide tools that are multi-threaded and in general they work well. However, I

[Maya-Python] How to remove an MNodeMessage

2015-12-15 Thread Michael Boon
Hi all, If I add a callback to a node like this: import maya.api.OpenMaya as om mayaCallbackID = om.MNodeMessage.addAttributeChangedCallback(mObj, myFunc) and then later I do om.MMessage.removeCallback(mayaCallbackID) I get the error #RuntimeError: (kInvalidParameter): No element at given index

[Maya-Python] Re: fixing polygon normals

2015-12-17 Thread Michael Boon
What about the command polyNormal(normalMode=2) (or in the Maya GUI, Normals > Conform)? If your problem is just a few faces in each mesh, that would probably take care of it for you. If your problem is entire meshes being inside out and you're looking for an algorithm to find out which ones

[Maya-Python] Re: How to remove an MNodeMessage

2016-01-17 Thread Michael Boon
aya.OpenMaya and not > maya.api.OpenMaya since it's very limited doesn\'t have MNodeMessage etc) > and it works perfectly. > You should check it out with it. > > On Wednesday, December 16, 2015 at 4:25:26 AM UTC+1, Michael Boon wrote: >> >> Hi all, >> >> If I add a callba

[Maya-Python] Re: How to remove an MNodeMessage

2016-01-18 Thread Michael Boon
I just tried it using API 2.0 in Maya 2016 and it works fine. So I guess the answer is, in Maya 2015 and before, use the old API. In 2016, the new API works. On Monday, 18 January 2016 16:35:23 UTC+11, Michael Boon wrote: > > Thanks, that seems to work. > > (I'm not g

Re: [Maya-Python] Re: Retain polygon position but make planar

2016-02-09 Thread Michael Boon
od perfectly. If the edge > flow is how it should be by design; how do I change it without > triangulating ? I've tried deleting the faces and recreating the faces, the > non-planar reappear again, frustrating. > > On Thursday, January 28, 2016 at 10:33:46 PM UTC-5, Michael Boo

[Maya-Python] Re: (API) Get flag names from MArgList

2017-02-16 Thread Michael Boon
bruary 2017 10:45:35 UTC+11, Michael Boon wrote: > > > > Hi all > > Is there a list anywhere near as good as this one for asking C++ API > questions? > > I have a plugin that takes a bunch of flags and other arguments. From > inside the plugin, I want to be able

[Maya-Python] Re: Working with MDGContext causes maya to evaluate constantly

2017-02-16 Thread Michael Boon
I don't know where you're calling this code from, but I agree with your guess: calling plug.getValue causes your code to be run again. The reason that would cause an infinite loop when you call it twice and not when you call it once, is that Maya short-circuits if you call it twice with the

[Maya-Python] Re: api 2.0 copying vert points from one list to another

2017-02-16 Thread Michael Boon
I'm not really understanding what you want to do but I'll take a stab at it. You've got a list of vertex positions in your target mesh (target_mesh_verts) You've got a list of component indices from your first mesh (indices) I'm not clear on how you want to use them together. You will probably

[Maya-Python] Re: MPxLocatorNode local position and scale

2017-02-16 Thread Michael Boon
localPosition is a static function that returns an MObject. I guess that means it's an attribute, not a value, and you probably need to create an MPlug in order to access the value. You could check its apiTypeStr() to be sure. Hopefully that points you in the right direction. On Saturday, 11

[Maya-Python] (API) Get flag names from MArgList

2017-02-16 Thread Michael Boon
Hi all Is there a list anywhere near as good as this one for asking C++ API questions? I have a plugin that takes a bunch of flags and other arguments. From inside the plugin, I want to be able to print out which flags are in use. Since there are a lot of flags and they are in flux, I'd

[Maya-Python] Re: How to check if an object exists and then add that to a new variable

2017-02-19 Thread Michael Boon
Maya is adding a pipe '|' to the start of each object's name, to distinguish it from the previously grouped object with the same name. If you don't include that pipe, anything you do using that name later won't work. So any time you do something like nucleo,nucleoHistory =

[Maya-Python] Re: kInvalidParameter except catching

2017-03-01 Thread Michael Boon
FWIW I've had a similar experience. In the past I've caught a kInvalidParameter using RuntimeError, which isn't ideal but it was all I could find at the time. My usage was calling MFnMesh functions on a MFnMesh that I had initialised using an MObject instead of a dag path. Once I realised my

Re: [Maya-Python] MFnMesh.setVertexNormal Huge performance issue

2017-02-26 Thread Michael Boon
Slower than C++ for sure, but depending on your needs it might still be fine. I often set normals on meshes up to about 100k verts using Python. To create your MVector array (in Python API 2.0), something like this will do it in less than a millisecond: normals = [om.MVector(0,0,1)]*10

[Maya-Python] Re: playblast resolution?

2017-03-15 Thread Michael Boon
Apparently 1920x1088 is considered full HD by a lot of software. Google shows several forum posts about it in various A/V forums. Also, apparently a lot of software ignores the 1088 and reports it as 1080, just to make it more confusing for the likes of us! On Thursday, 16 March 2017 09:16:58

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

2017-03-15 Thread Michael Boon
Lambdas are particularly confusing, too. Your original attempt command=lambda *x: self.add_btn_callback("item_list") doesn't actually call the function add_btn_callback, even though it looks like it does. It creates a new function that will call add_btn_callback later. I prefer partial instead,

[Maya-Python] Re: get closest vector to a vector argument

2017-03-21 Thread Michael Boon
You have a list of MVectors and you want to find which of them is closest to a target MVector? Unless your list of MVectors is sorted, you're going to have to compare them all, one at a time. In Python: closestDist = float("inf") for i, vec in enumerate(vectors): dist =

[Maya-Python] Re: get closest vector to a vector argument

2017-03-21 Thread Michael Boon
In general, comparing two vectors means getting the length of their difference. If your vectors are normalized, that will still work, but you can do it faster using a dot product. If you replace the line "dist = (vec-targetVector).length()" with "dot = vec * targetVector" above, the largest

Re: [Maya-Python] Calling my C++ plugin with args via Python maya.cmds

2017-03-06 Thread Michael Boon
probably want to switch to using the object list > instead > > > http://help.autodesk.com/cloudhelp/2016/ENU/Maya-SDK/cpp_ref/class_m_syntax.html#a299f2c91c864387f1b4208e99a72631d > > Justin > > On Mon, Mar 6, 2017, 7:52 PM Michael Boon <boon...@gmail.com > > wrote:

[Maya-Python] Calling my C++ plugin with args via Python maya.cmds

2017-03-05 Thread Michael Boon
Hi all, I have yet another question about arguments to Maya C++ plugins. I have a plugin that accepts flags and objects using an MSyntax and MArgDatabase, and everything works as expected when I call it from MEL, like this: myExportCmd -f "c:/temp" -verbose "pCube3"; Calling it from Python

[Maya-Python] MArgDatabase copy assignment doesn't work?

2017-03-02 Thread Michael Boon
Hey, I'm trying to process arguments in a C++ plugin. I'm a Python guy, not C++, so little things like constructors trip me up a lot. If I do it like this: MArgDatabase inputArgs(syntax(), argList); it works fine. But I want inputArgs to be a member variable, so it's already been constructed.

[Maya-Python] Re: MArgDatabase copy assignment doesn't work?

2017-03-02 Thread Michael Boon
By "doesn't work" I mean it doesn't populate inputArgs with the supplied flags. syntax() gets called, and the plugin will reject bad flags, but any subsequent isFlagSet call I do returns false. On Friday, 3 March 2017 10:13:44 UTC+11, Michael Boon wrote: > > Hey, I'm t

Re: [Maya-Python] Re: MArgDatabase copy assignment doesn't work?

2017-03-02 Thread Michael Boon
there a reason to not use it when you actually need to > process the args? > > > On Fri, Mar 3, 2017 at 12:16 PM Michael Boon <boon...@gmail.com > > wrote: > >> By "doesn't work" I mean it doesn't populate inputArgs with the supplied >> flags. syntax

Re: [Maya-Python] Re: MArgDatabase copy assignment doesn't work?

2017-03-02 Thread Michael Boon
On Friday, 3 March 2017 13:45:53 UTC+11, Justin Israel wrote: > > > On Fri, Mar 3, 2017 at 3:30 PM Michael Boon <boon...@gmail.com > > wrote: > >> Sorry I have confused you there. I'm not storing it in the constructor, >> specifically. >> >> I am

Re: [Maya-Python] Calling my C++ plugin with args via Python maya.cmds

2017-03-07 Thread Michael Boon
estion, "it is possible that this class isn't safe to copy and reuse." I've now crashed Maya a few times by trying to call isFlagSet later during my command execution. So now I have a page or so of extra code to maintain, but it doesn't crash :) On Tuesday, 7 March 2017 09:58:06 UTC+11, Michael Boon

Re: [Maya-Python] Calling my C++ plugin with args via Python maya.cmds

2017-03-07 Thread Michael Boon
s under 4 characters? I was having a similar issue and it was > because my short flags were too long. > > On Tue, Mar 7, 2017 at 9:00 PM, Michael Boon <boon...@gmail.com > > wrote: > >> So, I was doing two things wrong, it seems: >> First, I was passing my MA

[Maya-Python] My QMessageBox.question buttons didn't show up

2017-08-01 Thread Michael Boon
Hi, I've just had a bug report from someone who had to force close Maya 2017 because I popped up a QMessageBox and the buttons that were supposed to be on it were missing. Here's a sanitised version of my code. parentWin is a QMainWindow whose parent is the Maya window. from PySide2 import

Re: [Maya-Python] My QMessageBox.question buttons didn't show up

2017-08-02 Thread Michael Boon
Good point, thanks. On Wednesday, 2 August 2017 15:01:24 UTC+10, Marcus Ottosson wrote: > > If it happened under Maya 2017 pre update 4, then it could be a Maya issue > more than anything else. PySide2 is under heavy development even as we > speak. > -- You received this message because you

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

2017-07-24 Thread Michael Boon
Heh, since we're coming up with alternatives, you can do it in maya.api.OpenMaya too. Once you have the MFnMesh object you can check for uv sets, and also check if the uv sets have uvs: uvSets = fnMesh.getUVSetNames() # Note that uvSets can be empty but that is also handled by the any()

[Maya-Python] Re: How to add a callback to MC.warning to update commandLine1 QLineEdit background color ?

2017-07-26 Thread Michael Boon
Marcus and Justin are much more knowledgeable about stylesheets than I am, but, I suspect you just need to set the stylesheet on the main window instead of the QApplication instance. The example on this page sets a color, but I think the same approach should work for you:

Re: [Maya-Python] Making sense of crash logs

2017-06-29 Thread Michael Boon
That's a shame. I like PySide a lot. I found it creates more readable code than PyQt. This move to PySide2 is certainly creating lots of headaches though, even after Marcus' excellent work in the Qt module. On that subject, if you're using Maya 2017, get update 4. There are lots of fixes for

[Maya-Python] Re: Change and record Input Color Space

2017-07-03 Thread Michael Boon
Doing a text search for the button label, via the translation inputSpaceRulesUI_res.py file, I found this: It looks like this "Reapply Rules to Scene" button is created in ...\Program Files\Autodesk\Maya2017\Python\Lib\site-packages\maya\app\colorMgt\inputSpaceRulesUI.py in the function

[Maya-Python] Re: how many lines per function

2017-04-27 Thread Michael Boon
Sorry Andres, I basically just repeated what you said :) On Friday, 28 April 2017 12:20:49 UTC+10, Michael Boon wrote: > > I think it's important to note that Python is a scripting language. A lot > of the time when you're "scripting", you're writing a function that does a &g

[Maya-Python] Re: how many lines per function

2017-04-27 Thread Michael Boon
I think it's important to note that Python is a scripting language. A lot of the time when you're "scripting", you're writing a function that does a series of different, one-off things. If you try to break it up into reusable components you might make everything far more complicated. Creating

Re: [Maya-Python] Re: Widgets not updating when docked using workspaceControl PySide2/Maya2017

2017-08-07 Thread Michael Boon
I few days ago I ran a script from the Script Editor, which ran a robocopy from a network location, and contained a call to processEvents. It created an infinite loop of robocopy calls. I had to restart my PC to stop it! On Tuesday, 8 August 2017 05:34:03 UTC+10, Cole O'Brien wrote: > > Gotcha,

[Maya-Python] Re: [Maya API] get the translation matrix from the previous frame

2017-05-01 Thread Michael Boon
rix(1, 3), > matrix(2, 0), matrix(2, 1), matrix(2, 2 ), matrix(2, 3), matrix(3, 0), > matrix(3, 1), matrix(3, 2), matrix(3, 3)) > > # Set the output data. > dirX = pDataBlock.outputValue( DirectionMovNode.dirXAttribute > ) > d

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

2017-05-01 Thread Michael Boon
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.

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

2017-05-10 Thread Michael Boon
We both learned something on this thread :) On Tuesday, 9 May 2017 17:31:17 UTC+10, Junaid Iqbal wrote: > > Thank you all specially Michael Boon. I have been stuck with this for 1.5 > months and could not figure out. You have done me a big favor. thanks a lot > again. > Cheers

Re: [Maya-Python] opening .ma files in silent mode

2017-06-22 Thread Michael Boon
You can set environment variables from within Maya. The standard Python way is import os os.environ['MAYA_IGNORE_DIALOGS'] = '1' That will set it for the current Maya session, but not for Windows in general. I haven't checked to see if Maya takes notice of the change to this particular variable

[Maya-Python] Re: Getting pointer to qmainwindow returns nothing (maya2017+)

2017-06-26 Thread Michael Boon
Looking at your example code, there are a couple of things missing. - You don't set a parent for your QMainWindow. Without a parent, it doesn't have any hierarchy in the Maya UI. You've noted that you tried setting a parent, but maybe it didn't work? Can we see the code you tried? - You

Re: [Maya-Python] Fast way to create QIcon in PySide2?

2017-05-22 Thread Michael Boon
Thanks. That sounds like good advice. I'll try it and get back to you. It bears out so far though - trying it in Maya 2017 I see a huge amount of swapping going on. To answer your question Marcus, I guess I was doing it this way because it used to work! The documentation for QIcon says "The

Re: [Maya-Python] Fast way to create QIcon in PySide2?

2017-05-22 Thread Michael Boon
elated? > https://bugreports.qt.io/browse/QTBUG-59621 > > Justin > > > On Tue, May 23, 2017 at 9:43 AM Michael Boon <boon...@gmail.com > > wrote: > >> Thanks. That sounds like good advice. I'll try it and get back to you. It >> bears out so far tho

Re: [Maya-Python] Fast way to create QIcon in PySide2?

2017-05-23 Thread Michael Boon
their images on demand instead of maintaining my own icon cache list, but that was much slower.) On Tuesday, 23 May 2017 09:49:06 UTC+10, Michael Boon wrote: > > Yeah I had decided it was probably the same thing. The comments on the bug > indicate that the person trying to fix it has misu

[Maya-Python] Fast way to create QIcon in PySide2?

2017-05-22 Thread Michael Boon
Hey all, I've just discovered that QIcon is really slow to create in Maya 2017. I'm creating what is essentially a file browser, and my old version had a QStandardItemModel, a QListView with setViewModel(QtWidgets.QListView.IconMode) and about 50,000 icons. Creating the icons used to take ~1

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

2017-05-30 Thread Michael Boon
Sorry, I don't know, but here are some ideas. Perhaps use MEventMessage.addEventCallback('idle', fn). I'm not sure when it would fire but it's likely to fire at the same time as a print statement makes it to the Script Editor. You could look at MRenderer.addNotification with

Re: [Maya-Python] Creating a curve-based wireframe

2017-05-31 Thread Michael Boon
Yeah read up on cProfile if you haven't already. It's really useful. This section looks very slow 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 =

Re: [Maya-Python] Re: Maya 2017 executeDeferred running twice???

2017-06-13 Thread Michael Boon
There are some changes to workspaceControl commands in the new update that might have side-effects like that, so perhaps that's what you're seeing. In your case, perhaps your toolbar is being loaded once by something in your prefs (ie, Maya saved it to your prefs) and a second time by your

[Maya-Python] Re: [Maya API] get the translation matrix from the previous frame

2017-04-30 Thread Michael Boon
I've done a similar thing successfully in Python, but I used MPlug::asMObject and MFnMatrixData::matrix instead of MPlug::getValue. I don't remember if I tried using getValue, but I do remember that I found it extremely finicky and I tried a lot of approaches before I found one that gave me a

[Maya-Python] Re: project paths

2017-05-02 Thread Michael Boon
If you run "p4 info" in a subprocess, you can then look up "Client root". Something like this: info = subprocess.check_output('p4 info') info = info.splitlines() info = [L.split(':', 1) for L in info] info = dict(info) p4Root = info['Client root'] You can then compare p4Root to the paths you're

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

2017-05-02 Thread Michael Boon
The first script you linked is NOT using isRightHandedTangent. Instead it creates vectors and does a cross product in Python, which would slow it down for sure. The second script is very involved! It uses the API for some stuff but it is also iterating through all faces by converting each of

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

2017-05-04 Thread Michael Boon
The little apostrophe character you're using should be `, not ' On a US keyboard, that's the key above Tab. I don't know what it's called (and I've never seen it used for anything other than MEL). On Thursday, 4 May 2017 18:04:24 UTC+10, Junaid Iqbal wrote: > > Hey guys, > I need some help

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

2017-05-30 Thread Michael Boon
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"',

Re: [Maya-Python] Re: [QUATERNION] Slerp

2017-09-18 Thread Michael Boon
) (0.382683, 0, 0, 0.92388) which is correct. On Tuesday, 19 September 2017 07:57:55 UTC+10, Michael Boon wrote: > > If your dot is >0 in that code, and there are no mistakes, then you > shouldn't get a flip. If you're seeing a flip, my feeling is that you > should be looking for

Re: [Maya-Python] Re: [QUATERNION] Slerp

2017-09-19 Thread Michael Boon
I think I see your problem with accessing the slerp function. There are two Maya Python "OpenMaya" APIs. The old one (1.0) is maya.OpenMaya. maya.OpenMaya.MQuaternion does not have a slerp function. The new one (2.0) is maya.*api*.OpenMaya. maya.api.OpenMaya.MQuaternion does have slerp. The new

[Maya-Python] Import plugin (MPxFileTranslator)

2017-09-19 Thread Michael Boon
Hi, I have a file import script and I want to make it into an importer plugin. Hopefully someone can help me with these questions: - Does MPxFileTranslator exist in Python API 2.0? If not, - should I use API 1.0 or should I use a different class? - where can I find

[Maya-Python] Re: [QUATERNION] Slerp

2017-09-18 Thread Michael Boon
It's been a long time since I dealt with quaternions at this level, but if I understand your question correctly, yeah Maya will reverse the quaternion once you pass 180. Actually it's not Maya doing that. A quaternion can distinguish between, say, +270 and -90, but a transform matrix can only

Re: [Maya-Python] recover scripting work after a crash ?

2017-09-14 Thread Michael Boon
If you're doing something you suspect might crash Maya, you can save the Script Editor without closing Maya, like this: # Save contents of Script Editor import maya.cmds as cmds import maya.mel as mel cmds.savePrefs(general=True) # This saves tab names, among other stuff.

[Maya-Python] Re: adding placeholder menu BEFORE the file menu

2017-09-18 Thread Michael Boon
Maybe someone else can be more useful, but from what I can see this isn't easy. Maya provides commands like menu, and menuSet, that allow you to add and reorder menus, but you can't add menus to the default sets, and you can't have a different menu set show up to the left of the "Common" menu

[Maya-Python] Re: Having trouble nesting all instances into group.

2017-08-29 Thread Michael Boon
That doesn't actually work at all for me. The second time through the loop it creates a second instance with the same name as the first, then fails with # ValueError: More than one object matches name: [u'polySphere1_inst'] # It works for me if I don't try to set the name in the instance

[Maya-Python] Re: [QUATERNION] Slerp

2017-09-27 Thread Michael Boon
ons slerp nicely up to 360°. They get messy at 360 though, but I think that is unavoidable. Is that it? On Thursday, 28 September 2017 00:34:41 UTC+10, Rémi Deletrain wrote: > > *Michael Boon* > > I've attached two files to this post. rdTwist is my node. Browse this > plugin

Re: [Maya-Python] word sorting script not giving me the results I am expecting.

2017-09-27 Thread Michael Boon
I appreciate you're doing this as an exercise...but if you ever have to do it in real life, the Python standard libraries contain collections.Counter , which I think does exactly what you want, and probably much faster. > >>>

[Maya-Python] Re: What's a good strategy to let Maya load my modules which are always located in different places?

2017-09-27 Thread Michael Boon
I have no experience with GitLab Can you put your module into your ProjectRoot, and use relative directories inside the module? Then just change the MAYA_MODULE_PATH for each runner? On Wednesday, 27 September 2017 19:56:34 UTC+10, yaoys wrote: > > Hi all, > I'm going to use GitLab CI to build

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

2017-10-10 Thread Michael Boon
Wow! Happens in 2016 too. However, StopIteration is defined, and I can catch it. This: a = iter([1,2]) for i in range(4): print i, next(a) gives 0 1 1 2 2 While this: a = iter([1,2]) for i in range(4): try: print i, next(a) except StopIteration: print 'StopIteration'

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

2017-10-11 Thread Michael Boon
t;> have StopIteration available. >> >> On Tue, Oct 10, 2017 at 7:40 PM Marcus Ottosson <konstr...@gmail.com> >> wrote: >> >>> Can confirm that it is defined in 2018 as well. The above was in 2015. >>> How peculiar. >>> >>> O

[Maya-Python] Re: can I make and transform in one line

2017-10-11 Thread Michael Boon
It's pretty weird-looking, but this works: setAttr(cmds.polyCube(name="Bob")[0]+'.t', (10,5,-6)) I'm not sure what your real requirement is, but to get it on one line I'd be happier using a semicolon: bob = cmds.polyCube(name="Bob")[0]; cmds.setAttr(bob+'.t', 10,5,7) (I'm using cmds instead of

Re: [Maya-Python] component selection using python

2017-10-11 Thread Michael Boon
Just some thoughts on this, without running it: - cmds.sets has a flag "flatten" that will give you components individually, so you don't need to worry about separating out the colon. - I am confused about what all that code at the start does. It looks like you get the "Dirt"

Re: [Maya-Python] component selection using python

2017-10-12 Thread Michael Boon
olorVertexList = [api.MColor(1,0,0,1)]*len(vList) > meshFn.setVertexColors(colorVertexList, vList) > On Wednesday, October 11, 2017 at 10:23:44 PM UTC-6, Michael Boon wrote: > >> Just some thoughts on this, without running it: >> >>- cmds.sets has a fla

Re: [Maya-Python] MFnSkinCluster and setWeigths

2017-10-17 Thread Michael Boon
@Justin lol Yeah I have no idea either. Using the API functions I've always found it plenty fast. Of course there are a lot of ways to make code slow, and figuring out why code is slow is not always easy. I had the benefit of seeing a fast version someone else wrote before I had to write my

Re: [Maya-Python] Re: Maya API, getting UV border vertices struggle

2017-11-14 Thread Michael Boon
the time being can get us as close as possible. > > Not all faces have UVs in uvSet that I can confirm for sure so the lists > are out of sync. What if I iterated the face vertices and checked each > vertex has UVs first and then cross referenced each list? > > > On 13 Nove

Re: [Maya-Python] Re: Animating curves/surfaces by moving control point

2017-11-22 Thread Michael Boon
It would probably be useful to look at how other people have solved a similar problem, too. Are there any examples of people creating similar deformations in Maya? Do they have custom deformers for it? There's a good chance they used some combination of existing Maya nodes, at least for part

Re: [Maya-Python] Re: Maya API, getting UV border vertices struggle

2017-11-12 Thread Michael Boon
Hi Ben, I can't see your image, but I can run your code on a mesh of my own. In really basic tests it seems to work correctly. It's a bit tricky to read through. There's a fair bit of temp code in there, and things that are assigned and not used. Also, why are you using Python API 1.0? It's

[Maya-Python] Re: Animating curves/surfaces by moving control point

2017-11-12 Thread Michael Boon
This may not be the right place to ask, depending on what exactly you mean by that. You definitely need to be more specific about what you're trying to achieve. And start with the docs, and the various tutorials and help sites around the web, where the information you want is probably already

[Maya-Python] Re: [MSyntax] addFlag does not work

2017-11-07 Thread Michael Boon
Glad to hear you figured it out. I have never got MSyntax to work on the first attempt. It just seems to be finicky, and there's always some small thing that makes it fail. On Friday, 3 November 2017 18:32:44 UTC+11, Rémi Deletrain wrote: > > Sorry for my late answer... > > I think i found the

[Maya-Python] Re: Maya API, getting UV border vertices struggle

2017-11-09 Thread Michael Boon
For speed, you definitely want to use OpenMaya, but more importantly, avoid creating new Python objects every time you loop over a vert. Try to create some lists of regular Python ints upfront, then just count them. Once you have a MFnMesh, you can get a list of the UV IDs used at each corner

[Maya-Python] Re: Printing to console from custom node while playback or timeline scrubbing.

2017-11-09 Thread Michael Boon
I've noticed that print can be delayed until Maya is idle. You might want to try other methods of printing. If you have a logger object, logger.info is often more responsive than print. Or maybe you could use something like MEL's headsUpMessage or a GUI element like a messageLine? On

[Maya-Python] Re: UI: Custom sidebar button

2017-12-06 Thread Michael Boon
I'm not sure about creating a toggle button. For your second question though, I think you can do that with any dockable window. In Maya 2018 (at least) I can grab the Attribute Editor and dock it next to the Channel Box, for example. I guess I'm misunderstanding. Maybe a screenshot would help?

Re: [Maya-Python] Re: Maya, Euler Rotation and Gimbal lock

2018-05-31 Thread Michael Boon
Unless I'm mistaken, the Euler rotations (0, 0, -120) and (180,180, 60) are identical for any rotation order. Having said that, you don't have those. You have roughly (180, 180, -60) for your second one, plus there's an extra 2 degrees in the first one. I'd be looking at AK Eric's suggestion

[Maya-Python] Re: Create customised shader with Python - maya

2018-06-25 Thread Michael Boon
I don't have Arnold installed here so I can't help a whole lot, but I can use very similar script to set "diffuse" on a Lambert material. This works for me: import pymel.core as pm name = 'CHROME' shaderType = 'lambert' name = pm.shadingNode(shaderType, asShader=True, name=name) sg =

[Maya-Python] Re: Create customised shader with Python - maya

2018-06-26 Thread Michael Boon
iNoise to weight. Thanks in advance. > > On Tuesday, June 26, 2018 at 9:39:16 AM UTC+5:30, Michael Boon wrote: >> >> I don't have Arnold installed here so I can't help a whole lot, but I can >> use very similar script to set "diffuse" on a Lambert material.

[Maya-Python] Re: Create customised shader with Python - maya

2018-06-26 Thread Michael Boon
'%s.metallic1' %(name), f=True) > > return [name, sg] > > > > This is the error I'm getting "# RuntimeError: The source attribute > 'ramp1.outColor' cannot be found" > > > > > > > > On Tuesday, June 26, 2018 at 12:16:53 PM UTC+5:30, Michael Boon w

Re: [Maya-Python] mirroring a matrix without busting scale

2018-04-30 Thread Michael Boon
Mirroring quaternion rotation is actually easy. A quaternion is (for our purposes here) and axis and an angle. You just need to mirror the axis part. So if your quat is (x,y,z,w) and you want to mirror around the x axis, make it (-x, y, z, w) On Thursday, 26 April 2018 13:33:52 UTC+10,

[Maya-Python] Re: [MSyntax] addFlag does not work

2017-10-26 Thread Michael Boon
I don't understand properly. Are you saying that the code in your second post works correctly? The big difference between that and your first post is what Justin said - in your second post you set status. status =syntax.addFlag(... compared with the first post syntax.addFlag(... So in your first

[Maya-Python] Re: Build Mesh from point cloud using MayaAPI

2018-01-08 Thread Michael Boon
It can be done, and actually isn't too hard. Use the MFnMesh.create() function. Give it a try, and if you get stuck, get back to us and someone here will be able to help you with specifics. On Tuesday, 9 January 2018 02:54:50 UTC+11, illunara wrote: > > Hi > I want to build an low-res mesh

[Maya-Python] Re: pycrypto module inside maya for windows server 2016

2018-01-21 Thread Michael Boon
There's a good chance that the dll that fails is not something you're importing directly, but is being loaded from inside a module you're using, maybe from inside pycrypto. The reason could be Python version, 32 vs 64 bit, or the availability of some OS function. You could set "Show Stack

[Maya-Python] Re: Record Attribute for one frame

2018-02-07 Thread Michael Boon
So your problem is that Maya doesn't notice the hotkey being pressed while the mouse is down? Maya doesn't appear to have a scriptJob or an MMessage for a key being pressed. If you're familiar with Qt, you could try using a Qt event handler. I'm sure you could detect the key being pressed,

  1   2   >