def make_cristae(name='Cristae', loc=(0, 0, 0), scale=(0.1, 1, 1), loop_cut_scale_val=2.4): # Initial box cristae = geom.box(loc=loc, scale=(0.1, 1, 1), name=name) # Loop cut on front face 2x horizontally and vertically face = getPolygonByNormal(cristae, Vector((1, 0, 0))) edit.loop_cut(getEdgeForFaceAtIndex(cristae, face, 0).index, 2) bpy.ops.transform.resize(value=(1, cristae_disc_loop_cut_scale_val, 1)) edit.loop_cut(getEdgeForFaceAtIndex(cristae, face, 1).index, 2) bpy.ops.transform.resize(value=(1, 1, cristae_disc_loop_cut_scale_val)) # Subdivision surface 4x modifiers.subsurf(4) # Set base material setMaterial(cristae, makeMaterial('Cristae.Base', (1, 1, 1), (1, 1, 1), 1)) selectVerticesAndAssignMaterial( cristae, 'Cristae.Pinch', {'y': { 'lt': -0.89 }}, makeMaterial('Cristae.Pinch', (1, 0, 0), (1, 1, 1), 1)) selectVerticesAndAssignMaterial( cristae, 'Cristae.Wall', {'y': { 'gte': -0.91 }}, makeMaterial('Cristae.Wall', (0, 0, 1), (1, 1, 1), 1)) setMode('OBJECT')
def make_cristae(name='Cristae', loc=(0, 0, 0), scale=(0.1, 1, 1), side='right', loop_cut_scale_val=2.4, subsurf_level=2): # Initial box cristae = geom.box(loc=loc, scale=scale, name=name) # Loop cut on front face 2x horizontally and vertically face = getPolygonByNormal(cristae, Vector((1, 0, 0))) edit.loop_cut(getEdgeForFaceAtIndex(cristae, face, 0).index, 2) bpy.ops.transform.resize(value=(1, loop_cut_scale_val, 1)) edit.loop_cut(getEdgeForFaceAtIndex(cristae, face, 1).index, 2) bpy.ops.transform.resize(value=(1, 1, loop_cut_scale_val)) # Subdivision surface modifiers.subsurf(subsurf_level) # Set base material setMaterial(cristae, makeMaterial('Membrane.Inner.Base', (1, 1, 1), (1, 1, 1), 1)) # TODO figure out what these numbers should be procedurally # was 0.89, 0.91 with 4x subdiv. pinchThreshold = 0.90 wallThreshold = 0.95 if side == 'right': selectVerticesAndAssignMaterial( cristae, 'Membrane.Inner.Pinch', {'y': { 'lt': -pinchThreshold }}, makeMaterial('Membrane.Inner.Pinch', (1, 0, 0), (1, 1, 1), 1)) selectVerticesAndAssignMaterial( cristae, 'Membrane.Inner.Wall', {'y': { 'gte': -wallThreshold }}, makeMaterial('Membrane.Inner.Wall', (0, 0, 1), (1, 1, 1), 1)) elif side == 'left': selectVerticesAndAssignMaterial( cristae, 'Membrane.Inner.Pinch', {'y': { 'gte': pinchThreshold }}, makeMaterial('Membrane.Inner.Pinch', (1, 0, 0), (1, 1, 1), 1)) selectVerticesAndAssignMaterial( cristae, 'Membrane.Inner.Wall', {'y': { 'lt': wallThreshold }}, makeMaterial('Membrane.Inner.Wall', (0, 0, 1), (1, 1, 1), 1)) setMode('OBJECT')
def make_cristae(name='Cristae', loc=(0,0,0), scale=(0.1, 1, 1), side='right', loop_cut_scale_val=2.4, subsurf_level=2): # Initial box cristae = geom.box(loc=loc, scale=scale, name=name) # Loop cut on front face 2x horizontally and vertically face = getPolygonByNormal(cristae, Vector((1, 0, 0))) edit.loop_cut(getEdgeForFaceAtIndex(cristae, face, 0).index, 2) bpy.ops.transform.resize(value=(1, loop_cut_scale_val, 1)) edit.loop_cut(getEdgeForFaceAtIndex(cristae, face, 1).index, 2) bpy.ops.transform.resize(value=(1, 1, loop_cut_scale_val)) # Subdivision surface modifiers.subsurf(subsurf_level) # Set base material setMaterial(cristae, makeMaterial('Membrane.Inner.Base', (1,1,1), (1,1,1), 1)) # TODO figure out what these numbers should be procedurally # was 0.89, 0.91 with 4x subdiv. pinchThreshold = 0.90 wallThreshold = 0.95 if side == 'right': selectVerticesAndAssignMaterial(cristae, 'Membrane.Inner.Pinch', {'y': {'lt': -pinchThreshold}}, makeMaterial('Membrane.Inner.Pinch', (1,0,0), (1,1,1), 1)) selectVerticesAndAssignMaterial(cristae, 'Membrane.Inner.Wall', {'y': {'gte': -wallThreshold}}, makeMaterial('Membrane.Inner.Wall', (0,0,1), (1,1,1), 1)) elif side == 'left': selectVerticesAndAssignMaterial(cristae, 'Membrane.Inner.Pinch', {'y': {'gte': pinchThreshold}}, makeMaterial('Membrane.Inner.Pinch', (1,0,0), (1,1,1), 1)) selectVerticesAndAssignMaterial(cristae, 'Membrane.Inner.Wall', {'y': {'lt': wallThreshold}}, makeMaterial('Membrane.Inner.Wall', (0,0,1), (1,1,1), 1)) setMode('OBJECT')
def create_line(x=0, y=0, z=0): #палка будет красной material = makeMaterial('Red', (1, 0, 0), (1, 1, 1), 1) name_list = create_cube_line(4, x, y, z, material) #снимаем отметку со всех элементов bpy.ops.object.select_all(action='TOGGLE') #выделяем нужные кубы по имени select_by_names(name_list) bpy.ops.object.join()
def create_cross(x=0, y=0, z=0): material = makeMaterial('Green', (0, 1, 0), (1, 1, 1), 1) #сначала создаем палку из 3-х кубов name_list = create_cube_line(3, x, y, z, material) #добавляем куб по середине cube = create_simple_cube((x + 2, y - 2, z)) name_list.append(cube.name) setMaterial(cube, material) #снимаем отметку со всех элементов bpy.ops.object.select_all(action='TOGGLE') #выделяем нужные кубы по имени select_by_names(name_list) bpy.ops.object.join()
def make_cristae(name='Cristae', loc=(0,0,0), scale=(0.1, 1, 1), loop_cut_scale_val=2.4): # Initial box cristae = geom.box(loc=loc, scale=(0.1, 1, 1), name=name) # Loop cut on front face 2x horizontally and vertically face = getPolygonByNormal(cristae, Vector((1, 0, 0))) edit.loop_cut(getEdgeForFaceAtIndex(cristae, face, 0).index, 2) bpy.ops.transform.resize(value=(1, cristae_disc_loop_cut_scale_val, 1)) edit.loop_cut(getEdgeForFaceAtIndex(cristae, face, 1).index, 2) bpy.ops.transform.resize(value=(1, 1, cristae_disc_loop_cut_scale_val)) # Subdivision surface 4x modifiers.subsurf(4) # Set base material setMaterial(cristae, makeMaterial('Cristae.Base', (1,1,1), (1,1,1), 1)) selectVerticesAndAssignMaterial(cristae, 'Cristae.Pinch', {'y': {'lt': -0.89}}, makeMaterial('Cristae.Pinch', (1,0,0), (1,1,1), 1)) selectVerticesAndAssignMaterial(cristae, 'Cristae.Wall', {'y': {'gte': -0.91}}, makeMaterial('Cristae.Wall', (0,0,1), (1,1,1), 1)) setMode('OBJECT')
def create_g_l(x=0, y=0, z=0): #фиолетовая material = makeMaterial('Violet', (1, 0, 1), (1, 1, 1), 1) #сначала создаем палку из 3-х кубов name_list = create_cube_line(3, x, y, z, material) #добавляем куб слева cube = create_simple_cube((x, y - 2, z)) name_list.append(cube.name) setMaterial(cube, material) #снимаем отметку со всех элементов bpy.ops.object.select_all(action='TOGGLE') #выделяем нужные кубы по имени select_by_names(name_list) bpy.ops.object.join()
def make_membranes(scale, loc=(0,0,0)): geom.box(loc, scale, name='Membrane') modifiers.subsurf(4) modifiers.solidify(0, 0.04) # Seperate Inner and Outer membrane bpy.ops.mesh.separate(type='LOOSE') # Rename bpy.data.objects['Membrane'].name = 'Inner-Membrane' bpy.data.objects['Membrane.001'].name = 'Outer-Membrane' # Materialize Outer-Membrane setMaterial(bpy.data.objects['Outer-Membrane'], makeMaterial('Membrane.Outer', (0,1,0), (1,1,1), 1))
def make_membranes(scale, loc=(0, 0, 0)): geom.box(loc, scale, name='Membrane') modifiers.subsurf(4) modifiers.solidify(0, 0.04) # Seperate Inner and Outer membrane bpy.ops.mesh.separate(type='LOOSE') # Rename bpy.data.objects['Membrane'].name = 'Inner-Membrane' bpy.data.objects['Membrane.001'].name = 'Outer-Membrane' # Materialize Outer-Membrane setMaterial(bpy.data.objects['Outer-Membrane'], makeMaterial('Membrane.Outer', (0, 1, 0), (1, 1, 1), 1))
def create_cube4(x=0, y=0, z=0): name_list = [] #фиолетовая material = makeMaterial('Blue', (0, 0, 1), (1, 1, 1), 1) cube = create_simple_cube((x, y, z)) name_list.append(cube.name) setMaterial(cube, material) cube = create_simple_cube((x + 2, y, z)) name_list.append(cube.name) setMaterial(cube, material) cube = create_simple_cube((x, y + 2, z)) name_list.append(cube.name) setMaterial(cube, material) cube = create_simple_cube((x + 2, y + 2, z)) name_list.append(cube.name) setMaterial(cube, material) #снимаем отметку со всех элементов bpy.ops.object.select_all(action='TOGGLE') #выделяем нужные кубы по имени select_by_names(name_list) bpy.ops.object.join()
def create_z2(x=0, y=0, z=0): #светло голубая name_list = [] material = makeMaterial('ligth blue2', (0, 0.5, 1), (1, 1, 1), 1) cube = create_simple_cube((x + 2, y, z)) name_list.append(cube.name) setMaterial(cube, material) cube = create_simple_cube((x + 4, y, z)) name_list.append(cube.name) setMaterial(cube, material) cube = create_simple_cube((x + 2, y + 2, z)) name_list.append(cube.name) setMaterial(cube, material) cube = create_simple_cube((x, y + 2, z)) name_list.append(cube.name) setMaterial(cube, material) #снимаем отметку со всех элементов bpy.ops.object.select_all(action='TOGGLE') #выделяем нужные кубы по имени select_by_names(name_list) bpy.ops.object.join()