Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

Certainly!

You can use the following Python script in Blender's text editor to create a simple animation
of the word "Ziggurat" rotating and spinning for one minute:

```python

import bpy

from math import radians

from bpy import context as C

# Create text object

bpy.ops.object.text_add(enter_editmode=False, align='WORLD', location=(0, 0, 0))

text_obj = bpy.context.active_object

text_obj.data.body = "Ziggurat"

# Set keyframes for rotation and spin

text_obj.rotation_euler = (0, 0, 0)

text_obj.keyframe_insert(data_path="rotation_euler", frame=1)

text_obj.rotation_euler = (0, 0, radians(360))

text_obj.keyframe_insert(data_path="rotation_euler", frame=250) # Adjust frame count as needed

# Set up spinning animation

bpy.ops.transform.rotate(value=radians(360), orient_axis='Z')

text_obj.keyframe_insert(data_path="rotation_euler", frame=1)

text_obj.rotation_euler = (0, 0, 0)

text_obj.keyframe_insert(data_path="rotation_euler", frame=250) # Adjust frame count as needed


```

Copy and paste this code into Blender's text editor. You can adjust the frame count and other
parameters as needed. To run the script, click the "Run Script" button in the text editor or use the Alt+P
shortcut. This script creates a text object with the word "Ziggurat" and animates it by rotating and
spinning over the specified frame range.

Certainly! Here's an updated Python script that includes setting the word color to blue, adjusting the
camera, and making the animation more visually appealing:

```python

import bpy

from math import radians

# Clear existing mesh objects

bpy.ops.object.select_all(action='DESELECT')

bpy.ops.object.select_by_type(type='MESH')

bpy.ops.object.delete()

# Create text object

bpy.ops.object.text_add(enter_editmode=False, align='WORLD', location=(0, 0, 0))

text_obj = bpy.context.active_object

text_obj.data.body = "Ziggurat"

# Set text material to blue

material = bpy.data.materials.new(name="BlueMaterial")

material.diffuse_color = (0, 0, 1, 1) # RGB values, last is alpha (transparency)


text_obj.data.materials.append(material)

# Set keyframes for rotation and spin

text_obj.rotation_euler = (0, 0, 0)

text_obj.keyframe_insert(data_path="rotation_euler", frame=1)

text_obj.rotation_euler = (0, 0, radians(360))

text_obj.keyframe_insert(data_path="rotation_euler", frame=250) # Adjust frame count as needed

# Set up spinning animation

bpy.ops.transform.rotate(value=radians(360), orient_axis='Z')

text_obj.keyframe_insert(data_path="rotation_euler", frame=1)

text_obj.rotation_euler = (0, 0, 0)

text_obj.keyframe_insert(data_path="rotation_euler", frame=250) # Adjust frame count as needed

# Set up camera

bpy.ops.object.camera_add(enter_editmode=False, align='WORLD', location=(0, -10, 5),


rotation=(radians(60), 0, radians(45)))

camera = bpy.context.active_object

bpy.ops.object.select_all(action='DESELECT')

camera.select_set(True)

bpy.context.view_layer.objects.active = camera

# Set keyframes for camera animation

camera.location = (0, -10, 5)


camera.rotation_euler = (radians(60), 0, radians(45))

camera.keyframe_insert(data_path="location", frame=1)

camera.keyframe_insert(data_path="rotation_euler", frame=1)

camera.location = (0, -10, 10)

camera.rotation_euler = (radians(45), 0, radians(45))

camera.keyframe_insert(data_path="location", frame=250) # Adjust frame count as needed

camera.keyframe_insert(data_path="rotation_euler", frame=250) # Adjust frame count as needed

```

This script creates a blue material for the text, adjusts the camera position and rotation, and sets
keyframes for both the text and the camera to create an attractive animation. Adjust the frame count
and other parameters as needed.

import bpy

# Create a cube as a simple example

bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, align='WORLD', location=(0, 0, 0))

# Get a reference to the created cube

cube = bpy.context.active_object

# Modify the cube's geometry (this is a basic example)

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.transform.translate(value=(0, 0, 1))

bpy.ops.object.mode_set(mode='OBJECT')
# Example of applying a subdivision surface modifier for smoother geometry

subsurf = cube.modifiers.new(name="Subdivision Surface", type='SUBSURF')

subsurf.levels = 3

subsurf.render_levels = 3

import bpy

import random

from math import radians

# Clear existing mesh objects and materials

bpy.ops.object.select_all(action='DESELECT')

bpy.ops.object.select_by_type(type='MESH')

bpy.ops.object.delete()

