123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- import os
- import datetime
- import platform
- from subprocess import *
- from studio import history
- ostype = platform.system()
- def Open(arg):
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if ostype == "Linux":
- Popen(["xdg-open", arg])
-
- elif ostype == "Windows":
- os.system("start "+arg)
-
- elif ostype == "Darwin":
- os.system("open "+arg)
- def file_open(win, path):
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if os.path.exists(win.project+"/"+path):
- path = win.project+"/"+path
-
-
-
-
- blendfile = False
- for bt in [".blend", ".blend1"]:
- if path.endswith(bt):
- blendfile = True
-
-
-
- if blendfile:
- Popen([get_current_blender(win), path])
-
-
-
-
-
- history.record(win, path, "[Openned]")
-
- else:
- Open(path)
- def copy_file(win, from_path, to_path, new_name=""):
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if os.path.exists(win.project+"/"+from_path):
- from_path = win.project+"/"+from_path
- if os.path.exists(win.project+"/"+to_path):
- to_path = win.project+"/"+to_path
-
-
-
-
- if not new_name:
-
- new_name = from_path[from_path.rfind("/")+1:]
- count = 0
- while new_name in os.listdir(to_path):
- count = count + 1
- new_name = from_path[from_path.rfind("/")+1:from_path.rfind(".")]+"_"+str(count)+from_path[from_path.rfind("."):]
-
-
- to_path = to_path + "/" + new_name
-
- still = True
-
-
- blendfile = False
- for bt in [".blend", ".blend1"]:
- if from_path.endswith(bt):
- blendfile = True
-
- if blendfile:
-
-
-
- noblender = os.system(get_current_blender(win)+" -v")
-
-
-
- if not noblender:
- still = False
-
-
-
-
- os.system(get_current_blender(win)\
- +" -b "\
- +from_path.replace(" ", "\ ")\
- +" --python-expr import\ bpy\;\ bpy.ops.wm.save_as_mainfile\(filepath=\\\""\
- +to_path.replace(" ", "\ ")+"\\\"\)")
-
-
- history.record(win, to_path, "[Added]")
-
- if still:
-
-
- with open(from_path, "rb") as in_file, open(to_path, "wb") as out_file:
- out_file.write(in_file.read())
-
- return to_path
-
- def get_current_blender(win):
-
-
-
-
-
-
-
-
- return "blender"
|