Hello Blender Community,
I'm working on automating the Vi-Suite light simulation with radiance workflow for a simple sphere scene with a fine mesh which I created manually. My goal is to programmatically create and link the required nodes (LiVi Context
, LiVi Geometry
, LiVi Simulation
, and VI CSV Export
) and then execute their respective operators (liexport
, ligexport
, livicalc
, and csvexport
) to complete the simulation and export the results
Steps Taken Programmatically:
- Node Creation and Linking: I've created and linked the nodes programmatically with the following Python function:
import bpy
import os
def create_vi_suite_node_structure():
# Enable the scene in the node
bpy.context.scene.use_nodes = True
# Creates node tree
ng = bpy.data.node_groups.new('simulation', 'ViN')
print("Node tree 'simulation' created.")
# VI Location Node
location_node = ng.nodes.new(type="No_Loc")
location_node.location = (0, 0)
location_node.loc = '0'
location_node.latitude = 48.0
location_node.longitude = 7.84
print("Location node created.")
# LiVi Geometry Node
geometry_node = ng.nodes.new(type="No_Li_Geo")
geometry_node.location = (230, 140)
geometry_node.cpoint = '0' # Set to '0' for faces or '1' for vertices
geometry_node.offset = 0.001
geometry_node.triangulate = True # Setting 'Triangulate' as checked
print("Geometry node created with parameters set.")
# LiVi Context Node
context_node = ng.nodes.new(type="No_Li_Con")
context_node.location = (210, -120)
context_node.contextmenu = 'Basic' # Set to 'Basic' or 'CBDM'
context_node.skyprog = '1' # Set to '0' (Gensky), '1' (Gendaylit), etc.
context_node.spectrummenu = '1' # Set to '0' (Visible) or '1' (Full)
context_node.epsilon = 0.3
context_node.delta = 0.15
context_node.gref = 0.0
context_node.gcol = (0.0, 1.0, 0.0) # Green color
context_node.shour = 12.0
context_node.sdoy = 172
context_node.animated = True
context_node.startframe = 0
context_node.endframe = 6 # Replace with appropriate frame number
context_node.ehour = 13.00
context_node.edoy = 172
context_node.interval = 0.19
context_node.hdr = False
print("Context node created with parameters set.")
# LiVi Simulation Node
simulation_node = ng.nodes.new(type="No_Li_Sim")
simulation_node.location = (410, 70)
simulation_node.simacc = '0' # Set accuracy level as string, e.g., '0' (Low)
simulation_node.startframe = 1 # Start frame
simulation_node.endframe = 1 # End frame
print("Simulation node created with parameters set.")
# VI CSV Export Node
export_node = ng.nodes.new(type="No_CSV")
export_node.location = (610, 0)
print("Export node created.")
# Linking the nodes
ng.links.new(location_node.outputs[0], context_node.inputs[0])
ng.links.new(geometry_node.outputs[0], simulation_node.inputs[0])
ng.links.new(context_node.outputs[0], simulation_node.inputs[1])
ng.links.new(simulation_node.outputs[0], export_node.inputs[0])
print("Nodes linked.")
return ng, context_node, geometry_node, simulation_node, export_node
# Save the project
bpy.ops.wm.save_as_mainfile(filepath=myfilepath, myfilename)
print("Blender project saved.")
Where the problem lies
I am attempting to programmatically export the LiVi Geometry node, as shown in the attached image below, using the bpy.ops.node.ligexport()
function. The goal is to pass the geometry data from this node to the LiVi Simulation node for further processing in an automated workflow.
- Overrides and Operator Execution: To export nodes and run simulations, I used the following override structure, based on community advice and simply here summarized code :
override = {'node': context_node}
bpy.ops.node.liexport(override, 'EXEC_DEFAULT') # Context export
override['node'] = geometry_node
bpy.ops.node.ligexport(override, 'EXEC_DEFAULT') # Geometry export
override['node'] = simulation_node
bpy.ops.node.livicalc(override, 'EXEC_DEFAULT') # Simulation
override['node'] = export_node
bpy.ops.node.csvexport(override, 'EXEC_DEFAULT') # CSV Export
i refined and adjusted the code for debugging purposes
return ng, context_node, geometry_node, simulation_node, export_node
# Create and link the nodes
node_tree, context_node, geometry_node, simulation_node, export_node = create_vi_suite_node_structure()
# Save the project
bpy.ops.wm.save_as_mainfile(filepath=filepath and file name)
print("Info: Saved 'sphere automation.blend'")
# Perform Context Export
override = {'node': context_node}
print(f"Override for Context Export: {override}")
bpy.ops.node.liexport(override, 'EXEC_DEFAULT')
print("Context export completed.")
# Perform Geometry Export
override = {'node': geometry_node}
print(f"Override for Geometry Export: {override}")
bpy.ops.node.ligexport(override, 'EXEC_DEFAULT')
print("Geometry export completed.")
# Perform Simulation
override = {'node': simulation_node}
print(f"Override for Simulation: {override}")
bpy.ops.node.livicalc(override, 'EXEC_DEFAULT')
print("Simulation calculation completed.")
# Export CSV Results
override = {'node': export_node}
print(f"Override for CSV Export: {override}")
bpy.ops.node.csvexport(override, 'EXEC_DEFAULT')
print(f"Results exported to: {export_node.file}")
I also attempted using INVOKE_DEFAULT
instead of EXEC_DEFAULT
, but the same error persists.
Questions
Why does the
error 1-2 args execution context is supported
occur when using operators such asbpy.ops.node.liexport
,bpy.ops.node.ligexport
,bpy.ops.node.livicalc
, andbpy.ops.node.csvexport
in the script?How can this issue be resolved for both
EXEC_DEFAULT
andINVOKE_DEFAULT
contexts? also, Are there additional parameters required in the override context to make these operators work programmatically?Where can I find scripting documentation for the Vi-Suite add-on?
If anyone has successfully automated the Vi-Suite workflow, could you share insights or examples for your approach?
Your assistance in resolving these issues would be greatly appreciated, as it will help me successfully automate this workflow and wrap up my project faster. Thank you in advance for your insights and support!