bpy.ops.object.select_by_type(type='MATERIAL')

bpy.ops.object.material_slot_remove()

# Create text object

bpy.ops.object.text_add(enter_editmode=False, align='WORLD', location=(0, 0, 0))

text_obj = bpy.context.active_object

text_obj.data.body = "Ziggurat"

# Set text material to blue

material = bpy.data.materials.new(name="BlueMaterial")
material.diffuse_color = (0, 0, 1, 1) # RGB values, last is alpha (transparency)

text_obj.data.materials.append(material)

# Set up keyframes for rotation

text_obj.rotation_euler = (0, 0, 0)

text_obj.keyframe_insert(data_path="rotation_euler", frame=1)

text_obj.rotation_euler = (0, 0, radians(360))

text_obj.keyframe_insert(data_path="rotation_euler", frame=250) # Adjust frame count as needed

# Create bubbles

for _ in range(50):

bpy.ops.mesh.primitive_uv_sphere_add(radius=random.uniform(0.1, 0.5),
location=(random.uniform(-5, 5), random.uniform(-5, 5), random.uniform(1, 5)))

bubble = bpy.context.active_object

bubble.keyframe_insert(data_path="location", index=-1, frame=1)

bubble.location.z -= random.uniform(2, 5)

bubble.keyframe_insert(data_path="location", index=-1, frame=250) # Adjust frame count as needed

# Set up camera

bpy.ops.object.camera_add(enter_editmode=False, align='WORLD', location=(0, -10, 5),


rotation=(radians(60), 0, radians(45)))

camera = bpy.context.active_object

bpy.ops.object.select_all(action='DESELECT')

camera.select_set(True)

bpy.context.view_layer.objects.active = camera
# Set keyframes for camera animation

camera.location = (0, -10, 5)

camera.rotation_euler = (radians(60), 0, radians(45))

camera.keyframe_insert(data_path="location", frame=1)

camera.keyframe_insert(data_path="rotation_euler", frame=1)

camera.location = (0, -10, 10)

camera.rotation_euler = (radians(45), 0, radians(45))

camera.keyframe_insert(data_path="location", frame=250) # Adjust frame count as needed

camera.keyframe_insert(data_path="rotation_euler", frame=250) # Adjust frame count as needed

import bpy

# Clear existing mesh objects and materials

bpy.ops.object.select_all(action='DESELECT')

bpy.ops.object.select_by_type(type='MESH')

bpy.ops.object.delete()

# Create text object

bpy.ops.object.text_add(enter_editmode=False, align='WORLD', location=(0, 0, 0))

text_obj = bpy.context.active_object

text_obj.data.body = "Bubble"

# Set text material (you can customize the color)


material = bpy.data.materials.new(name="TextMaterial")

material.diffuse_color = (0.5, 0.8, 1, 1) # RGB values, last is alpha (transparency)

text_obj.data.materials.append(material)

# Adjust font settings if needed (optional)

text_obj.data.extrude = 0.1

text_obj.data.size = 2.0

# Set up camera

bpy.ops.object.camera_add(enter_editmode=False, align='WORLD', location=(0, -5, 5),


rotation=(radians(60), 0, radians(45)))

camera = bpy.context.active_object

bpy.ops.object.select_all(action='DESELECT')

camera.select_set(True)

bpy.context.view_layer.objects.active = camera

# Set keyframes for camera animation

camera.location = (0, -5, 5)

camera.rotation_euler = (radians(60), 0, radians(45))

camera.keyframe_insert(data_path="location", frame=1)

camera.keyframe_insert(data_path="rotation_euler", frame=1)

camera.location = (0, -5, 10)

camera.rotation_euler = (radians(45), 0, radians(45))

camera.keyframe_insert(data_path="location", frame=250) # Adjust frame count as needed

camera.keyframe_insert(data_path="rotation_euler", frame=250) # Adjust frame count as needed


import bpy

# Clear existing mesh objects

bpy.ops.object.select_all(action='DESELECT')

bpy.ops.object.select_by_type(type='MESH')

bpy.ops.object.delete()

# Create a basic human-shaped mesh

bpy.ops.mesh.primitive_human_add()

# Select the newly created mesh

bpy.context.view_layer.objects.active = bpy.context.selected_objects[0]

bpy.ops.object.mode_set(mode='EDIT')

# Extrude to create legs

bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":(0, 0, -1)})

# Switch back to Object mode

bpy.ops.object.mode_set(mode='OBJECT')

# Create a blue material

mat = bpy.data.materials.new(name="BlueMaterial")

mat.diffuse_color = (0, 0, 1, 1) # RGB values for blue


