1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| ''' Created on 2018-4-12 @author: kikita ''' from scripting import *
ce = CE()
def writeCGAlib(): cga = "/*Asset Library Loader : Generated by asset_lib.py*/\n version \"2014.0\"\n\n" cga += "Lot --> Geometries Textures" cga += "\n\nGeometries --> " for obj in ce.getObjectsFrom("/", ce.isFile, ce.withName("/Tutorial_10*/assets/*.obj")): cga += "\n\t t(2,0,0) Geometry(\""+obj+"\")" print obj cga += "\n\nTextures --> \n\ts(1,0,0) set(scope.tz,0) set(scope.ty,3) i(\"facades/xy-plane.obj\")" for jpg in ce.getObjectsFrom("/", ce.isFile, ce.withName("/Tutorial_10*/assets/*.jpg")): cga += "\n\tt(2,0,0) Texture(\""+jpg+"\")" cga += "\n\n Geometry(asset) --> s(1,0,0) i(asset) set(scope.ty,0) set(scope.tz,0)" cga += "\n\n Texture(asset) --> set(material.colormap, asset)" cgafile = ce.toFSPath("rules/asset_lib2.cga") CGA = open(cgafile, "w") CGA.write(cga) CGA.close() print "written file "+cgafile def assignAndGenerateLib(): object = ce.getObjectsFrom(ce.scene, ce.withName("'Lot2'")) ce.refreshWorkspace() ce.setRuleFile(object, "asset_lib2.cga") ce.setStartRule(object, "Lot") ce.generateModels(object) if __name__ == '__main__': writeCGAlib() assignAndGenerateLib()
|