Skip to content

Commit

Permalink
installers updated for gaffer
Browse files Browse the repository at this point in the history
  • Loading branch information
masqu3rad3 committed Apr 6, 2024
1 parent 01efe3d commit d59502a
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 14 deletions.
3 changes: 3 additions & 0 deletions package/tik_manager4_innosetup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Name: "Nuke"; Description: "Nuke"; Flags: checkedonce
Name: "Photoshop"; Description: "Photoshop"; Flags: checkedonce
Name: "Katana"; Description: "Katana"; Flags: checkedonce
Name: "Mari"; Description: "Mari"; Flags: checkedonce
Name: "Gaffer"; Description: "Gaffer"; Flags: checkedonce

[Code]
type
Expand Down Expand Up @@ -93,6 +94,8 @@ begin
strFlag := strFlag + ' ' + 'Katana';
if WizardIsTaskSelected('Mari') then
strFlag := strFlag + ' ' + 'Mari';
if WizardIsTaskSelected('Gaffer') then
strFlag := strFlag + ' ' + 'Gaffer';
result := strFlag;
end;
Expand Down
56 changes: 53 additions & 3 deletions tik_manager4/dcc/dcc_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self, argv):
"Photoshop": self.photoshop_setup,
"Katana": self.katana_setup,
"Mari": self.mari_setup,
"Gaffer": self.gaffer_setup,
}

def install_all(self):
Expand All @@ -69,6 +70,7 @@ def install_all(self):
self.photoshop_setup(prompt=False)
self.katana_setup(prompt=False)
self.mari_setup(prompt=False)
self.gaffer_setup(prompt=False)
ret = input("Setup Completed. Press Enter to Exit...")
assert isinstance(ret, str)
sys.exit()
Expand Down Expand Up @@ -516,7 +518,6 @@ def mari_setup(self, prompt=True):
_r = input("Press Enter to continue...")
assert isinstance(_r, str)


def photoshop_setup(self, prompt=True):
"""Install the Photoshop plugin."""
print_msg("Starting Photoshop Setup...")
Expand Down Expand Up @@ -604,6 +605,57 @@ def photoshop_setup(self, prompt=True):
ret = input("Press Enter to continue...")
assert isinstance(ret, str)

def gaffer_setup(self, prompt=True):
"""Install Gaffer integration."""
print_msg("Starting Gaffer Setup...")

# find the gaffer installation folder.
places_to_look = ["C:/Program Files", "C:/Program Files (x86)", "C:/opt", "C:/software"]

gaffer_versions = []
for place in places_to_look:
# it the place doesn't exist, skip it
if not Path(place).exists():
continue
# look for folders that starts with "gaffer" and append them to the list
for x in Path(place).iterdir():
# print("path", x)
if x.is_dir() and x.name.startswith("gaffer"):
print("gaffer", x)
gaffer_versions.append(x)
# gaffer_versions.extend([x for x in Path(place).iterdir() if x.is_dir() and x.name.startswith("gaffer")])

# for each gaffer version check for the startup/gui folders. If they don't exist, skip the version
for version in list(gaffer_versions):
gui_folder = version / "startup" / "gui"
if not gui_folder.exists():
gaffer_versions.remove(version)
if not gaffer_versions:
print_msg("No Gaffer version can be found.")
print_msg(f"Make sure Gaffer is installed in one of the following folder and try again. {places_to_look}"
"Alternatively you can try manual install. "
"Check the documentation for more information.")
if prompt:
ret = input("Press Enter to continue...")
assert isinstance(ret, str)
return
source_init_file = self.tik_dcc_folder / "gaffer" / "setup" / "tik_4_init.py"

for version in gaffer_versions:
print_msg(f"Setting up {version.name}...")
gui_folder = version / "startup" / "gui"
init_file = gui_folder / "tik_4_init.py"
shutil.copy(source_init_file, init_file)
injector = Injector(init_file)
injector.match_mode = "contains"
injector.replace_single_line(f"tik_path = '{self.tik_root.parent.as_posix()}'",
line="tik_path = ")

print_msg("Gaffer setup completed.")
if prompt:
_r = input("Press Enter to continue...")
assert isinstance(_r, str)

def __set_csx_key(self, val):
"""Convenience function to set the csx key."""
try:
Expand Down Expand Up @@ -888,8 +940,6 @@ def replace_single_line(self, new_content, line, suppress_warnings=False):
self._dump_content(injected_content)
return True



def read(self):
"""Reads the file."""
if not self.file_path.is_file():
Expand Down
25 changes: 25 additions & 0 deletions tik_manager4/dcc/gaffer/ingest/reader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Element reader for Gaffer ingest module"""

from pathlib import Path

import GafferScene

from tik_manager4.dcc.gaffer import gaffer_menu

from tik_manager4.dcc.ingest_core import IngestCore

class Reader(IngestCore):
"""Ingest elements."""

nice_name = "Reader"
valid_extensions = [".abc", ".lscc", ".scc", ".usd", ".usda", ".usdc", ".usdz", ".vdb"]
referencable = False

def __init__(self):
super(Reader, self).__init__()
self.gaffer = gaffer_menu.GafferMenu()
def _bring_in_default(self):
"""Import various file types."""
reader_node = GafferScene.SceneReader()
self.gaffer.script.addChild(reader_node)
reader_node["fileName"].setValue(Path(self.ingest_path).as_posix())
25 changes: 25 additions & 0 deletions tik_manager4/dcc/gaffer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def get_main_window(self):
"""Get the main window of the DCC."""
return self.gaffer.script_window._qtWidget()

def save_scene(self):
"""Save the current scene."""
self.gaffer.script.save()

def save_as(self, file_path):
"""Save the current scene as the given file path."""
self.gaffer.script["fileName"].setValue(file_path)
Expand All @@ -45,6 +49,11 @@ def save_as(self, file_path):

return file_path

def save_prompt(self):
"""Pop up the save prompt."""
GafferUI.FileMenu.save(self.gaffer.menu)
return True # this is important or else will be an indefinite loop

def open(self, file_path, force=True, **_extra_arguments):
"""Open the given file path
Args:
Expand All @@ -57,6 +66,10 @@ def open(self, file_path, force=True, **_extra_arguments):
self.gaffer.script["fileName"].setValue(file_path)
self.gaffer.script.load()

