-
Notifications
You must be signed in to change notification settings - Fork 0
/
installScript.py
37 lines (29 loc) · 1.15 KB
/
installScript.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Copyright: Hans Willem Gijzel (hanswillemgijzel@gmail.com)
C4D R18
Name-US:Install Script
Description-US:Copies the selected python script to the scripts folder
"""
import c4d
import shutil
import os
def main():
scriptFullPath = c4d.storage.LoadDialog()
scriptFile = os.path.basename(scriptFullPath)
scriptFileExt = os.path.splitext(scriptFile)[1]
iconFullPath = os.path.dirname(scriptFullPath)
iconFile = os.path.splitext(scriptFile)[0] + '.tif'
iconFullPath = os.path.join(iconFullPath, iconFile)
pathToScriptsScriptFile = c4d.storage.GeGetC4DPath(1)[:-6] + '/library/scripts/' + scriptFile
pathToScriptsIconFile = c4d.storage.GeGetC4DPath(1)[:-6] + '/library/scripts/' + iconFile
if scriptFileExt == '.py':
shutil.copyfile(scriptFullPath, pathToScriptsScriptFile)
if os.path.isfile(iconFullPath):
shutil.copyfile(iconFullPath, pathToScriptsIconFile)
c4d.gui.MessageDialog('Script and icon installed!')
else:
c4d.gui.MessageDialog('Script installed!')
else:
c4d.gui.MessageDialog('Select a python file!')
if __name__ == '__main__':
main()