|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| Passing enums from concatenated strings
|
|
|
Hello everyone,
I’m not sure if this is a MotionBuilder question, but here goes…
I’m trying to procedurally generate enums based off of input from a UI, I can grab the info and format it to which enums I want to use, but am having difficulty passing this as an argument (as it’s now a string).
Has anyone had any success doing this?
Any help appreciated, thanks in advance.
|
|
|
|
Without any code or a simplified example it is a bit difficult to understand the problem. However, if you have a string and want to turn it into an Integer in python you simply wrap the variable in int() you can also force objects to
str()#string
#and
eval()#which will evaluate a string
Although I think you already know of these, because you are using Classes and enums which is not low level code. I recommend you post a quick example or error you are receiving.
|
|
|
|
Hi Ryan,
Sorry for the delayed response.
Here’s a simplified example of what I was asking. The first block should be executed separately, then the second block.
#BLOCK 1
m = FBModelMarker('test') m.Show = True
m.Look = FBMarkerLook.kFBMarkerLookSphere
#BLOCK 2
##passing an enum as a string fails... enumString = 'FBMarkerLook.kFBMarkerLookHardCross' m.Look = enumString
In my tool, enumString is what I create procedurally. But when I try to use this string, I get an argument error. Kinda makes sense, but I’m not sure what to do in order for it to let me parse the variable as an enum.
Any thoughts appreciated!
Thanks.
|
|
|
|
Now I am sorry for the delayed response haha.
So the problem is that you are passing a string “FBMarkerLook.kFBMarkerLookHardCross” where the m.Look is searching for a specific argument.
by wrapping your string in eval() python no longer treats your string the same way.
if you do
m = FBModelMarker('test') m.Show = True
enumString = 'FBMarkerLook.kFBMarkerLookHardCross'
m.Look = eval(enumString)
Let me know if that works. I did not receive any errors…
|
|
|
|
|
|