Reading a variation table

import Atoms import AtomsCore variations = Atoms.loadVariationFromFile("C:\\maya\\projects\\default\\assets\\archer_cloth\\variations.json") #you can read also from a string with Atoms.loadVariationFromString agent_types = variations.getAgentTypeNames() for agent_type_name in agent_types: agent_variations = variations.getAgentTypeVariation(agent_type_name) # get all geos for geo_name in agent_variations.getGeometryNames(): geo_data = agent_variations.getGeometry(geo_name) geo_file = geo_data.getGeometryFile() geo_filter = geo_data.getGeometryFilter() print("Geometry: {} File: {} Filter: {}".format(geo_name, geo_file, geo_filter)) #get all materials for material_name in agent_variations.getMaterialNames(): material_data = agent_variations.getMaterial(material_name) material_file = material_data.getMaterialFile() print("Material: {} File: {}".format(material_name, material_file)) for diffuse_id in range(material_data.getDiffuseSlotSize()): diffuse_file = material_data.getDiffuseFile(diffuse_id) diffuse_color = material_data.getDiffuseColor(diffuse_id) print("\tDiffuse {} color {} {} {} File {}".format(diffuse_id, diffuse_color.getRed(), diffuse_color.getGreen(), diffuse_color.getBlue(), diffuse_file)) # iterate over each variation for variation_name in agent_variations.getGroupNames(): variation_group = agent_variations.getGroup(variation_name) print("Variation: {}".format(variation_name)) for comb_id in range(variation_group.numCombinations()): combination = variation_group.getCombinationAtIndex(comb_id) print("\tGeom: {} Material: {}".format(combination[0], combination[1])) #You need to modify the variation table and save to disk using #variations.writeToFile("C:\\maya\\projects\\default\\assets\\archer_cloth\\new_variations.json") #or use variations.toString() to serialize it to a string

 

Copyright © 2017, Toolchefs LTD.