""" import seamless from seamless import context, cell, pythoncell, transformer, reactor, \ macro, export from seamless.lib import link, edit, display from seamless.gui import shell ctx = context() """ import seamless from seamless import context, cell, transformer, reactor from seamless.lib import edit, display, link ctx = seamless.fromfile("test-sphere2.seamless") #KLUDGE; although file dominant, differences do not trigger a macro update... need to make a new test-sphere.seamless del ctx.subdivisions del ctx.edit.subdivisions del ctx.minimizations del ctx.edit.minimizations del ctx.gen_sphere del ctx.params.gen_sphere del ctx.links.params_gen_sphere del ctx.links.code_gen_sphere ctx.texture_coords = cell("array").set_store("GL") ctx.triangle_texture_coords = cell("array").set_store("GL") #for now, load-ply must be a reactor, because it has multiple outputs #TODO: make it a transformer in a future version of seamless c = ctx.params.load_ply = cell(("cson", "seamless", "reactor_params"))
""" import seamless from seamless import context, cell, pythoncell, transformer, reactor, \ macro, export from seamless.lib import link, edit, display from seamless.gui import shell ctx = context() """ import seamless from seamless import context, cell, transformer, reactor from seamless.lib import edit, display, link ctx = seamless.fromfile("test-sphere6.seamless") #KLUDGE; although file dominant, differences do not trigger a macro update... need to make a new test-sphere.seamless del ctx.subdivisions del ctx.edit.subdivisions del ctx.minimizations del ctx.edit.minimizations del ctx.gen_sphere del ctx.params.gen_sphere del ctx.links.params_gen_sphere del ctx.links.code_gen_sphere ctx.texture_coords = cell("array").set_store("GL") ctx.triangle_texture_coords = cell("array").set_store("GL")
"dtype": "int" }, "result": { "pin": "output", "dtype": "int" }, }) ctx.tf.code.cell().set("""print("evaluate!"); return value""") ctx.value.connect(ctx.tf.value) ctx.tf.result.connect(ctx.result) ctx.value.set(42) ctx.link_value = link(ctx.value, ".", "hashcache-value.txt") ctx.link_result = link(ctx.result, ".", "hashcache-result.txt", file_dominant=True) ctx.equilibrate() ctx.tofile("test-hashcache.seamless",backup=False) ctx = seamless.fromfile("test-hashcache.seamless") ctx.equilibrate() print(ctx.result.value) print("LOAD 1") ctx.destroy() ctx = seamless.fromfile("test-hashcache.seamless") ctx.equilibrate() print(ctx.result.value) #42, and no "evaluate!"" print("Changing result to 99...") ctx.destroy() open("hashcache-result.txt", "w").write("99") print("LOAD 2") ctx = seamless.fromfile("test-hashcache.seamless") print(ctx.result.value) #usually 99, sometimes 42 ctx.equilibrate() print(ctx.result.value) #42
import seamless f = "test-tofromfile.seamless" f2 = "test-tofromfile-reload.seamless" ctx = seamless.context() from seamless.core.macro import _macros _macros.clear() ctx = seamless.fromfile(f) ctx.equilibrate() c_output = ctx.cont.output.cell() print(c_output.data) ctx.cont.value.cell().set(10) ctx.equilibrate() print(c_output.data) ctx.cont.code.cell().set("return value**2") ctx.equilibrate() print(c_output.data) ctx.tofile(f2, backup=False) ctx = seamless.fromfile(f2) ctx.equilibrate() c_output = ctx.cont.output.cell() print(c_output.data) ctx.cont.code.cell().set("return value*2") ctx.equilibrate() print(c_output.data) ctx.cont.value.cell().set(4) ctx.equilibrate() print(c_output.data)
"pin": "output", "dtype": "int" }, }) ctx.tf.code.cell().set("""print("evaluate!"); return value""") ctx.value.connect(ctx.tf.value) ctx.tf.result.connect(ctx.result) ctx.value.set(42) ctx.link_value = link(ctx.value, ".", "hashcache-value.txt") ctx.link_result = link(ctx.result, ".", "hashcache-result.txt", file_dominant=True) ctx.equilibrate() ctx.tofile("test-hashcache.seamless", backup=False) ctx = seamless.fromfile("test-hashcache.seamless") ctx.equilibrate() print(ctx.result.value) print("LOAD 1") ctx.destroy() ctx = seamless.fromfile("test-hashcache.seamless") ctx.equilibrate() print(ctx.result.value) #42, and no "evaluate!"" print("Changing result to 99...") ctx.destroy() open("hashcache-result.txt", "w").write("99") print("LOAD 2") ctx = seamless.fromfile("test-hashcache.seamless") print(ctx.result.value) #usually 99, sometimes 42 ctx.equilibrate() print(ctx.result.value) #42