Skip to content

Commit

Permalink
Merge pull request #1 from renderbus/1-add-blender
Browse files Browse the repository at this point in the history
feat: add sdk blender
  • Loading branch information
foxrenderfarm committed Apr 22, 2021
2 parents a1e999e + 882f43b commit 02339cb
Show file tree
Hide file tree
Showing 17 changed files with 829 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .gitignore
@@ -0,0 +1,25 @@
# Byte-compiled / optimized / DLL files
*.py[cod]
*.pyd[cod]
*.so[cod]


# PyCharm project files
.idea/

# Vim / Notepad++ temp files
*~
.*/
*.egg-info
# PyInstaller output
build/
dist/
*.spec

# PyBuilder output
.build/
result/

# Coverage output
.coverage
/venv/
9 changes: 9 additions & 0 deletions README.md
@@ -0,0 +1,9 @@
rayvision_blender
==================

[![](https://img.shields.io/badge/pypi%20package-1.0.0-green)](https://pypi.org/project/rayvision-katana/)
[![](https://img.shields.io/badge/docs--%E4%B8%AD%E6%96%87%E7%AE%80%E4%BD%93-latest-green)](https://renderbus.readthedocs.io/zh/latest)
[![](https://img.shields.io/badge/docs--English-latest-green)](https://renderbus.readthedocs.io/en/latest)
[![](https://img.shields.io/badge/license-Apache%202-blue)](http://www.apache.org/licenses/LICENSE-2.0.txt)
![](https://img.shields.io/badge/python-2.7.10+%20%7C%203.6%20%7C%203.7-blue)
![](https://img.shields.io/badge/platform-windows-lightgrey)
86 changes: 86 additions & 0 deletions help/examples/blender_demo.py
@@ -0,0 +1,86 @@
# -*- coding: utf-8 -*-
"""blender render demo."""

from rayvision_api.core import RayvisionAPI
from rayvision_api.task.check import RayvisionCheck
from rayvision_api.utils import update_task_info, append_to_task, append_to_upload
from rayvision_blender.analyze_blender import AnalyzeBlender
from rayvision_sync.download import RayvisionDownload
from rayvision_sync.upload import RayvisionUpload

# API Parameter
render_para = {
"domain": "task.renderbus.com",
"platform": "2",
"access_id": "xxxx",
"access_key": "xxxx",
}

api = RayvisionAPI(access_id=render_para['access_id'],
access_key=render_para['access_key'],
domain=render_para['domain'],
platform=render_para['platform'])

# Step1:Analyze CG File
analyze_info = {
"cg_file": r"D:\houdini\cg_file\PRAM RENDER 1.blend",
"workspace": "c:/workspace",
"software_version": "2.81",
"project_name": "Project1",
"plugin_config": {}
}
analyze_obj = AnalyzeBlender(**analyze_info)
analyze_obj.analyse(exe_path=r"C:\Program Files (x86)\Blender Foundation\Blender\blender.exe")

# step2:Add some custom parameters, or update the original parameter value
update_task = {
"pre_frames": "100",
"stop_after_test": "1",
"hardwareConfigId": "5",
}
update_task_info(update_task, analyze_obj.task_json)

custom_info_to_task = {}
append_to_task(custom_info_to_task, analyze_obj.task_json)

# User-defined UPLOAD.JSON file path
upload_json_path = r"D:\blender\upload.json"

custom_info_to_upload = [
r"D:\houdini\cg_file\PRAM RENDER 1.blend"
]

append_to_upload(custom_info_to_upload, upload_json_path)

# step3:Check json files
check_obj = RayvisionCheck(api, analyze_obj)
task_id = check_obj.execute(analyze_obj.task_json, analyze_obj.upload_json)

# Step4:Transmission
"""
There are two ways to upload the transmission:
Upload_method: 1:upload four json files and upload the resource file according to upload.json;
2:json files and resources are uploaded separately;
"""
CONFIG_PATH = {
"tips_json_path": analyze_obj.tips_json,
"task_json_path": analyze_obj.task_json,
"asset_json_path": analyze_obj.asset_json,
}
upload_obj = RayvisionUpload(api, automatic_line=True)
"""
The default of the test demo is to upload json and resource files at the same time,
and users can choose their own upload method according to the actual situation.
"""
upload_obj.upload_asset(upload_json_path=upload_json_path)
upload_obj.upload_config(str(task_id), list(CONFIG_PATH.values()))

# Step5:Submit Task
api.submit(int(task_id))

# Step6:Download
download = RayvisionDownload(api)
# All complete before the automatic start of uniform download.
# download.auto_download_after_task_completed([task_id])
# Poll download (automatic download for each completed frame)
download.auto_download([int(task_id)])
14 changes: 14 additions & 0 deletions help/examples/only_analyze_demo.py
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
"""only analyze blender"""

from rayvision_blender.analyze_blender import AnalyzeBlender

analyze_info = {
"cg_file": r"D:\houdini\cg_file\PRAM RENDER 1.blend",
"workspace": "c:/workspace",
"software_version": "2.78",
"project_name": "Project1",
"plugin_config": {}
}

AnalyzeBlender(**analyze_info).analyse(exe_path=r"C:\Program Files (x86)\Blender Foundation\Blender\blender.exe")
9 changes: 9 additions & 0 deletions init_pycharm_setup.cmd
@@ -0,0 +1,9 @@
::We need to initialize all the environments when we start the new project.
@echo off
set INDEX_URL=https://mirrors.aliyun.com/pypi/simple
set URL_HOST=mirrors.aliyun.com
call %~dp0venv\Scripts\activate.bat
call easy_install -i %INDEX_URL% --upgrade pip
call pip install -i %INDEX_URL% --trusted-host %URL_HOST% tox pre-commit
call pre-commit install
call pip install -i %INDEX_URL% %URL_HOST% -r %~dp0requirements.txt -r %~dp0dev_requirements.txt
16 changes: 16 additions & 0 deletions rayvision_blender/__init__.py
@@ -0,0 +1,16 @@
"""A Python-based API for Using Renderbus cloud rendering houdini service."""

# pylint: disable=import-error
from pkg_resources import DistributionNotFound, get_distribution

from rayvision_blender.constants import PACKAGE_NAME
from rayvision_log import init_logger

# Initialize the logger.
init_logger(PACKAGE_NAME)

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# Package is not installed.
__version__ = '0.0.0-dev.1'

0 comments on commit 02339cb

Please sign in to comment.