Discussion:
[Maya-Python] Custom Maya node, with iconName like dagContainer
Marcus Ottosson
2017-11-16 06:34:29 UTC
Permalink
Hi all,

I’m looking to implement this.

node = cmds.createNode("myCustomNode")
cmds.setAttr(node+ ".iconName", "polyMeasureUV.png")

And have the icon appear wherever this node is drawn, such as the Outliner
and Node Editor. Ideally polyMeasureUV.png is one of Maya’s own internal
icons, the ones you can browse via the Shelf Editor.

I know about the XBMLANGPATH but would like something that A) doesn’t
require a restart or meddling with the environment in order to work (if
that’s possible still using this approach, do let me know) and B) uses
Maya’s own icon library such that I won’t have to ship custom images.

I’m chasing this, because I noticed the dagContainer have a feature like it
and works quite well.

from maya import cmds
container = cmds.createNode("dagContainer", name="LegLeft03_LIM")
cmds.setAttr(container + ".iconName", "polyMeasureUV.png")

[image: Inline images 1]

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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCf7aAUKAyAFZTnoS6G%2Ba%3DzEZDQuzp60Ct6KBi3YJ0o4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
davidlatwe
2018-10-10 18:48:09 UTC
Permalink
Hi Marcus,

I was looking for this, too. Have you got any result ?

While I was googling, I found this page

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2018/ENU/Maya-SDK/cpp-ref/node-icon-cmd-2node-icon-cmd-8cpp-example-html.html

And that inspired me to use `MFnDependencyNode.setIcon()` to do the trick,
but I end up using Maya Python API 1.0, since 2.0 won't work.

Finally, I put them together as a small tool and upload it

https://github.com/davidlatwe/NodeSticker

Although this thread has been here almost a year..., but welcome to have a
try :)

Best,
David


Marcus Ottossonæ–Œ 2017幎11月16日星期四 UTC+8䞋午2時34分38秒寫道
Post by Marcus Ottosson
Hi all,
I’m looking to implement this.
node = cmds.createNode("myCustomNode")
cmds.setAttr(node+ ".iconName", "polyMeasureUV.png")
And have the icon appear wherever this node is drawn, such as the Outliner
and Node Editor. Ideally polyMeasureUV.png is one of Maya’s own internal
icons, the ones you can browse via the Shelf Editor.
I know about the XBMLANGPATH but would like something that A) doesn’t
require a restart or meddling with the environment in order to work (if
that’s possible still using this approach, do let me know) and B) uses
Maya’s own icon library such that I won’t have to ship custom images.
I’m chasing this, because I noticed the dagContainer have a feature like
it and works quite well.
from maya import cmds
container = cmds.createNode("dagContainer", name="LegLeft03_LIM")
cmds.setAttr(container + ".iconName", "polyMeasureUV.png")
[image: Inline images 1]
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/6687779b-277a-49fe-ad21-0888aca2ca34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2018-10-11 13:50:35 UTC
Permalink
Thanks David, that’s a great find. :)

from maya import cmds, OpenMaya as om

node = cmds.createNode("transform")
sel = om.MSelectionList()
mobj = om.MObject()
om.MGlobal.getActiveSelectionList(sel)
sel.getDependNode(0, mobj)
fn = om.MFnDependencyNode(mobj)
fn.setIcon("polyTorus.png")

Since then, it’s turned out that setting XBMLANGPATH during userSetup.py
works just fine, except on Linux in which case setting it prior to
launching Maya hasn’t been as much of a problem as I initially expected.

I did come across an .iconName attribute only a few weeks ago, present on
all nodes since at least Maya 2015, but quickly dismissed it as I couldn’t
get it to work. it doesn’t seem related either, as seems to be for the
Hypergraph specifically.

-
https://help.autodesk.com/cloudhelp/2015/ENU/Maya-Tech-Docs/Nodes/containerBase.html#attriconName

I had a look at your “NodeSticker” code, and it looks like you’ve
identified a few issues with the idea, primarily that the set icon isn’t
stored with the scene; what a shame! Such a small thing. It means you’ll
either need to manually call something whenever you open a scene (tedious),
or install a callback for scene-open, or node-creation that can call it
automatically (complex).