# Assign the material to the character

bpy.context.object.data.materials.append(mat)

# Set the character's shirt color to blue

bpy.context.object.data.materials[0] = mat

# Optional: Set the character's name

bpy.context.object.name = "MaleCharacter"

# Optional: Position the character

bpy.context.object.location = (0, 0, 0)

# Optional: Scale the character

bpy.context.object.scale = (1, 1, 1)

# Update the scene

bpy.context.view_layer.update()

# Save the blend file

bpy.ops.wm.save_as_mainfile(filepath="/path/to/your/file.blend")

import bpy

import random

# Clear existing mesh objects in the scene


bpy.ops.object.select_all(action='DESELECT')

bpy.ops.object.select_by_type(type='MESH')

bpy.ops.object.delete()

# Function to create a skyscraper

def create_skyscraper(x, y, height):

bpy.ops.mesh.primitive_cube_add(size=1, enter_editmode=False, align='WORLD', location=(x, y,


height/2))

bpy.context.object.scale = (random.uniform(0.5, 1.5), random.uniform(0.5, 1.5), height)

# Function to create a street grid

def create_street_grid(grid_size, street_width):

for i in range(grid_size):

for j in range(grid_size):

x = i * (2 + street_width)

y = j * (2 + street_width)

create_skyscraper(x, y, random.uniform(2, 20))

# Set up the scene

bpy.ops.wm.read_factory_settings(use_empty=True)

# Create the street grid

create_street_grid(5, 1)

# Set the view to a more suitable angle

bpy.ops.view3d.camera_to_view_selected()
# Update the scene

bpy.context.view_layer.update()

# Save the Blender file

bpy.ops.wm.save_as_mainfile(filepath='path_to_save.blend')

import bpy

import random

# Clear existing mesh objects in the scene

bpy.ops.object.select_all(action='DESELECT')

bpy.ops.object.select_by_type(type='MESH')

bpy.ops.object.delete()

# Function to create a building

def create_building(x, y, z, width, depth, height):

bpy.ops.mesh.primitive_cube_add(size=1, location=(x, y, z))

building = bpy.context.active_object

building.dimensions = (width, depth, height)

# Function to create a street

def create_street(x, y, z, width, length):


bpy.ops.mesh.primitive_plane_add(size=1, location=(x, y, z))

street = bpy.context.active_object

street.dimensions = (width, length, 0.1)

street.rotation_euler[2] = random.uniform(0, 3.14) # Randomly rotate streets

# Number of buildings and streets

num_buildings = 20

num_streets = 5

# Create random buildings

for _ in range(num_buildings):

x = random.uniform(-50, 50)

y = random.uniform(-50, 50)

z=0

width = random.uniform(2, 10)

depth = random.uniform(2, 10)

height = random.uniform(5, 30)

create_building(x, y, z, width, depth, height)

# Create random streets

for _ in range(num_streets):

x = random.uniform(-50, 50)

y = random.uniform(-50, 50)

z=0

width = random.uniform(10, 20)


length = random.uniform(50, 100)

create_street(x, y, z, width, length)

import bpy

import math

from mathutils import noise

# Clear existing mesh objects

bpy.ops.object.select_all(action='DESELECT')

bpy.ops.object.select_by_type(type='MESH')

bpy.ops.object.delete()

# Function to create a tree

def create_tree():

# Add a cylinder as the trunk

bpy.ops.mesh.primitive_cylinder_add(radius=0.1, depth=1, location=(0, 0, 0))

# Move to edit mode to add branches

bpy.ops.object.mode_set(mode='EDIT')

# Iterate to create branches

for i in range(4):

bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":(0, 0, 1)})
bpy.ops.transform.rotate(value=math.radians(45), orient_axis='Z')

# Return to object mode

bpy.ops.object.mode_set(mode='OBJECT')

# Function to add realistic colors using noise

def add_realistic_colors(obj):

material = bpy.data.materials.new(name="TreeMaterial")

obj.data.materials.append(material)

bpy.context.view_layer.objects.active = obj

bpy.ops.object.material_slot_assign()

mat_nodes = material.node_tree.nodes

shader_node = mat_nodes.get("Principled BSDF")

# Add noise texture

noise_texture = mat_nodes.new(type='ShaderNodeTexNoise')

noise_texture.location = (-200, 300)

# Link noise texture to color

mat_nodes.link(noise_texture.outputs[0], shader_node.inputs[0])

# Create the tree

create_tree()
# Select the tree object

tree_object = bpy.context.active_object

# Add realistic colors

add_realistic_colors(tree_object)

You might also like