A tutorial series about creating art with Blender Python scripts
cgartpython / blender_plus_python Goto Github PK
View Code? Open in Web Editor NEWA tutorial series about creating art with Blender Python scripts
License: MIT License
A tutorial series about creating art with Blender Python scripts
License: MIT License
A tutorial series about creating art with Blender Python scripts
with Weave project files 'weave_start.py' and 'weave_done.py' :
running scripts on Blender v4.0.2 causes:
File ".../weave_done.py",
line 307, in create_emissive_material
KeyError: 'bpy_prop_collection[key]: key "Emission" not found'
code currently reads:
307 material.node_tree.nodes["Principled BSDF"].inputs["Emission"].default_value = color
changing the input name to "Emission Color" fixes this error
307 material.node_tree.nodes["Principled BSDF"].inputs["Emission Color"].default_value = color
typos in the file :
subdivided_triangulated_cube_part_1_start.py
line 19 :
... see this from more
-> ... see this for more
line 47 :
... make sure non of
-> ... make sure none of
thx for sharing
have fun
aum
Do you know why the left side of the monkey's left eye is always black after running this code? Didn't I replace the color of 500 faces?
The sequence_editor_stitched_together_clips_done.py works when I paste the code in GUI, have the Video Editor open and hit run. When layout is open or when or running from command-line using blender.exe -b -P sequence_editor_stitched_together_clips_done.py
, it gives this error:
File "C:\myProjects\myBlender\sequence_editor_stitched_together_clips_done.py", line 91, in create_transition_between_videos bpy.ops.sequencer.movie_strip_add( File "C:\Program Files\Blender Foundation\Blender 3.4\3.4\scripts\modules\bpy\ops.py", line 111, in __call__ ret = _op_call(self.idname_py(), C_dict, kw, C_exec, C_undo) RuntimeError: Operator bpy.ops.sequencer.movie_strip_add.poll() failed, context is incorrect
How can I modify the code to avoid this. In other words, how can I choose the Video Editor context inside the code.
(I'm using Blender 3.4)
import bpy
import bmesh
import random as rnd
def deleteall():
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False, confirm=False)
for m in bpy.data.materials:
bpy.data.materials.remove(m)
def RndColor():
return [rnd.uniform(0,1.0),rnd.uniform(0,1.0),rnd.uniform(0,1.0),1.0]
def SetMaterial(obj,color):
material = bpy.data.materials.new(name=f'rnd color material') # maybe repeated
material.use_nodes = True
#rnd_material.diffuse_color = RndColor()
#bpy.data.materials[rnd_material.name].node_tree.nodes["Emission"].inputs[0].default_value = (0.0441256, 0.57093, 1, 1)
material.node_tree.nodes["Principled BSDF"].inputs["Metallic"].default_value = rnd.uniform(0,1)
material.node_tree.nodes["Principled BSDF"].inputs["Roughness"].default_value = rnd.uniform(0,1)
material.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = color
obj.data.materials.append(material)
def go_1():
deleteall()
a = []
for _ in range(9):
x = rnd.uniform(-5,5)
y = rnd.uniform(-5,5)
z = rnd.uniform(-5,5)
a.append([x,y,z])
print(x,y,z)
for aa in a:
if aa[2] <= -2:
bpy.ops.mesh.primitive_ico_sphere_add(radius=1, location=[aa[0],aa[1],aa[2]])
elif aa[2] > -2 and aa[2] <= 1:
bpy.ops.mesh.primitive_cube_add(size=1,location=[aa[0],aa[1],aa[2]])
else:
bpy.ops.mesh.primitive_cone_add(location=[aa[0],aa[1],aa[2]])
obj = bpy.context.active_object
SetMaterial(obj,RndColor())
cubes = []
for obj in bpy.data.objects:
if "Cube" in obj.name:
cubes.append(obj)
for cube in cubes:
location = cube.location
bpy.data.objects.remove(cube)
bpy.ops.mesh.primitive_monkey_add(location=location)
obj = bpy.context.active_object
SetMaterial(obj,RndColor())
#----------------------------------------------------------------------------------------
if name == "main":
go_1()
several project startup files have errors in Blender v4.0, as with Weave, for example:
.../weave_done.py", line 209, in set_scene_props
TypeError: bpy_struct:
item.attr = val: enum "Very High Contrast"
not found in (..., 'AgX - Very High Contrast', 'AgX - High Contrast', ...)
this is fixed by changing
209 scene.view_settings.look = "Very High Contrast"
to
209 scene.view_settings.look = "AgX - Very High Contrast"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.