Skip to content

Commit 1fb3d07

Browse files
author
Datsik Mikhail
committed
Add one place to store additional apps, add readme
1 parent 62154ae commit 1fb3d07

File tree

4 files changed

+80
-35
lines changed

4 files changed

+80
-35
lines changed

README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Implementation of a shotgun toolkit engine for [**Cinema 4D**](https://www.maxon
1212
* [Configuring your project for Shotgun Toolkit](#configuring-your-project-for-shotgun-toolkit)
1313
* [Modifying the toolkit configuration files to add this engine and related apps](#modifying-the-toolkit-configuration-files-to-add-this-engine-and-related-apps)
1414
* [Modifying the Templates](#modifying-the-templates)
15+
* [Add additional App into Engine](#add-additional-app-into-engine)
1516
* [Configuring Cinema 4D in the software launcher](#configuring-cinema-in-the-software-launcher)
1617
* [Caching and downloading the engine into disk](#caching-and-downloading-the-engine-into-disk)
1718

@@ -160,7 +161,18 @@ The additions to `config/core/templates.yml` are provided also under the config
160161

161162
[templates.yml](config/core/templates.yml)
162163

164+
## Add additional App into Engine
163165

166+
To load Cinema preload plugins, when you add additional applications you must add line with new `app name, id, pace in menu`.
167+
168+
In file `python\tk_cinema\constant_apps.py` add following string:
169+
```
170+
["app name", "id", "pace in menu"]
171+
172+
Example:
173+
174+
["Sync Frame Range with Shotgun", "3366874", "main"],
175+
```
164176
## Configuring Cinema 4D in the software launcher
165177

166178
In order for Cinema 4D to show up in the shotgun launcher, we need to add it to our list of softwares that are valid for this project.
@@ -199,8 +211,9 @@ One last step is to cache the engine and apps from the configuration files into
199211

200212
* type `tank cache_apps` , and press enter. Shotgun Toolkit will start revising the changes we have done to the configuration yml files and downloading what is required, in this case the engine and the changes for tk-multi-setframerange app listed below.
201213

202-
![tank_cache_apps](config/images/tank_cache_apps.png)
203-
214+
<p align="center">
215+
<img src="config/images/tank_cache_apps.png">
216+
</p>
204217

205218
## Cinema 4D engine should be ready to use
206219

python/tk_cinema/constant_apps.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright (c) 2013 Shotgun Software Inc.
2+
#
3+
# CONFIDENTIAL AND PROPRIETARY
4+
#
5+
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
6+
# Source Code License included in this distribution package. See LICENSE.
7+
# By accessing, using, copying or modifying this work you indicate your
8+
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
9+
# not expressly granted therein are reserved by Shotgun Software Inc.
10+
11+
# Menu Id"s generated with simple function
12+
# def get_plugins():
13+
# out = []
14+
# for item in engine.commands.items():
15+
# tmp = [item]
16+
# m = hashlib.md5()
17+
# m.update(item[0])
18+
# plug_id = str(int(m.hexdigest(), 16))[0:7]
19+
# tmp.append(plug_id)
20+
# out.append(tmp)
21+
# return out
22+
23+
menu_prebuild = [
24+
["Separator", "0", "separator"],
25+
["Jump to Shotgun", "2701393", "submenu"],
26+
["Jump to File System", "2158662", "submenu"],
27+
["Jump to Screening Room in RV", "2188709", "submenu"],
28+
["Jump to Screening Room Web Player", "2419038", "submenu"],
29+
["Reload and Restart", "5919542", "submenu"],
30+
["Open Log Folder", "3271712", "submenu"],
31+
["Work Area Info...", "2574358", "submenu"],
32+
["File Open...", "1760964", "main"],
33+
["Snapshot...", "2436236", "main"],
34+
["File Save...", "1825592", "main"],
35+
["Publish...", "3378887", "main"],
36+
["Load...", "3279052", "main"],
37+
["Separator", "0", "separator"],
38+
["Scene Breakdown...", "1506973", "main"],
39+
["Shotgun Panel...", "2399777", "main"],
40+
["Snapshot History...", "3313077", "main"],
41+
["Sync Frame Range with Shotgun", "3366874", "main"],
42+
["Separator", "0", "separator"],
43+
]

python/tk_cinema/menu_generation.py

+10-23
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from tank.platform.qt import QtGui, QtCore
2323

2424
import c4d
25+
import constant_apps
2526

2627

2728
__author__ = "Mykhailo Datsyk"
@@ -46,33 +47,19 @@ def create_menu(self, *args):
4647

4748
menu = c4d.BaseContainer()
4849
menu.InsData(c4d.MENURESOURCE_SUBTITLE, self._menu_name)
49-
50+
5051
submenu = c4d.BaseContainer()
5152
submenu.InsData(c4d.MENURESOURCE_SUBTITLE, "{}".format(self._engine.context))
52-
53-
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2701393))
54-
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2158662))
55-
submenu.InsData(c4d.MENURESOURCE_SEPERATOR, True)
56-
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2188709))
57-
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2419038))
58-
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3271712))
59-
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2574358))
60-
menu.InsData(c4d.MENURESOURCE_SUBMENU, submenu)
6153

62-
menu.InsData(c4d.MENURESOURCE_SEPERATOR, True)
63-
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(1760964))
64-
65-
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2436236))
66-
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(1825592))
67-
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3378887))
68-
69-
menu.InsData(c4d.MENURESOURCE_SEPERATOR, True)
70-
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3279052))
71-
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(1506973))
72-
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3313077))
73-
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2399777))
74-
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3366874))
54+
for app, app_id, place in constant_apps.menu_prebuild:
55+
if "submenu" in place:
56+
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(app_id))
57+
elif "main" in place:
58+
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(app_id))
59+
else:
60+
menu.InsData(c4d.MENURESOURCE_SEPERATOR, True)
7561

62+
menu.InsData(c4d.MENURESOURCE_SUBMENU, submenu)
7663
mainMenu.InsData(c4d.MENURESOURCE_STRING, menu)
7764

7865
c4d.gui.UpdateMenus()

startup/shotgun.pyp

+12-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import sgtk
1111

1212
import tank
1313

14+
1415
# Need to find better Solution with dinamic menu
1516
menu_prebuild = [ ['File Save...', '1825592'],
1617
['File Open...', '1760964'],
@@ -42,7 +43,7 @@ try:
4243
except:
4344
engine = tank.platform.engine.current_engine()
4445

45-
print engine
46+
4647

4748
def get_plugins():
4849
out = []
@@ -163,15 +164,16 @@ def register_plugins():
163164

164165
c4d.plugins.RegisterMessagePlugin(id=15151510, str="", info=0, dat=SceneChangeEvent())
165166

166-
for item in menu_prebuild:
167-
c4d.plugins.RegisterCommandPlugin(
168-
id=int(item[-1]),
169-
str=item[0],
170-
info=c4d.PLUGINFLAG_HIDEPLUGINMENU,
171-
help='',
172-
icon=None,
173-
dat=callbackPlugin(callback=item[0])
174-
)
167+
for item in engine.import_module("tk_cinema").constant_apps.menu_prebuild:
168+
if not "separator" in item[-1]:
169+
c4d.plugins.RegisterCommandPlugin(
170+
id=int(item[-2]),
171+
str=item[0],
172+
info=c4d.PLUGINFLAG_HIDEPLUGINMENU,
173+
help='',
174+
icon=None,
175+
dat=callbackPlugin(callback=item[0])
176+
)
175177

176178
if __name__ == '__main__':
177179
register_plugins()

0 commit comments

Comments
 (0)