Bases: object
Connects the environment (the host program) to the oyProjectManager.
In oyProjectManager, an Environment is a host application like Maya, Nuke, Houdini etc.
Generally a GUI for the end user is given an environment which helps the QtGui to be able to open, save, import or export a Version without knowing the details of the environment.
Note
For now the EnvironmentBase inherits from the Python object class. There were no benefit to inherit it from the DeclarativeBase.
To create a new environment for you own program, just instantiate this class and override the methods as necessary. And call the UI with by giving an environment instance to it, so the interface can call the correct methods as needed.
Here is an example how to create an environment for a program and use the GUI:
from oyProjectManager.core import EnvironmentBase
class MyProgram(EnvironmentBase):
"""This is a class which will be used by the UI
"""
def open():
"""uses the programs own Python API to open a version of an
asset
"""
# do anything that needs to be done before opening the file
my_programs_own_python_api.open(filepath=self.version.full_path)
def save():
"""uses the programs own Python API to save the current file
as a new version.
"""
# do anything that needs to be done before saving the file
my_programs_own_python_api.save(filepath=self.version.full_path)
# do anything that needs to be done after saving the file
and that is it.
The environment class by default has a property called version. Holding the current open version. It is None for a new scene and a Version instance in any other case.
Parameters: | name – To initialize the class the name of the environment should be given in the name argument. It can not be skipped or None or an empty string. |
---|
x.__init__(...) initializes x; see help(type(x)) for signature
Methods
check_referenced_versions() | Checks the referenced versions |
export_as(version) | Exports the contents of the open document as the given version. |
getProject() | returns the current project from environment |
get_current_version() | Returns the current Version instance from the environment. |
get_fps() | Returns the frame rate of this current environment |
get_frame_range() | Returns the frame range from the environment |
get_last_version() | Returns the last opened Version instance from the environment. |
get_referenced_versions() | Returns the Version instances |
get_version_from_full_path(full_path) | Finds the Version instance from the given full_path value. |
get_versions_from_path(path) | Finds Version instances from the given path value. |
has_extension(filename) | Returns True if the given filenames extension is in the extensions |
import_(asset) | the import action |
load_referenced_versions() | loads all the references |
open_(version[, force]) | the open action |
reference(asset) | the reference action |
replace_external_paths([mode]) | Replaces the external paths (which are not starting with the environment variable) with a proper path. |
replace_version(source_version, target_version) | Replaces the source_version with the target_version |
save_as(version) | The save as action of this environment. |
set_fps([fps]) | Sets the frame rate of the environment. |
set_frame_range([start_frame, end_frame, ...]) | Sets the frame range in the environment to the given start and end |
set_project(version) | Sets the project to the given versions project. |
trim_server_path(path_in) | Trims the server_path value from the given path_in |
Attributes
extensions | Returns the valid native extensions for this environment. |
name | returns the environment name |
version | returns the current Version instance which is open in the |
The save as action of this environment. It should save the current scene or file to the given version.full_path
Exports the contents of the open document as the given version.
Parameters: | version – A Version instance holding the desired version. |
---|
Trims the server_path value from the given path_in
Parameters: | path_in – The path that wanted to be trimmed |
---|---|
Returns: | str |
Finds Version instances from the given path value.
Finds and returns the Version instances from the given path value.
Returns an empth list if it can’t find any matching.
This method is different than get_version_from_full_path() because it returns a list of Version instances which are residing in that path. The list is ordered by the ids of the instances.
Parameters: | path – A path which has possible Version instances. |
---|---|
Returns: | A list of Version instances. |
Finds the Version instance from the given full_path value.
Finds and returns a Version instance from the given full_path value.
Returns None if it can’t find any matching.
Parameters: | full_path – The full_path of the desired Version instance. |
---|---|
Returns: | Version |
Returns the current Version instance from the environment.
Returns: | Version instance or None |
---|
Returns the last opened Version instance from the environment.
Returns: | Version instance or None |
---|
Sets the project to the given versions project.
Because the projects are related to the created Version instances instead of passing a Project instance it is much meaningful to pass a Version instance which will have a reference to the Project instance already.
Parameters: | project – A Version. |
---|
Returns the Version instances which are referenced in to the current scene
Returns: | list of Version instances |
---|
Returns the frame range from the environment
Returns: | a tuple of integers containing the start and end frame numbers |
---|
Sets the frame range in the environment to the given start and end frames
Returns the valid native extensions for this environment.
Returns: | a list of strings |
---|
Returns True if the given filenames extension is in the extensions list false otherwise.
accepts: * a full path with extension or not * a file name with extension or not * an extension with a dot on the start or not
Parameters: | filename – A string containing the filename |
---|
Replaces the source_version with the target_version
Parameters: |
---|
Replaces the external paths (which are not starting with the environment variable) with a proper path. The mode controls if the resultant path should be absolute or relative to the project dir.
Parameters: | mode – Controls the resultant path is absolute or relative. mode 0: absolute (a path which starts with $REPO) mode 1: relative (to project path) |
---|---|
Returns: |