3
$\begingroup$

I'm trying to subdivide a cube at different intervals depending on the length, for example, if I make a 1x1x2 cube and subdivide it, it becomes 8 sections vertically (which is what I want) but also 8 horizontally (bad) I would like it to be 8 vertically and 4 horizontally. Now I can get around this by taking a 1x1x1 cube and subdividing it to have 4x4 segments, and copy pasting another one above to get the desired result, but I'm wondering if there is a better way to do it so I don't have to copy and past each correct block? So I could take a 1x1x2 block and say divide it by 8 on the z axis but only 4 on the x and y? Thank you for your help

The incorrect amount of subdivisions, requires much more clicking to do what I want, but doesn't require copy pasting enter image description here

The correct amount of subdivisions, but requires copy pasting and seems inefficiententer image description here

$\endgroup$
4
$\begingroup$

Use Loop Cuts (Ctrl+R)

Position the mouse to select the axis,

Using the Mouse Wheel you can control how many subdivisions you want on each axis.

enter image description here

$\endgroup$
  • $\begingroup$ Thank you! Great explanation, still a beginner and trying to figure all this out. Thank you for your response. $\endgroup$ – Joel Banks Mar 3 '18 at 3:00
2
$\begingroup$

My solution might be a smidge impractical but once I started, I couldn't stop and after a creative fever, I managed to make a magic cube out of Array Modifiers:

cube xyz anim

all the parts

I took a cube, scaled it to one Blender Unit and removed 5 faces. Any object you see, except Hronkar, is a single quad, rotation and scale applied, one unit in length with the Object Origin usually half a Blender Unit away. Where exactly the Object Origin had to be was trial and error. Notice the funny offset location of part 3.

relative location of the planes

Blender has this weird pseudobug which causes drivers to lag a frame behind when they refer to themselves. That's why I gave Hronkar the tyrant 3 custom properties name X, Y and Z. They determine the dimensions of the magic cube in Blender Units and drive all the arrays.

Here are all the array modifiers. I named them after the objects and by which axis they're driven. X=3, Y=4, Z=5. The start- and end caps make this possible.

Bosscube:

bosscube array modifier settings

Part 1:

part 1 array modifier settings

Part 2:

part 2 array modifier settings

Part 3:

part 3 array modifier settings

Part 4:

part 4 array modifier settings

Part 5:

part 5 array modifier settings

This is one example of the drivers. Single property, Hronkar as the source and a single roperty in square brackets.

drivers

It's a bit confusing, I agree. A bit gaga, but, by entering Y, Y and Z values into Hronkars custom props you can create a cube that is made of evenly spaced quads. And it's a watertight mesh, not a bunch of stacked cubes.

3 values to rule them all

All you have to do is start with six planes left from a cube, attach the modifiers as shown and move the object origin around. Once you have managed to set it up, better make 5 independent backups. You might not be able to recreate it, ever.

In order to turn it into a regular mesh, one just has to copy it and apply two modifiers.

$\endgroup$
1
$\begingroup$

Approach based on Subdivide operator means selecting those edges which compose an edge ring in the direction you want to subdivide. So if subdividing vertically you select top and bottom edges, if horizontally - side edges:

enter gif description here

Note that to subdivide side of the cube like in example which already was subdivided you need to select whole edge ring in order crossing subdivision to cut through it:

enter gif description here

Otherwise it will subdivide only face which shares selected edges.
This is destructive approach which changes mesh geometry so make sure you have either backup or some copy of the object to not change it in a way you didn't mean to.

$\endgroup$
1
$\begingroup$

Add Cuboid Addon

If you know you want to add a 3 x 4 x 5 subdivided cuboid, it might be easier to set this when the object is created, rather than have to add a cube and then go thru the rigmarole of subdividing on each axis.

Here's a script based on the text editor > templates > python > Addon Add Object example in blender. Adds a cube with bmesh, and subdivides it into dimensions.

enter image description here

Example of adding cuboid in edit mode (pretty crappy gif)`

bl_info = {
    "name": "Add Cuboid",
    "author": "batFINGER",
    "version": (1, 0),
    "blender": (2, 75, 0),
    "location": "View3D > Add > Mesh > Add Cuboid",
    "description": "Adds a Cuboid",
    "warning": "",
    "wiki_url": "",
    "category": "Add Mesh",
    }

import bpy
import bmesh
from bpy.types import Operator
from bpy.props import FloatVectorProperty, IntVectorProperty
from bpy_extras.object_utils import AddObjectHelper, object_data_add

from mathutils import Matrix

def add_object(self, context):
    bm = bmesh.new()
    mesh = bpy.data.meshes.new(name="Cuboid")
    S = Matrix.Scale(1, 4)
    for i in range(3):
        S[i][i] = self.scale[i] * self.dimensions[i]
    bmesh.ops.create_cube(bm, size=1, matrix=S)

    #bm.edges.ensure_lookup_table()
    axes = [axis for axis in Matrix().to_3x3()]

    for cuts, axis in zip(self.dimensions, axes):
        def aligned(e):
            dir = (e.verts[1].co - e.verts[0].co).normalized()
            return abs(dir.dot(axis)) > 0.5
        if cuts == 1:
            continue
        bmesh.ops.subdivide_edges(bm,
            edges=[e for e in bm.edges if aligned(e)],
            use_grid_fill=True,
            cuts=cuts - 1)    
    for v in bm.verts:
        v.select = True
    bm.select_flush(True)
    bm.to_mesh(mesh)
    #mesh.update()
    object_data_add(context, mesh, operator=self)
    bm.free()
    if context.edit_object:
        mesh = context.edit_object.data
        bmesh.from_edit_mesh(mesh)
        bmesh.update_edit_mesh(mesh)

class OBJECT_OT_add_cuboid(Operator, AddObjectHelper):
    """Create a subdivided by dimension cuboid"""
    bl_idname = "mesh.add_cuboid"
    bl_label = "Add Cuboid"
    bl_options = {'REGISTER', 'UNDO'}

    dimensions = IntVectorProperty(
            name="Dimensions",
            default=(1, 1, 1),
            description="Width(x) x Breadth(y) x Height(z)",
            min=1,
            max=20
            )    
    scale = FloatVectorProperty(
            name="scale",
            default=(1.0, 1.0, 1.0),
            subtype='TRANSLATION',
            description="scaling",
            )

    def execute(self, context):
        add_object(self, context)
        return {'FINISHED'}

# Registration

def add_object_button(self, context):
    self.layout.operator(
        OBJECT_OT_add_cuboid.bl_idname,
        text="Add Cuboid",
        icon='MESH_CUBE')

def register():
    bpy.utils.register_class(OBJECT_OT_add_cuboid)
    bpy.types.INFO_MT_mesh_add.append(add_object_button)

def unregister():
    bpy.utils.unregister_class(OBJECT_OT_add_object)
    bpy.utils.unregister_manual_map(add_object_manual_map)
    bpy.types.INFO_MT_mesh_add.remove(add_object_button)

if __name__ == "__main__":
    register()
    # test call
    bpy.ops.mesh.add_cuboid(dimensions=(3, 4, 5))

EDIT. Change axis test on edges to a simple dot product. Using bmesh.ops.similar_edges(...) becomes unreliable when scrubbing props in operator panel. New mesh vertices are selected in edit mode.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.