hey , its been a while but is this the Softimage badass thread? :)
python... meh!



On 29 May 2012 20:24, Jeremie Passerin <gerem....@gmail.com> wrote:
> Interesting !
> That looks nicer
>
>
> import json
>
> root = Application.ActiveSceneRoot
> blob = root.Properties("Test")
> if not blob:
> blob = root.AddProperty("UserDataBlob", False, "Test")
>
> LogMessage(blob)
>
> data = {}
> data["test"] = 123
> data["hello"] = "hello"
>
> d = json.dumps(data)
>
> blob.Value = d
>
> out = json.loads(blob.Value)
>
> LogMessage(out)
>
> On 29 May 2012 12:05, Alan Fregtman <alan.fregt...@gmail.com> wrote:
>>
>> For a dictionary the json module is
>> nice: http://docs.python.org/library/json.html
>>
>> A bit less ugly than storing base64 text.
>>
>>
>>
>> On Tue, May 29, 2012 at 2:34 PM, Jeremie Passerin <gerem....@gmail.com>
>> wrote:
>>>
>>> okay.. I was thinking of that too... just wondering if that was the only
>>> way...
>>>
>>> so it looks like this for me :
>>>
>>> # Python code starts
>>> import pickle
>>> import base64
>>>
>>> root = Application.ActiveSceneRoot
>>> blob = root.Properties("Test")
>>> if not blob:
>>> blob = root.AddProperty("UserDataBlob", False, "Test")
>>>
>>> LogMessage(blob)
>>>
>>> data = {}
>>> data["test"] = 123
>>> data["hello"] = "hello"
>>>
>>> d = base64.b64encode(pickle.dumps(data,
>>> protocol=pickle.HIGHEST_PROTOCOL))
>>>
>>> blob.Value = d
>>>
>>> out = pickle.loads(base64.b64decode(blob.Value))
>>>
>>> LogMessage(out)
>>> # Python Code ends
>>>
>>>
>>>
>>> On 29 May 2012 11:26, Francois Lord <flordli...@gmail.com> wrote:
>>>>
>>>> I've done it for binary data with pickle and base64.
>>>> Yes I know, it's very ugly.
>>>>
>>>>
>>>> On 29/05/2012 14:03, Jeremie Passerin wrote:
>>>>>
>>>>> Hi list !
>>>>>
>>>>> This morning I've been trying to do something that I thought would be
>>>>> fairly easy... but I'm stuck
>>>>> How do you store a dictionary inside a userdatablob in Python?
>>>>> My dictionary is just made of integer, strings, float... nothing fancy
>>>>> And it doesn't have to be a dictionary... I just need a way to connect
>>>>> a value to a name...
>>>>>
>>>>> I've seen this example :
>>>>>
>>>>> http://softimage.wiki.softimage.com/sdkdocs/scriptsdb/scriptsdb/UserDataBlob_ByteArray_1_pys.htm
>>>>>
>>>>> but I would need a untyped array as my values are not all of the same
>>>>> type.
>>>>>
>>>>>
>>>>> Any idea ?
>>>>>
>>>>> cheers,
>>>>> Jeremie
>>>>>
>>>>>
>>>
>>
>

Reply via email to