In my experiment just now, it looks like some icons *are* preserved (in
this case, in 2018 on the defaultObjectSet) but not others; likely only in
the current Maya session; as though that node is never actually deleted on
scene new/open (perhaps a “shared node”?).
Post by davidlatwe
Hi Marcus,
I was looking for this, too. Have you got any result ?
While I was googling, I found this page
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2018/ENU/Maya-SDK/cpp-ref/node-icon-cmd-2node-icon-cmd-8cpp-example-html.html
And that inspired me to use `MFnDependencyNode.setIcon()` to do the trick,
but I end up using Maya Python API 1.0, since 2.0 won't work.
Finally, I put them together as a small tool and upload it
https://github.com/davidlatwe/NodeSticker
Although this thread has been here almost a year..., but welcome to have a
try :)
Best,
David
Marcus Ottossonæ–Œ 2017幎11月16日星期四 UTC+8䞋午2時34分38秒寫道
Post by Marcus Ottosson
Hi all,
I’m looking to implement this.
node = cmds.createNode("myCustomNode")
cmds.setAttr(node+ ".iconName", "polyMeasureUV.png")
And have the icon appear wherever this node is drawn, such as the
Outliner and Node Editor. Ideally polyMeasureUV.png is one of Maya’s own
internal icons, the ones you can browse via the Shelf Editor.
I know about the XBMLANGPATH but would like something that A) doesn’t
require a restart or meddling with the environment in order to work (if
that’s possible still using this approach, do let me know) and B) uses
Maya’s own icon library such that I won’t have to ship custom images.
I’m chasing this, because I noticed the dagContainer have a feature like
it and works quite well.
from maya import cmds
container = cmds.createNode("dagContainer", name="LegLeft03_LIM")
cmds.setAttr(container + ".iconName", "polyMeasureUV.png")
[image: Inline images 1]
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/6687779b-277a-49fe-ad21-0888aca2ca34%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/6687779b-277a-49fe-ad21-0888aca2ca34%40googlegroups.com?utm_medium=email&utm_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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBKyvr53DXoMa1eR1GtOBrqRUiicsttYjnX7%3DSwVbHMhg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
David Lai
2018-10-11 20:36:43 UTC
Permalink
Indeed some nodes’ icon get preserved !
Like time1 lambert1 shaderGlow1, also their UUID didn’t change, too.
( another *Maya Fun Fact* I guess )

install a callback for scene-open

I was going to do this.
It’s really a bit unfortunate that won’t survive scene-new/open, but since
my original goal was only to differentiate between native objectSet node
and those created from my pipeline (Avalon), I can sleep well with this
outcome :D
Way better then using AssetNode just for custom icon (I was looking in that
direction before this).

Lastly, thanks for having a look !
Post by Marcus Ottosson
Thanks David, that’s a great find. :)
from maya import cmds, OpenMaya as om
node = cmds.createNode("transform")
sel = om.MSelectionList()
mobj = om.MObject()
om.MGlobal.getActiveSelectionList(sel)
sel.getDependNode(0, mobj)
fn = om.MFnDependencyNode(mobj)
fn.setIcon("polyTorus.png")
Since then, it’s turned out that setting XBMLANGPATH during userSetup.py
works just fine, except on Linux in which case setting it prior to
launching Maya hasn’t been as much of a problem as I initially expected.
I did come across an .iconName attribute only a few weeks ago, present on
all nodes since at least Maya 2015, but quickly dismissed it as I couldn’t
get it to work. it doesn’t seem related either, as seems to be for the
Hypergraph specifically.
-
https://help.autodesk.com/cloudhelp/2015/ENU/Maya-Tech-Docs/Nodes/containerBase.html#attriconName
I had a look at your “NodeSticker” code, and it looks like you’ve
identified a few issues with the idea, primarily that the set icon isn’t
stored with the scene; what a shame! Such a small thing. It means you’ll
either need to manually call something whenever you open a scene (tedious),
or install a callback for scene-open, or node-creation that can call it
automatically (complex).
In my experiment just now, it looks like some icons *are* preserved (in
this case, in 2018 on the defaultObjectSet) but not others; likely only
in the current Maya session; as though that node is never actually deleted
on scene new/open (perhaps a “shared node”?).
Post by davidlatwe
Hi Marcus,
I was looking for this, too. Have you got any result ?
While I was googling, I found this page
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2018/ENU/Maya-SDK/cpp-ref/node-icon-cmd-2node-icon-cmd-8cpp-example-html.html
And that inspired me to use `MFnDependencyNode.setIcon()` to do the
trick, but I end up using Maya Python API 1.0, since 2.0 won't work.
Finally, I put them together as a small tool and upload it
https://github.com/davidlatwe/NodeSticker
Although this thread has been here almost a year..., but welcome to have
a try :)
Best,
David
Marcus Ottossonæ–Œ 2017幎11月16日星期四 UTC+8䞋午2時34分38秒寫道
Post by Marcus Ottosson
Hi all,
I’m looking to implement this.
node = cmds.createNode("myCustomNode")
cmds.setAttr(node+ ".iconName", "polyMeasureUV.png")
And have the icon appear wherever this node is drawn, such as the
Outliner and Node Editor. Ideally polyMeasureUV.png is one of Maya’s
own internal icons, the ones you can browse via the Shelf Editor.
I know about the XBMLANGPATH but would like something that A) doesn’t
require a restart or meddling with the environment in order to work (if
that’s possible still using this approach, do let me know) and B) uses
Maya’s own icon library such that I won’t have to ship custom images.
I’m chasing this, because I noticed the dagContainer have a feature
like it and works quite well.
from maya import cmds
container = cmds.createNode("dagContainer", name="LegLeft03_LIM")
cmds.setAttr(container + ".iconName", "polyMeasureUV.png")
[image: Inline images 1]
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/6687779b-277a-49fe-ad21-0888aca2ca34%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/6687779b-277a-49fe-ad21-0888aca2ca34%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the
Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/python_inside_maya/9XAzZL24tUs/unsubscribe
.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBKyvr53DXoMa1eR1GtOBrqRUiicsttYjnX7%3DSwVbHMhg%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBKyvr53DXoMa1eR1GtOBrqRUiicsttYjnX7%3DSwVbHMhg%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
David

0982-000-675

GDay
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAKhUT%2BSq%2BEx7XSuONdM4FuHs7ZtOd5UDdGDuhTZynnQLQyCxeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...