I have the following simple script that draws a cube and color it in red.
import bpy
Create a red material
newMat = bpy.data.materials.new(name = "Material")
newMat.use_nodes = True
nodes = newMat.node_tree.nodes
material_output = nodes.get("Material Output")
node_emission = nodes.new(type="ShaderNodeBsdfDiffuse")
node_emission.inputs[0].default_value = (1,0,0,1)
links = newMat.node_tree.links
newLink = links.new(node_emission.outputs[0], material_output.inputs[0])
Create a cube and add the red material to it
bpy.ops.mesh.primitive_cube_add(location=[0,0,0], scale=[10,10,10])
bpy.context.object.data.materials.append(newMat)
When I export this to FBX with Path Mode = Copy and Embed Textures = True, I get an FBX that shows the uncolored cube; together with an error message in the console that says:
FBX export starting... 'Z:\\Workspace\\red-cube.fbx'
NO NODES!
export finished in 0.0000 sec.
I have read many other posts about the issue but being a novice in Blender I could not make much sense of them. It seems that the issue is related to "Principled BSDF" that is apparently missing from the above script.
How would I fix this script so that it exports both mesh and color?