4
$\begingroup$

I want to use the bevel-tool to add a face between two other faces. The bevel-tool should use the selected edge(s) as geometry.location is given via a selected edge.

This is what I have

This is what I have

This is what I want

This is what I want

Which bevel-tool should I use? http://www.blender.org/api/blender_python_api_2_75a_release/bmesh.ops.html?highlight=bmesh.ops.bevel#bmesh.ops.bevel or http://www.blender.org/api/blender_python_api_2_75a_release/bpy.ops.mesh.html?highlight=bpy.ops.mesh.bevel#bpy.ops.mesh.bevel

And how can I set a enum-value? I tried offset_type='OFFSET' but I get the error that int was expected.

Script:

import bpy, bmesh
from mathutils import Vector
obj = bpy.context.object
bm = bmesh.new()
bm.from_mesh(obj.data)
bm.verts.ensure_lookup_table()


selected_edge = None
for edge in bm.edges:
    if edge.select:
        selected_edge = edge
        print("edge", edge)


print("selected_edge", selected_edge)

bpy.ops.object.mode_set(mode='OBJECT') # only working in object mode
faces = bmesh.ops.bevel(bm,
                geom=[selected_edge],
                offset=0.2,
                offset_type='OFFSET',
                segments=1,
                profile=0.5,
                vertex_only=False,
                clamp_overlap=True,
                material=-1)

print("faces", faces)

bm.to_mesh(obj.data)
$\endgroup$
2
  • $\begingroup$ Question edited. $\endgroup$
    – Hamburml
    Commented Aug 10, 2015 at 16:06
  • 5
    $\begingroup$ Bmesh operators use integer constants instead of string enum keys. They are defined in the C code, and there's currently no other way than to find the definition in the C code and use the found values in the Python script. You may want to define some variables to make the numbers more descriptive. See here: developer.blender.org/diffusion/B/browse/master/source/blender/… $\endgroup$
    – CodeManX
    Commented Aug 11, 2015 at 0:03

2 Answers 2

3
$\begingroup$

enter image description here You can find out the answer to this in several ways. Here's what I did:

  1. Use the UI tool (mark the middle edge then press CtrlB to bevel).
  2. Go to the info panel (above the 3D view on the default layout), and open it up a little bit. Not always, but often, using the UI commands and operators will print out the command used in the info panel. Here we can see that the bpy.ops.mesh.bevel operator was used.
  3. To further explore this command and its documentation, open the python console. Type in:

    bpy.ops.mesh.bevel(

    Then press CtrlSpace to see the autocompleted documentation for this operator. In this case:

    bevel()
    bpy.ops.mesh.bevel(
        offset_type   = 'OFFSET',
        offset        = 0,
        segments      = 1,
        profile       = 0.5,
        vertex_only   = False,
        clamp_overlap = False,
        loop_slide    = True,
        material      = -1
    )
    

This shows you all the parameters and their defaults, you can then experiment with other values and search for this operator in the official docs to review any additional information you might need.

$\endgroup$
0
$\begingroup$

The parameter "geom" must be a list of edges AND their vertices, compare:

Beveling edges with varying number of segments (preferably programatically).

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .