-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the readme and including the render restart scripts, and driv…
…e appscript utility
- Loading branch information
1 parent
c1bfe6f
commit bbd72af
Showing
6 changed files
with
411 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.blend filter=lfs diff=lfs merge=lfs -text | ||
*.png filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* Populate uploaded filenames from a form given the entry URL | ||
We need to correlate the row of an entry submission via google form to | ||
the given file that was uploaded. The form response itself only | ||
has the link to the file itself as a column value, not the filename itself. | ||
Connecting the filename to the form row data is necessary for other processes | ||
in the community render system. | ||
*/ | ||
|
||
const _SHEET_NAME = 'tsv_sheet_download'; // Name of the tab to download | ||
const _BATCH_SIZE = 100 // Number of rows to process at once. | ||
|
||
|
||
function populateAllRows(){ | ||
var ss = SpreadsheetApp.getActiveSpreadsheet(); | ||
var targetSheet = ss.getSheetByName(_SHEET_NAME); | ||
Logger.log(targetSheet) | ||
var lastRow = targetSheet.getLastRow(); | ||
Logger.log("Last row:" + lastRow.toString()); | ||
|
||
var updated = 0 | ||
for (var i = 1; i <= Math.floor(lastRow/_BATCH_SIZE); i++) { | ||
var startRow = (i - 1) * _BATCH_SIZE + 1 | ||
var endRow = startRow + _BATCH_SIZE - 1 | ||
if (endRow > lastRow){ | ||
endRow = lastRow | ||
} | ||
updated = updated + populateRow(targetSheet, startRow, endRow); | ||
} | ||
Logger.log("Done, updated " + updated.toString()) | ||
} | ||
|
||
function populateRow(sheet, startRow, endRow) { | ||
const readCol = 5; // E | ||
const writeCol = 6; // F | ||
Logger.log(startRow.toString() +", " + endRow.toString()) | ||
|
||
var readUrls = sheet.getRange(startRow, readCol, endRow-startRow+1, 1).getValues() | ||
var writeRange = sheet.getRange(startRow, writeCol, endRow-startRow+1, 1) | ||
var writeNames = writeRange.getValues() | ||
var updated = 0; | ||
|
||
for (var i = 0; i <= endRow-startRow; i++) { | ||
if (writeNames[i] != ""){ | ||
continue // data already loaded | ||
} | ||
// Logger.log('No data for index, load row '+(startRow+i).toString()); | ||
// all have prefix: https://drive.google.com/open?id= | ||
var id = readUrls[i][0].substring(33, readUrls[i][0].length); | ||
// Logger.log(id) | ||
var this_file = "" | ||
try { | ||
var this_file = DriveApp.getFileById(id) | ||
} | ||
catch(err) { | ||
Logger.log("Failed to pull id "+id.toString()+" from row "+(startRow+i).toString()) | ||
writeNames[i] = [''] | ||
continue | ||
} | ||
writeNames[i] = [this_file.getName()] | ||
updated = updated + 1; | ||
} | ||
// Logger.log("Writing names:"); | ||
// Logger.log(writeNames); | ||
writeRange.setValues(writeNames); | ||
return updated; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# ##### BEGIN GPL LICENSE BLOCK ##### | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 3 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software Foundation, | ||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# ##### END GPL LICENSE BLOCK ##### | ||
|
||
# Blender Community Render - OSX Guardian Wrapper | ||
# | ||
# Script used to auto-restart blender in case it crashes in the middle of an | ||
# execution. | ||
|
||
# Hard code this to match your local blender executable location. | ||
blender='/Applications/Blender 2.93/blender.app/Contents/MacOS/blender' | ||
|
||
# Path to where the source blend files are saved | ||
src_files='/source/blender/files_folder' | ||
|
||
# Specify the source blend file to open as the render template | ||
render_template='/path/to/render_tempalte.blend' | ||
|
||
# Assumed the source addon script is in the same directory as active directory. | ||
# Using relative path | ||
addon_py="community_render.py" | ||
|
||
# Only need to make modifications above! | ||
|
||
if [[ ! -f $blender ]] ; then | ||
echo "Blender file missing: $blender". | ||
exit | ||
fi | ||
|
||
# Auto restart blender until THIS script is closed. | ||
echo "Starting blender, will restart until this process is closed." | ||
|
||
restarter="restart_until_finished.txt" | ||
touch $restarter | ||
|
||
while true | ||
do | ||
echo "> Starting blender in 3s (ctrl c to cancel or close window)..." | ||
sleep 3 | ||
"$blender" -b "$render_template" -P startup.py -- \ | ||
-src_files "$src_files" \ | ||
-addon_py "$(pwd)/$addon_py" | ||
echo "Blender exited" | ||
# exit | ||
|
||
if [[ ! -f $restarter ]] ; then | ||
echo "Restarter file is missing, assumign render completed.". | ||
exit | ||
fi | ||
|
||
done |
Oops, something went wrong.