def create_text_file(name):
"""
Create a new text file, change its name and return it
Args:
- name, the name of the text file, a string"""
if not name and isinstance(name, str):
raise TypeError('The name of the text file has to be a string')
bpy.ops.text.new()
import re
re_text = re.compile(r'^Text.[0-9]{3}$')
text_name = ''
text_index, max_index = 0, 0
for text in bpy.data.texts:
if re_text.match(text.name):
text_index = int(text.name[-3:])
if text_index > max_index:
max_index = text_index
text_name = text.name
if not text_name:
text_name = 'Text'
bpy.data.texts[text_name].name = name
return bpy.data.texts[name]
file_management.py 文件源码
python
阅读 33
收藏 0
点赞 0
评论 0
评论列表
文章目录