def is_modified(self):
"""Check if the current scene is modified."""
return self.gaffer.script["unsavedChanges"].getValue()

def get_scene_file(self):
"""Get the current scene file path."""
_filename = self.gaffer.script["fileName"].getValue()
Expand All @@ -72,6 +85,10 @@ def get_ranges(self):
r_aet = self.gaffer.script["frameRange"]["end"].getValue()
return [r_ast, r_min, r_max, r_aet]

def get_current_frame(self):
"""Get the current frame."""
return self.gaffer.script["frame"].getValue()

def set_ranges(self, range_list):
"""Set the viewport ranges."""
self.gaffer.script["frameRange"]["start"].setValue(range_list[0])
Expand All @@ -84,6 +101,14 @@ def generate_thumbnail(self, file_path, width, height):
# TODO: figure out a way to resize/crop the image to the width and height
return file_path

def get_scene_fps(self):
"""Get the FPS of the scene."""
return self.gaffer.script["framesPerSecond"].getValue()

def set_scene_fps(self, fps_value):
"""Set the FPS of the scene."""
self.gaffer.script["framesPerSecond"].setValue(fps_value)

@staticmethod
def get_dcc_version():
"""Get the version of the DCC."""
Expand Down
14 changes: 13 additions & 1 deletion tik_manager4/dcc/gaffer/setup/how-to-install.txt
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
Tik Manager 4 <template_dcc_name> Installation Guide
Gaffer Integration
==================

1. Locate the ``startup\gui`` folder inside gaffer installation folder.

2. Find the ``tik_4_init.py`` file in the ``tik_manager4/dcc/gaffer/setup`` folder and copy it to the Gaffer ``startup\gui`` scripts folder.

3. Open the copied ``tik_4_init.py`` with a text editor and replace the ``PATH\\TO\\PARENT\\FOLDER\\OF\\TIKMANAGER4\\`` with the extracted parent of the tik_manager4 folder.

.. attention::
The Path MUST be the parent of the tik_manager4 folder. If you extracted the contents directly from the zip file it will be something like ``tik_manager4-4.0.7-beta``.

4. Open Gaffer and you should see the Tik Manager menu in the top menu bar.
37 changes: 37 additions & 0 deletions tik_manager4/dcc/gaffer/setup/tik_4_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Tik Manager 4 [Start]
import sys
tik_path = 'PATH\\TO\\PARENT\\FOLDER\\OF\\TIKMANAGER4\\'
if not tik_path in sys.path:
sys.path.append(tik_path)
# Tik Manager 4 [End]

import Gaffer
import GafferUI
import GafferScene

import tik_manager4
INIT = tik_manager4.initialize("Gaffer")

from tik_manager4.ui import main
from tik_manager4.dcc.gaffer.gaffer_menu import GafferMenu

def __main_ui(menu):
_gaffer_menu = GafferMenu
GafferMenu.set_menu(menu)
main.launch(dcc="Gaffer")

def __new_version(menu):
_gaffer_menu = GafferMenu
GafferMenu.set_menu(menu)
tui = main.launch("Gaffer", dont_show=True)
tui.on_new_version()

def __publish(menu):
_gaffer_menu = GafferMenu
GafferMenu.set_menu(menu)
tui = main.launch("Mari", dont_show=True)
tui.on_publish_scene()

GafferUI.ScriptWindow.menuDefinition(application).append( "/TikManager/Main UI", { "command" : __main_ui } )
GafferUI.ScriptWindow.menuDefinition(application).append( "/TikManager/New Version", { "command" : __new_version } )
GafferUI.ScriptWindow.menuDefinition(application).append( "/TikManager/Publish", { "command" : __publish } )
10 changes: 0 additions & 10 deletions tik_manager4/dcc/katana/ingest/usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
from Katana import NodegraphAPI
from tik_manager4.dcc.ingest_core import IngestCore

# Specify the filename for the USD file
usd_filename = "/path/to/your/usd/file.usd"

# Create the USDIn node
usd_in_node = NodegraphAPI.CreateNode("UsdIn", NodegraphAPI.GetRootNode())

# Set the filename parameter of the USDIn node
usd_in_node.getParameter("fileName").setValue(usd_filename, 0)


class Usd(IngestCore):
"""Ingest Usd."""

Expand Down
Binary file modified tik_manager4/dist/tik4/_internal/base_library.zip
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/install_dccs.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_photoshop.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_ps_new_version.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_ps_publish.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_standalone.exe
Binary file not shown.

0 comments on commit d59502a

Please sign in to comment.