Setting the default value of a node's string attribute

432 views
Skip to first unread message

Szabolcs Horvátth

unread,
Dec 4, 2015, 8:10:46 AM12/4/15
to python_inside_maya
Hi,

I'd like to specify the default value of a string attribute of a node generated by a Python plugin.
Based on the C++ API docs I assume I have to use OpenMaya.MFnStringData() but I can't find any solution that actually works.

Any tips and pointers are much appreciated!

Cheers,
Szabolcs

f.michal

unread,
Dec 4, 2015, 8:15:30 AM12/4/15
to python_in...@googlegroups.com
try this:

tAttr = OpenMaya.MFnTypedAttribute()
tAttr.create(name, name, OpenMaya.MFnData.kString,
OpenMaya.MFnStringData().create(default_value) )

W dniu 2015-12-04 o 14:10, Szabolcs Horvátth pisze:

szabolcs...@digicpictures.com

unread,
Dec 4, 2015, 3:00:53 PM12/4/15
to Python Programming for Autodesk Maya
Thanks Michał, it works nicely! I was almost there... :)

sz.

szabolcs...@digicpictures.com

unread,
Dec 4, 2015, 3:00:56 PM12/4/15
to Python Programming for Autodesk Maya
Thanks Michal,

This was the kind of stuff I tried and this is what I get with Maya 2015sp6 on windows7:
--
RuntimeError: file S:\Maya_2015_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py line 4821: (kFailure): Object does not exist
--

The usual useful and descriptive error message. :)

Cheers,
Szabolcs


On Friday, December 4, 2015 at 2:15:30 PM UTC+1, Michał Frątczak wrote:

Michał Frątczak

unread,
Dec 8, 2015, 6:06:32 AM12/8/15
to Python Programming for Autodesk Maya, szabolcs...@digicpictures.com
Hi Szabolcs
Sorry for late reply, I missed your post.
Can't help with exact error message, but in case you haven't resolved it by now, here's a working code:

Reply all
Reply to author
Forward
0 new messages