Skip to content

Commit

Permalink
Add one place to store additional apps, add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Datsik Mikhail committed Nov 4, 2019
1 parent 62154ae commit 1fb3d07
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 35 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Implementation of a shotgun toolkit engine for [**Cinema 4D**](https://www.maxon
* [Configuring your project for Shotgun Toolkit](#configuring-your-project-for-shotgun-toolkit)
* [Modifying the toolkit configuration files to add this engine and related apps](#modifying-the-toolkit-configuration-files-to-add-this-engine-and-related-apps)
* [Modifying the Templates](#modifying-the-templates)
* [Add additional App into Engine](#add-additional-app-into-engine)
* [Configuring Cinema 4D in the software launcher](#configuring-cinema-in-the-software-launcher)
* [Caching and downloading the engine into disk](#caching-and-downloading-the-engine-into-disk)

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

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

## Add additional App into Engine

To load Cinema preload plugins, when you add additional applications you must add line with new `app name, id, pace in menu`.

In file `python\tk_cinema\constant_apps.py` add following string:
```
["app name", "id", "pace in menu"]
Example:
["Sync Frame Range with Shotgun", "3366874", "main"],
```
## Configuring Cinema 4D in the software launcher

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.
Expand Down Expand Up @@ -199,8 +211,9 @@ One last step is to cache the engine and apps from the configuration files into

* 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.

![tank_cache_apps](config/images/tank_cache_apps.png)

<p align="center">
<img src="config/images/tank_cache_apps.png">
</p>

## Cinema 4D engine should be ready to use

Expand Down
43 changes: 43 additions & 0 deletions python/tk_cinema/constant_apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) 2013 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

# Menu Id"s generated with simple function
# def get_plugins():
# out = []
# for item in engine.commands.items():
# tmp = [item]
# m = hashlib.md5()
# m.update(item[0])
# plug_id = str(int(m.hexdigest(), 16))[0:7]
# tmp.append(plug_id)
# out.append(tmp)
# return out

menu_prebuild = [
["Separator", "0", "separator"],
["Jump to Shotgun", "2701393", "submenu"],
["Jump to File System", "2158662", "submenu"],
["Jump to Screening Room in RV", "2188709", "submenu"],
["Jump to Screening Room Web Player", "2419038", "submenu"],
["Reload and Restart", "5919542", "submenu"],
["Open Log Folder", "3271712", "submenu"],
["Work Area Info...", "2574358", "submenu"],
["File Open...", "1760964", "main"],
["Snapshot...", "2436236", "main"],
["File Save...", "1825592", "main"],
["Publish...", "3378887", "main"],
["Load...", "3279052", "main"],
["Separator", "0", "separator"],
["Scene Breakdown...", "1506973", "main"],
["Shotgun Panel...", "2399777", "main"],
["Snapshot History...", "3313077", "main"],
["Sync Frame Range with Shotgun", "3366874", "main"],
["Separator", "0", "separator"],
]
33 changes: 10 additions & 23 deletions python/tk_cinema/menu_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from tank.platform.qt import QtGui, QtCore

import c4d
import constant_apps


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

menu = c4d.BaseContainer()
menu.InsData(c4d.MENURESOURCE_SUBTITLE, self._menu_name)

submenu = c4d.BaseContainer()
submenu.InsData(c4d.MENURESOURCE_SUBTITLE, "{}".format(self._engine.context))

submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2701393))
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2158662))
submenu.InsData(c4d.MENURESOURCE_SEPERATOR, True)
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2188709))
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2419038))
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3271712))
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2574358))
menu.InsData(c4d.MENURESOURCE_SUBMENU, submenu)

menu.InsData(c4d.MENURESOURCE_SEPERATOR, True)
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(1760964))

menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2436236))
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(1825592))
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3378887))

menu.InsData(c4d.MENURESOURCE_SEPERATOR, True)
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3279052))
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(1506973))
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3313077))
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(2399777))
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(3366874))
for app, app_id, place in constant_apps.menu_prebuild:
if "submenu" in place:
submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(app_id))
elif "main" in place:
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(app_id))
else:
menu.InsData(c4d.MENURESOURCE_SEPERATOR, True)

menu.InsData(c4d.MENURESOURCE_SUBMENU, submenu)
mainMenu.InsData(c4d.MENURESOURCE_STRING, menu)

c4d.gui.UpdateMenus()
22 changes: 12 additions & 10 deletions startup/shotgun.pyp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import sgtk

import tank


# Need to find better Solution with dinamic menu
menu_prebuild = [ ['File Save...', '1825592'],
['File Open...', '1760964'],
Expand Down Expand Up @@ -42,7 +43,7 @@ try:
except:
engine = tank.platform.engine.current_engine()

print engine


def get_plugins():
out = []
Expand Down Expand Up @@ -163,15 +164,16 @@ def register_plugins():

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

for item in menu_prebuild:
c4d.plugins.RegisterCommandPlugin(
id=int(item[-1]),
str=item[0],
info=c4d.PLUGINFLAG_HIDEPLUGINMENU,
help='',
icon=None,
dat=callbackPlugin(callback=item[0])
)
for item in engine.import_module("tk_cinema").constant_apps.menu_prebuild:
if not "separator" in item[-1]:
c4d.plugins.RegisterCommandPlugin(
id=int(item[-2]),
str=item[0],
info=c4d.PLUGINFLAG_HIDEPLUGINMENU,
help='',
icon=None,
dat=callbackPlugin(callback=item[0])
)

if __name__ == '__main__':
register_plugins()

0 comments on commit 1fb3d07

Please sign in to comment.