Notifications
Clear all
[Closed] Python: SetCurrentLayer broken?!?
Mar 26, 2015 4:26 pm
Simple example code:
import MaxPlus
MaxPlus.LayerManager.CreateLayer("foobar")
MaxPlus.LayerManager.SetCurrentLayer("foobar")
A “foobar” layer will be created, but SetCurrentLayer() will result in a error:
-- Error occurred in anonymous codeblock; filename: test.ms; position: 250; line: 6
-- Runtime error: Line 39 run()
Line 30210 SetCurrentLayer()
<type 'exceptions.NotImplementedError'> Wrong number or type of arguments for overloaded function 'LayerManager_SetCurrentLayer'.
Possible C/C++ prototypes are:
Autodesk::Max::LayerManager::SetCurrentLayer(Autodesk::Max::WStr const &)
Autodesk::Max::LayerManager::SetCurrentLayer()
Why?
2 Replies
Mar 26, 2015 4:26 pm
i think that setcurrentlayer needs a layer object instead of layer name.
the createlayer probably returns this object
Mar 26, 2015 4:26 pm
You need to wrap the layer name into a MaxPlus.WStr object:
import MaxPlus
MaxPlus.LayerManager.CreateLayer("foobar")
MaxPlus.LayerManager.SetCurrentLayer(MaxPlus.WStr("foobar"))
EDIT:
Better solution using python unicode literals:
import MaxPlus
MaxPlus.LayerManager.CreateLayer("foobar")
MaxPlus.LayerManager.SetCurrentLayer(u"foobar")
I think the problem here is the SetCurrentLayer function having two overloads where the automatic type conversion from python to c++ fails.