Run Blender with python

Blender may be operated with a mouse in most cases, but running it with python saves a lot of trouble. To write the code, select Scripting → Text Editior

無題2.png

無題.png

Mode switching

bpy.ops.object.mode_set (mode ='OBJECT', toggle = False) #Object mode bpy.ops.object.mode_set (mode ='EDIT', toggle = False) # Edit mode. Basically, operations such as rotation are set to EDIT mode.

Translation

bpy.ops.transform.translate(value=(x,y,z))

Enlargement / reduction

bpy.ops.transform.resize (value = (x, y, z)) # 1 or above will expand

rotation

bpy.ops.transform.rotate (value = 0, axis = (x, y, z)) # value = amount of rotation

Select / deselect all faces

obj = bpy.context.edit_object # Put in edit mode me = obj.data # Get data bm = bmesh.from_edit_mesh(me) for i, f in enumerate (bm.faces): # Process by face (i is the order of faces) f.select = False #False deselects the face, if True, edit

Screen update

bmesh.update_edit_mesh(me, True)

Other writing style

If you move the cursor over it, it will appear, so you can refer to it.

無題.png

Official API documentation on how to use arguments http://docs.blender.org/api/blender_python_api_2_67_1/bpy.ops.transform.html

Recommended Posts

Run Blender with python
Run mruby with Python or Blender
Run Python with VBA
Run prepDE.py with python3
Operate Blender with Python
Run iperf with python
Run python with PyCharm (Windows)
Run Python with CloudFlash (arm926ej-s)
Let's run Excel with Python
Run Label with tkinter [Python]
Run DHT22 with RasPi + Python
Run Rotrics DexArm with python API
Run XGBoost with Cloud Dataflow (Python)
Run Aprili from Python with Orange
Run python3 Django1.9 with mod_wsgi (deploy)
Until you run python with apache
Easy modeling with Blender and Python
Get started with Python in Blender
FizzBuzz with Python3
Scraping with Python
Statistics with python
Scraping with Python
Twilio with Python
Integrate with Python
Blender 2.9 Python Extrude extrude
Play with 2016-Python
AES256 with python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
Run servo with Python on ESP32 (Windows)
Run a Python web application with Docker
[Blender x Python] Let's get started with Blender Python !!
Serial communication with Python
Django 1.11 started with Python3.6
Primality test with Python
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Try scraping with Python.
Learning Python with ChemTHEATER 03
"Object-oriented" learning with python
Handling yaml with python
Solve AtCoder 167 with python
Serial communication with python
[Python] Use JSON with Python
Learning Python with ChemTHEATER 05-1
Learn Python with ChemTHEATER
1.1 Getting Started with Python
Collecting tweets with Python
Binarization with OpenCV / Python
3. 3. AI programming with Python
Kernel Method with Python
Non-blocking with Python + uWSGI
Scraping with Python + PhantomJS
Posting tweets with python