#with all objects selected (assume they are all poly mesh with single face and flat) #go in iteration
for sel in selected: #get material color #convert value to just luminance #extrude face based on luminance value (between 0 and 1) #keep looping until all faces are extruded based on the color.
Ok, I am not 100% sure where I am going with this.
Basically I imagine if I could bring in some 2D vector Shapes generated procedurally using NodeBox 2 (it could be city blue print map). NodeBox exports out PDF, which can be converted into bunch of vector curve shapes (via Inkscape) into Blender. With those imported 2D Curves Shapes, I was again wondering if I could extrude them using script, just based on different Materials, perhaps their luminance.
@Atom, you are right, that’s also what I had in mind. @PKHG, I would think Luminance will just just the B in HSB color ring.
It would be a lot nicer of course to do everything inside Blender.
The most basic thing, for example I have 2D image on a plane. Would it be possible via scripting to sample color per UV into grid of cubes? I sort of able to do this in other 3D package (Houdini actually).
My 1st guess originally is: Blender Particles can sample color, but unfortunately the color does not get transferred into the Instance. Not sure if RE:Ticular add-on can sort of does this. Make instance alive and transfer each particle color into the instances.
Before getting too complicated, I think the question is:
If I have bunch of separate shapes with different Materials, I am wondering what kind of script helps to extrude each of those shapes based on the Material properties. Luminance or anything.
Is it tricky to script? It is more of curiosity than anything.
not tricky, this should extrude first face in its normal direction
import bpy
sce = bpy.context.scene
sel = [o for o in bpy.context.selected_objects if o.type == 'MESH']
for obj in sel:
# activate object
sce.objects.active = obj
if obj == sel[0]:
# set face selection mode once
bpy.ops.object.mode_set(mode='EDIT')
bpy.context.tool_settings.mesh_select_mode = [False, False, True]
bpy.ops.object.mode_set()
# select some face in object mode
for f in obj.data.faces: f.select = False
obj.data.faces[0].select = True
# get vector and hsv value
nor = obj.data.faces[0].normal
v = obj.data.materials[0].diffuse_color.hsv[2]
# go edit mode and extrude / translate first face along normal
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":nor * v * 5})
bpy.ops.object.mode_set()
sure, set the select faces line to True like this
for f in obj.data.faces: f.select = True
and delete: obj.data.faces[0].select = True as it is already selected
as svg imports as curves you can do similar script to extrude curves
btw, nodebox2 is big fun…
This is starting to get cool. Probably very basic, but nice start, I supposed.
OK, I should try to write similar script to extrude curves. At the moment, I will just use script I learned from PKHG to quickly convert all these Curves.
import bpy
bpy.ops.object.convert(target=‘MESH’)
Great, you tried NodeBox2! I am glad you also find it fun. I studied it for a while years ago, before I moved to Houdini. NodeBox2 has just been updated too and it has more development going now.