[MaxPlus 2015]Reading an Array of various data types with MaxPlus

Hello,

I am trying to run a speed test between two functions, one written with maxScript dotNet and the other in Python.
The two functions need to read data saved in a maxScript array though, and when I use the following code:


res = MaxPlus.FPValue()
evaluation_success = MaxPlus.Core.EvalMAXScript(cmd, res)
MaxPlus.FPValue_Get(res)

it returns the following error code:
– Runtime error: Line 36429 FPValue_Get()
<type ‘exceptions.RuntimeError’> unable to find an appropriate get function for type 2091

as far as my digging around has been able to figure out, there is no native MaxPlus support for an array with different types of data in them (Strings, nested arrays, matrix3s)

Has anyone experienced this, if so is there a work around?
Any help would be appreciated.

We wrapped the EvalMaxScript function to avoid this kind of thing. You need to check your FPValue before returning its value. Some types have no conversion format to python so you need to handle them yourself. Off the top of my head I don’t remember which is which, but I think code 2091 is undefined.

def eval_mxs_string(cmd):
    try:
        res = MaxPlus.FPValue()
        evaluation_success = MaxPlus.Core.EvalMAXScript(cmd, res)
        if not evaluation_success or res.GetType() == 44 or res.GetType() == 2091:
            return None
        else:
            return res.Get()
    except RuntimeError as e:
        print 'eval_mxs_string error: {}'.format(e.message)

Thanks Claudio,

That is a neat way of handling the error, but unfortunately I need the data it is returning so a None type won’t really help :frowning:

After digging around a bit more, it seems that it is unable to give a type for the returned value as it is an array with multiple object types inside of it. It looks like maxPlus only wraps the list classes from the SDK and not the array class :confused: So it is impossible to get the fpValue of a multitype array…