Beginner Python Exercise in Blender: Make a cube from a list of vertices

preview_player
Показать описание

This is a video exercise for Blender Python beginners.
We will write a Python script that creates a Cube from a list of vertices and faces.

Final code:

00:00 - Intro
00:30 - Setup Workspace
00:58 - Adding Lists
01:28 - Create mesh data
03:02 - Add a vert
03:27 - Create an object
05:18 - Add to the Scene Collection
06:09 - Removing orphan data
06:35 - Adding verts to form a face
07:13 - Show vert indices
08:23 - Define a face
09:17 - Check face orientation
09:30 - Define remaining verts
10:03 - Define remaining faces
11:18 - Inspecting a face
12:52 - What is a Python script?
13:53 - Exercise #1
14:34 - Exercise #2
15:08 - Outro

Intro Music
Fiery Trails - Silent Partner

Outro Music
Geographer - Easy Shake

#blender #python #scripting
Рекомендации по теме
Комментарии
Автор

You are the most useful resource I have found on python/blender scripts. Thanks you!

opticaudio
Автор

bro i just started python in blender with you and your descriptions are amazing, thank you very much!

alirezakhademi
Автор

I'll make sure to watch it this evening. As always... thanks for your efforts :)

BrettKromkamp
Автор

love this.
I made the exercise 1 in a different way than yours.
I just add variables on edges. 😀

Thanks again Victor! you are the best!🤘

jessiecampanero
Автор

thank you so much for this .. I was trying exactly this a few months ago, but wanted to figure it out on my own .. and was even less used to blender than I am today .. now I can finally improvise on this! :)

lezvgov
Автор

Thank you! That was a great tutorial!
The big advantage of it, that you are able to solve the task. That’s greate to have a little success, after you got the exercises done. Those little portions combined with success in my opinion, are a key to learn further. This is a kind of lessons I needed for python.
Like and Abo and big thanks 🙏🍀

PowNyTales
Автор

Super well taught! Thank you for sharing your knowledge!!!

philippe
Автор

Note to run scripts less than possible: for faces choose verts *CONTRAclockwise* to set normals outward (blue color), and clockwise to set normals inward (red color).
Note 2: with indices view enable, be sure that you in vertices selection mode (Edit Mode -> 1), otherwise, indices will be shown to edges (2), faces (3) - I checked, if it created the edges automatically, and forget to set back to verts selection, and spent time to figure out what the problem was... now, you know how to solve this issue.

DenisTrebushnikov
Автор

You made bpybb - just use them, no need to repeat "old truths" every video. Great job man!

aleksanderk
Автор

Thanks for the video. I just recently ventured into using python with blender and I'm excited about it. Real quick though, has anyone ever told you you looked like Peter Dinklage? :D

JM-jkvz
Автор

I greatly appreciate your help; you went straight to the point. I was looking for an output platform for the data I'm about to generate through IoT sensors. If you have any recommendations for a bootcamp that covers this topic, I would be very happy. I'm asking for this recommendation because of the quality of your explanation, which was impeccable!
You earned a subscribed!

parkour
Автор

Thank you very much! Are you providing online lessons? Thanks!

briantriesart
Автор

Thanks again, CGPython! Just completed this one. I kept the original vertices for the entire thing and simply added a 9th vertex for the point of the pyramid. I'm using a lot of #comments to keep track, and toggling out one set of face tuples for the next shape's tuples. I definitely got a few faces flipped or overlapping while trying to keep the 2nd Cube w/triangle faces built, but I learned a lot. I am so excited for the next one with repeating code with for loops! 🐍🟦

jmfs
Автор

Hi, this video came up on the search of my problem and it was a huge help.
I need to automat the creation of some specific modular gameobjects. Creating those within Unity would be no problem. However I do want to create an atlas of modular elements within blender and I am new to this topic of programming within blender. Creating those intended base modules within the gameengine and trying to export those (however?) for specific variations into blender does sound more complicated. So I am trying to use blender directly.
Following those steps I managed to create some prototypes like intended. However the upcoming problem is the following:

While defining the faces I would also like to specify the UV-positions of each vertex of the current face.
I was hoping to find something like:

UV_POSITION_OF_VERTICES_OF_FACES=[[(0, 1), (0.2, 1), (0.2, 0), (0, 0)], [...], [...], [...]] ?
mesh_data.from_pydata(verts, edges, faces, ?

Does such a similar function with those intended parameters exist or something similar?

I was searching for an answer, but I assume I do not even know how to search in this category correctly for my problem. All I got were examples concerning unwrapping or answers with loops, where I could not find a single assignation with a 2d-vector position.

Thanks for this tutorial

kronenapp
Автор

why does the order of the indexes change the face orientation? how do you know which order to go?

oishiiyum
Автор

hello Victor, thanks for the tutorials. At the end I wanted to recalculate the normals so that they point outwards, but I did not succeed.

arturertel
Автор

Привет. Не подскажите, куда копать, чтобы добавить элементы интерактивности в скрипты. Как определить выделенные вершины или ребра, как отследить положение курсора (мыши) и в реальном времени строить объекты кликами. Пришел из C# и многие вещи в Python кажутся дикими :). Имеются ли какие-то код-конвеншн по написанию скриптов, чтобы приучить себя сразу? Спасибо и удачи с каналом.

smikhasko
Автор

The very last clip was the most interesting, which looked like a randomly positioned objects floating.. Go over the code for that.

honestyrocksu
Автор

I wrote a script before in that similar way after months of trying (I am not a programmer). I had x, y & z values. There were a lot of points. I wanted to edit the Z values only. However, when you have a lot of points, it becomes very confusing and difficult to find the points to change. Is there a way to add a menu for the z values that can be edited?

ashhaf
Автор

very helpful thanks! But let me ask you Is there a way to declare the variable of vertices (more than 68) so that some function can update the coordinates?
For a simple list, you can use verts=list(range(208))
For verts=[(1, 0, 1), (1, 2, 3)....] how ?

spirosmarinis