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 | |
| class SquareFaceCube: | |
| """ | |
| a class to represent a cube mesh object with square faces | |
| """ | |
| def __init__(self): | |
| # define the coordinates of each vertex |
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
| """ | |
| Note: not using any blank lines to make it easier to copy into the Python interactive console | |
| """ | |
| class ExampleClass: | |
| def __init__(self, example_parameter): | |
| self.example_data = 33 | |
| self.example_param = example_parameter | |
| print("message from constructor") | |
| def example_method(self): | |
| print(self.example_param) |
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 | |
| ####################################################################### | |
| # create a cube with square faces | |
| ####################################################################### | |
| # define the coordinates of each vertex | |
| verts = [ | |
| (-1.0, -1.0, -1.0), | |
| (-1.0, 1.0, -1.0), |
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 | |
| def create_mesh_data(verts, edges, faces): | |
| """ | |
| create a mesh from the vert, edge, and face data | |
| """ | |
| mesh_data = bpy.data.meshes.new("cube_data") | |
| mesh_data.from_pydata(verts, edges, faces) |
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 | |
| class Cube: | |
| """ | |
| a class to represent a cube mesh object | |
| """ | |
| def __init__(self): | |
| # define the coordinates of each vertex |
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 | |
| ####################################################################### | |
| # create a cube with square faces | |
| ####################################################################### | |
| verts = [ | |
| (-1.0, -1.0, -1.0), | |
| (-1.0, 1.0, -1.0), | |
| (1.0, 1.0, -1.0), |
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 | |
| def create_mesh_data(name, verts, edges, faces): | |
| """ | |
| create a mesh from the vert, edge, and face data | |
| """ | |
| mesh_data = bpy.data.meshes.new(f"{name}_data") | |
| mesh_data.from_pydata(verts, edges, faces) |
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 | |
| class Shape: | |
| """ | |
| a class to represent a mesh object | |
| """ | |
| # example of a class variable | |
| instance_count = 0 |
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
| # give Python access to Blender's functionality | |
| import bpy | |
| # extend Python's math functionality | |
| import math | |
| # add a cube mesh into the scene | |
| bpy.ops.mesh.primitive_cube_add() | |
| # get a reference to the currently active object |
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
| # give Python access to Blender's functionality | |
| import bpy | |
| # extend Python's math functionality | |
| import math | |
| # extend Python functionality to generate random numbers | |
| import random | |