Created
May 16, 2022 00:30
-
-
Save CGArtPython/6e98beb424b6c58bbda0469b2c0434a9 to your computer and use it in GitHub Desktop.
Beginner Blender Python Exercise: Circle mesh from scratch (Part 1) https://www.youtube.com/watch?v=uOQ-CPcaqMo
This file contains 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
# give Python access to Blender's functionality | |
import bpy | |
# extend Python's math functionality | |
import math | |
# extend Python's print functionality | |
import pprint | |
# initialize paramaters | |
vert_count = 32 # show with 16 and 64 | |
angle_step = math.tau / vert_count | |
radius = 2 | |
# create a list of vert coordinates | |
vert_coordinates = list() | |
# repeat code in a loop | |
for i in range(vert_count): | |
# calculate current current_angle | |
current_angle = angle_step * i | |
# calculate coordinate | |
x = radius * math.cos(current_angle) | |
y = radius * math.sin(current_angle) | |
# visualize what we are doing | |
bpy.ops.mesh.primitive_ico_sphere_add(radius=0.05, location=(x, y, 0)) | |
# add current coordinate to list | |
vert_coordinates.append((x, y, 0)) | |
pprint.pprint(vert_coordinates) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment