Skip to content

Commit

Permalink
initial working version
Browse files Browse the repository at this point in the history
  • Loading branch information
tokejepsen committed Aug 6, 2015
1 parent 6ae7b2e commit 8af56e2
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.pyc
._*
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# pyblish-hiero
Pyblish for Hiero

This page will walk you through integrating Pyblish with Foundry Hiero.

### Prerequisities

Make sure you have installed Pyblish before continuing.

- See [Installing Pyblish](https://github.com/pyblish/pyblish/wiki/Installation)

### Introduction

The integration comes in the form of a menu-item called *"Publish"*, located directly under `File`.

Once clicked, it will display a Pyblish graphical user interface.

### Installation

Ensure Pyblish for Hiero is on your `PYTHONPATH` and run this within Hiero.

```python
import pyblish_hiero
pyblish_hiero.setup()
```

You can then show the Pyblish graphical user interface by calling `show()`.

```python
pyblish_hiero.show()
```

### Persistence

It is recommended that you allow Pyblish to load upon launching Hiero.
For this to work, add the `pyblish_hiero/hiero_plugin_path` directory to your `HIERO_PLUGIN_PATH`

(2) You can find your `pythonpath` directory here:

```bash
pyblish-hiero/pyblish_hiero/hiero_plugin_path
```

As you will find, this directory contains sub-directories leading to two python files; `pyblish_startup.py` and `active_project_tracker.py`.

**pyblish_startup.py**

This sets up Pyblish similar to `pyblish_hiero.setup()`

**active_project_tracker**

This ensures that you can access the active project outside of Hiero, via `hiero.activeProject`. This is also injected into the context, so you can easily access the active project with `context.data('activeProject')`
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Puts the active project into 'hiero.activeProject'
"""

import os

import hiero

def selectionChanged(event):
selection = event.sender.selection()
binSelection = selection
if len(binSelection)>0 and hasattr(binSelection[0],'project'):
hiero.activeProject = binSelection[0].project()

hiero.core.events.registerInterest('kSelectionChanged', selectionChanged)

def projectCreated(event):
hiero.activeProject = event.sender

hiero.core.events.registerInterest('kAfterNewProjectCreated', projectCreated)

def projectLoad(event):
basename = os.path.basename(event.sender.path())
print event.sender.path()
if basename != 'HieroPresets.hrox':
hiero.activeProject = event.sender

hiero.core.events.registerInterest('kAfterProjectLoad', projectLoad)
8 changes: 4 additions & 4 deletions pyblish_hiero/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ def threaded_wrapper(func, *args, **kwargs):

register_plugins()
add_to_filemenu()
register_host()

pyblish_integration.echo("pyblish: Integration loaded..")

def register_host():
"""Register supported hosts"""
pyblish.api.register_host("hiero")

This comment has been minimized.

Copy link
@mottosso

mottosso Aug 6, 2015

Don't forget about linting, there should be two newlines here.

def register_plugins():
# Register accompanying plugins
Expand Down Expand Up @@ -92,9 +96,6 @@ def where(program):
def filemenu_publish():
"""Add Pyblish to file-menu"""

import pyblish.util
pyblish.util.publish()
"""
try:
import pyblish_hiero.lib
pyblish_hiero.lib.show()
Expand All @@ -109,7 +110,6 @@ def filemenu_publish():

import pyblish.util
pyblish.util.publish()
"""


def menu_action():
Expand Down
15 changes: 15 additions & 0 deletions pyblish_hiero/plugins/collect_active_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pyblish.api

import hiero


@pyblish.api.log

This comment has been minimized.

Copy link
@mottosso

mottosso Aug 6, 2015

This isn't necessary anymore, see https://github.com/pyblish/pyblish/issues/213

class CollectActiveProject(pyblish.api.Collector):
"""Inject the active project into context"""

version = (0, 1, 0)
order = pyblish.api.Collector.order - 0.1

def process(self, context):

context.set_data('activeProject', value=hiero.activeProject)
3 changes: 1 addition & 2 deletions pyblish_hiero/plugins/select_current_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ class SelectCurrentFile(pyblish.api.Selector):
def process(self, context):
"""Todo, inject the current working file"""

project = hiero.ui.activeView().selection()[0].project()

project = context.data('activeProject')
context.set_data('currentFile', value=project.path())

0 comments on commit 8af56e2

Please sign in to comment.