cont = temp[0]['containers'][0] # replace the id in the container to make it use another plateID cont['id'] = psr # replace the list of containers by a list that contains only the first element (could be more) temp[0]['containers'] = [cont] # make a deep copy of the three step template and add it to the momentum script. Deepcopy is necessary, otherwise the changes in the template # would be present in all templates. This might be a desired feature in another case but here it is not psr['process/steps'].extend(copy.deepcopy(temp)) # create an if cascade that assignes different strings to the varible 'PlateType' in iterations 1 to 8 like Muniz explained # NOTE : Momentum does not allow more than 8 iterations!!! # psr['process/steps'].insert(0, flow_iteration_assign('PlateType', [1,8], ['"A"', '"B"', '"C"', '"D"', '"E"', '"F"', '"G"', '"H"'])) # finally write the modified script to a file for Momentum to import #psr.toMomentumFile("example_momentum_worklist.txt") # Read a momentum process .mpr file and convert it into xmlutil psr = Momentum.readMomentum("components/momentum/templates/process/plAnalysis.mpr") xml = psr.asXML() xml = etree.tostring(objectify.fromstring(xml), pretty_print=True) print xml psr = Momentum.fromXML(xml) print psr.asMomentum()