All posts related to V2
#382068
Hi, I'm writing a python script to do something similar to the pack and go function in Studio, but am having some issues with python and Maxwell 2.7.2.

Calling getDependencies() returns a list, but it contains NULL values as well as dependency paths. Then if I try to loop through the list python crashes completely.

For example the code below...
Code: Select all
from pymaxwell import *
import sys

def get_dependencies():

    mxs_path = r'C:\\Users\\davealot\\Dropbox\\SPARK\\MXS scenes\\Pack_and_go_test_scene\\cube_ball_cube.mxs'
    scene = Cmaxwell(mwcallback)
    ok = scene.readMXS(mxs_path)

    if ok == 0:
        print "Error reading scene"
        return 0;

    scene_dependencies = scene.getDependencies()
    print scene_dependencies

get_dependencies()
print sys.version

produces this output:
Code: Select all
>> [<NULL>, <NULL>, <NULL>, <NULL>, 'C:\\Visualisation_PC\\Groundplants0153_5_S.jpg', 'D:\\Visualisation\\concrete-19_d100.png', 'D:\\Visualisation\\White_resin_BUMP.jpg', 'D:\\Visualisation\\1103 Sun Clouds.hdr']
2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)]
It works in Maxwell 3 ok. Any scripting/plugin gurus have any idea what's going wrong? Or if there's another way to create a pack and go like script?

Ta
#382080
Hi!

There is a bug there (indeed, it is solved for maxwell 3).

The problem is that it creates the dependencies list that way:

num_dependencies = 4
create_list( 4 ) -> [<NULL>,<NULL>,<NULL>,<NULL>]
appends the dependencies to the list -> [<NULL>,<NULL>,<NULL>,<NULL>,'depA','depB','depC','depD']

creates a list with the right size, but it appends the dependencies, instead of fill the list, so instead of having a 4 items list in that case, we have a 2*4=8 items, with the first half of the list uninitialized.

So, to workaround this, you must use the second half of the dependencies list, you can do it this way:
Code: Select all
temp = scene.getDependencies()
scene_dependencies = temp[len(temp)/2:]
Hope it helps!
Chocolate test with SSS

nice