Here’s my 2 cents. I’d be explicit about it.
from maya import cmds
def myCreateNode(node):
nodes = {
"joint": {
"tx": 1.0,
"ty": 10.0,
"ry": 5.0
},
"mesh": {
"overrideEnabled": 1,
"overrideColor": 6,
}
}
overrides = nodes.get(node, {})
node = cmds.createNode(node)
for attribute, value in overrides.items():
cmds.setAttr(node + "." + attribute, value)
return node
myCreateNode("joint")
myCreateNode("mesh")
--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCA_FC-6iK3EVhYCXTYw8CTKttfrjJNm92izuCVroOfXA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2bd95713-2224-4b8f-8dfb-cf74b0f275a4%40googlegroups.com.
Hey,You can run that check without a callback:from maya import OpenMaya as omif not om.MFileIO.isReadingFile():change some stuff...That would avoid callback spaghetti :)Best,Ian
On 30 Mar 2017, at 12:20, Szabolcs <szab...@impresszio.hu> wrote:
Hi,
I'd like to change the default attribute values of a certain node type, but because of an existing asset library I can't simply change the defaults in the plugin, because that would break existing Maya scenes. I tried using OpenMaya.MDGMessage.addNodeAddedCallback() to setup a callback to change the attributes after node creation and it works ok, but the problem is that the callback executes not only when a new node is created by hand (or script) but also when a scene file is loaded / imported / referenced. I could disable the callback for scene load using another callback (yuck!) but it sounds like its leading into a mess of callbacks fighting with each other. I'm also not super happy about having a callback that examines the node type of every created node either, I'm afraid that it would slow down some scripts.
So the question is: is there a bulletproof solution for doing something like this? Or are there any tricks to check the reason of the addNodeAddedCallback being called? Or should I simply hijack createNode and shadingNode commands and wrap them into custom code (for both mel and python)? Any suggestion is much appreciated!
Cheers,
Szabolcs--
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+unsub...@googlegroups.com.