I have been plugging away at this for a couple days without any real progress. I am creating a series of cubes in Blender which I need to all have beveled bottom edges (see image) I was able to easily do this in CAD but this is kicking my butt in Blender. I have tried programmatically selecting the bottom vertices and creating a vertex group, however none of my attempts have resulted in a vertex group being created, and when it has been created the vertex groups end up being empty for some reason. The following script is what I am using to create this cube.
numberSpaces = 3 baseWidth = 32.25 wallThickness = 7 wallLength = baseWidth + wallThickness tolerance = 0.2 floorHeight = 2.5 wallHeight = 25.75 brickLength = 10 brickHeight = 5 groutSpacing = 0.5 #Createe Base Geometry #Insertion Base # Add a basic cube to the scene # Add a basic cube to the scene def create_base_geometry(): bpy.ops.mesh.primitive_cube_add() bpy.context.object.name = "Base Geometry Cube" cube = bpy.context.object # set scale and location of the cube cube.scale = (numberSpaces * (baseWidth + wallThickness)/2, wallThickness/2 - tolerance, floorHeight/2) cube.location = (numberSpaces * (baseWidth + wallThickness) / 2, 0, floorHeight/2) # Select the cube object by name cube_object = bpy.data.objects["Base Geometry Cube"] # Get the active object obj = bpy.context.active_object # Switch to edit mode bpy.ops.object.mode_set(mode='EDIT') # Deselect all vertices and faces bpy.ops.mesh.select_all(action='DESELECT') # Select the bottom face of the cube for face in obj.data.polygons: if face.normal.z == -1.0: face.select = True # Create a new vertex group for the selected face group_name = "Bottom Face" group_index = obj.vertex_groups.new(name=group_name) bpy.ops.object.vertex_group_assign() # Switch back to object mode bpy.ops.object.mode_set(mode='OBJECT')
This creates the geometry, however I am unable to script-select the bottom vertices (I could do it manually but I would like this all to be scripted). I have the current selection criteria shown just to show what I have been trying, though there have been numerous incarnations of this and none of them have worked.
I followed This example however at the end of that script, although the selection claims to be created in the console the face/vertices are not selected in the UI, nor does the vertex group cretion menu allow me to create a new group from the selected vertices.