Created
June 3, 2015 11:25
-
-
Save anonymous/66fc4ba106fce581b21b to your computer and use it in GitHub Desktop.
random_tubes_2015_06_03_13-25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
import random | |
def deselect(bm): | |
for f in bm.faces: | |
f.select = False | |
def pick_two_random_faces(bm): | |
for i in random.sample(range(len(bm.faces)), 2): | |
bm.faces[i].select = True | |
# Get the active mesh | |
obj = bpy.context.edit_object | |
me = obj.data | |
# Get a BMesh representation | |
bm = bmesh.from_edit_mesh(me) | |
bm.faces.ensure_lookup_table() | |
bm.faces.active = None | |
deselect(bm) | |
for i in range(10): | |
pick_two_random_faces(bm) | |
bpy.ops.mesh.add_curvebased_tube(main_scale=0.3) | |
deselect(bm) | |
# Show the updates in the viewport | |
# and recalculate n-gon tessellation. | |
bmesh.update_edit_mesh(me, True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment