Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is Blender script development like?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Blender script development is like, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Blender is an open source model editing tool that can support the development of scripting languages. For batch model processing, with the help of scripts, manual operations can be reduced.

Blender's script is developed in python, uses python's API, and can call Blender's API.

API address of Blender:

Https://docs.blender.org/api/2.80/

To use scripts in Blender, first switch to the script editing interface:

The middle blank area is where the python script is written. Click "template" to view some pre-set scripts.

Take the template of opening a file as an example, after opening it, directly click "run script" on the right, you can see the window that opens to select the file.

API that uses Blender requires import bpy to operate on the model file.

A simple folder, select the .dae format model, export to .glb model format code:

Import os

Import bpy

# define to delete the model files in the scene, and import one to delete one

Def remove_file ():

Objs = bpy.data.objects

For (kpene v) in objs.items ():

Bpy.data.objects.remove (v)

Data_path = "input path"

Out_path= "output path"

File_list = os.listdir (data_path)

Remove_file ()

# traversing the dae model

Dae_list = [item for item in file_list if item.endswith ('.dae')]

For item in dae_list:

Dae_path = os.path.join (data_path, item)

# dae Model Import

Bpy.ops.wm.collada_import (filepath=dae_path)

# glb Model Export

Out_dae_path = os.path.join (out_path, item.replace (".dae", '.glb'))

Bpy.ops.export_scene.gltf (export_format='GLB',filepath=out_dae_path)

Remove_file ()

The above python language format does not display properly, please adjust it according to the editor.

For some Blender operations, when using, the corresponding command prompt will be displayed in the lower left of the editor, so you can have a visual understanding of the use of API.

After reading the above, have you mastered the method of Blender script development? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report