bmesh exrude and faces color ?

if you let say make a new primitive mesh with bmesh and extrude then move / translate
you get new faces wih faces list i guess
now is there a way to directly change the color for the newly created faces

or how can you do it ?

thanks
happy bl

Couldn’t you assign a different material index to newly extruded faces? You would have to have the material slot populated with a valid material but it could work.

that would be afterward when the Bmesh is done
but i’m talking when your doing it before you finish the bmesh data if possible

cause then i got a problem to find which faces index !

also having a problem now to extrude only one edge with edge extrude
get error that it needs a list !

any idea how to correct that ?

thanks

error that it needs a list !
any idea how to correct that ?

Make it a list, e.g. [edge_ref]

that would be afterward when the Bmesh is done

When is a Bmesh “done”?
You can set the material_index property as soon as there’s a BMFace ref.

i began doing a square with verts and one face
i can list the edges but how do you make a list of edges

for f in bm.faces:

print(‘face=’,f)
for e in f.edges:
print(‘edge=’,e)
for v in e.verts:
print(‘vert=’,v,‘c0=’,v.co) --> this works fine

edges_start_a = bm.edges[0]

print (’ edge =’,edges_start_a)
print ()

ret = bmesh.ops.extrude_edge_only(
bm,
edges=edges_start_a)
geom_extrude_mid = ret[“geom”]

ect
as soon as it begins the extrude edges part i get an error ?

so something is worng with my list of edges

and at this stage is it possible to add color on face or have to wait till mesh data ia completely added
after doing the

me = bpy.data.meshes.new(named1)
bm.to_mesh(me)
bm.free()

part or even after adding ob to scene ?

did not find any command on wiki page to make face color !

may be with polygon settion but i’m not using that method here!

thanks

Dang 17,000+ posts and you still don’t use the code block…:confused:

i found edge problem

edges_start_a = [bm.edges[1]]
has to e a list of edge and not one edge alone

numbers are relative and Bmesh is still new and i dont’ use it everyday
doc is almost nill!
and i’m not a programmer just learning as i go along

what is a code block ?

thanks

at this stage is it possible to add color on face or have to wait till mesh data ia completely added

The bmesh is always “complete”, as it exists in memory. Turning it into a mesh datablock doesn’t make it complete. You can turn it into a mesh, link it to an object and scene to display it. But you could work in-memory and get rid of it without ever displaying it.

And yes, you can access material_index early.

import bmesh
bm=bmesh.new()
v1=bm.verts.new((1,2,3))
v2=bm.verts.new((3,2,3))
v3=bm.verts.new((3,6,3))
f=bm.faces.new((v1,v2,v3))
f.material_index = 2

i found edge problem

edges_start_a = [bm.edges[1]]
has to e a list of edge and not one edge alone

That’s what I told you…

what is a code block ?

This is a code block

Wrap your code like:

[ code]this, but remove the space in front of "code" [/ code]

fist of all code block

i tried the # and it does not seems to work anymore
so what is happenng with that ?

here is test


 
 
def Grunge1(matname1):   #  
 
 m1 = Material()
 m1.set_cycles()
 
 m1.make_material(matname1)
 
 xl1=-200
 
 
 materialOutput = m1.nodes['Material Output']
 materialOutput.location =400,0
 


2 - the faces color


 
f=bm.faces.new((v1,v2,v3))
f.material_index = 2




this seems to assign a color per index
but this means it already exist or not?

is it possible to add new mat with some colors while you still building the new mesh or only after ?

like for this case here i would like to extrude downward a line and scale to 0
so this would generate some faces and add a color
then take same lines verts and extrude upward then add a new color
to make like a rectangle with 2 colors

edit do you see first example for code block
it does not respect the indentation anymore
what is happening with this not working now !

thanks

does
    work
        with
            tabs

and
    spaces
        as well...

this seems to assign a color per index
but this means it already exist or not?

is it possible to add new mat with some colors while you still building the new mesh or only after ?

All it does is assign an int to the material_index property. It’s up to you add materials in an order, so that the index number of the bm matches the material you want. You can set the material_index right after faces.new(…).

code block
i found something you need something else also for it to work
have to be in



need to be in wysiwyg or source  mode  too
remove format does not work

not certain why this was change in my set up


so this si like only adding an index then mat will be assing as per index list !

thanks