-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from atticus-lv/fix-4.0
- Loading branch information
Showing
26 changed files
with
750 additions
and
126 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
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
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,3 @@ | ||
import bpy | ||
from bpy.props import StringProperty, BoolProperty, EnumProperty | ||
|
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,41 @@ | ||
import argparse | ||
import bpy | ||
import sys | ||
|
||
|
||
def main(args): | ||
print("Script args: ", args) | ||
|
||
if len(args) > 0: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('blend') | ||
parser.add_argument('--pack', action='append') | ||
args = parser.parse_args(args) | ||
|
||
blend = args.blend | ||
|
||
print(f"Blend to fix: {blend}") | ||
|
||
bpy.ops.wm.open_mainfile(filepath=blend) | ||
|
||
# pack | ||
bpy.ops.file.pack_all() | ||
try: | ||
bpy.ops.file.pack_libraries() | ||
except Exception as e: | ||
print(e) | ||
|
||
for o in bpy.data.objects: | ||
bpy.context.scene.collection.objects.link(o) | ||
|
||
bpy.context.view_layer.update() | ||
bpy.context.preferences.filepaths.save_version = 0 # No backup blends needed | ||
bpy.ops.wm.save_as_mainfile(filepath=blend, compress=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
if "--" not in sys.argv: | ||
argv = [] # as if no args are passed | ||
else: | ||
argv = sys.argv[sys.argv.index("--") + 1:] # get all args after "--" | ||
main(argv) |
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,41 @@ | ||
import argparse | ||
import bpy | ||
import sys | ||
|
||
|
||
def main(args): | ||
print("Script args: ", args) | ||
|
||
if len(args) > 0: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('blend') | ||
parser.add_argument('--pack', action='append') | ||
args = parser.parse_args(args) | ||
|
||
blend = args.blend | ||
|
||
print(f"Blend to fix: {blend}") | ||
|
||
bpy.ops.wm.open_mainfile(filepath=blend) | ||
|
||
# pack | ||
bpy.ops.file.pack_all() | ||
try: | ||
bpy.ops.file.pack_libraries() | ||
except Exception as e: | ||
print(e) | ||
|
||
for o in bpy.data.objects: | ||
bpy.data.objects.remove(o) | ||
|
||
bpy.context.view_layer.update() | ||
bpy.context.preferences.filepaths.save_version = 0 # No backup blends needed | ||
bpy.ops.wm.save_as_mainfile(filepath=blend, compress=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
if "--" not in sys.argv: | ||
argv = [] # as if no args are passed | ||
else: | ||
argv = sys.argv[sys.argv.index("--") + 1:] # get all args after "--" | ||
main(argv) |
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,63 @@ | ||
import argparse | ||
import bpy | ||
import sys | ||
from math import floor | ||
|
||
|
||
def main(argv): | ||
FILEPATH,OUTPATH, SIZE_X, SCALE, COLORSPACE = argv | ||
SIZE_X = int(SIZE_X) | ||
SCALE = float(SCALE) | ||
|
||
context = bpy.context | ||
scene = context.scene | ||
|
||
scene.use_nodes = True | ||
node_tree = scene.node_tree | ||
|
||
# Remove default nodes, except composite | ||
n_comp = None | ||
for n in node_tree.nodes: | ||
if not n.type == 'COMPOSITE': | ||
node_tree.nodes.remove(n) | ||
else: | ||
n_comp = n | ||
|
||
img = bpy.data.images.load(FILEPATH) | ||
n_img = node_tree.nodes.new("CompositorNodeImage") | ||
n_img.image = img | ||
|
||
n_blur = node_tree.nodes.new("CompositorNodeBlur") | ||
n_blur.filter_type = 'FLAT' | ||
n_blur.size_x = floor(img.size[0] / SIZE_X / 2) | ||
n_blur.size_y = n_blur.size_x | ||
|
||
n_scale = node_tree.nodes.new("CompositorNodeScale") | ||
n_scale.space = "RENDER_SIZE" | ||
n_scale.frame_method = "CROP" | ||
|
||
# Links | ||
links = node_tree.links | ||
links.new(n_img.outputs[0], n_blur.inputs[0]) | ||
links.new(n_blur.outputs[0], n_scale.inputs[0]) | ||
links.new(n_scale.outputs[0], n_comp.inputs[0]) | ||
|
||
# Render | ||
r = scene.render | ||
r.image_settings.file_format = 'JPEG' | ||
r.image_settings.quality = 95 | ||
r.resolution_x = SIZE_X | ||
r.resolution_y = int(SIZE_X / SCALE) | ||
r.resolution_percentage = 100 | ||
r.filepath = OUTPATH | ||
scene.view_settings.view_transform = COLORSPACE | ||
|
||
bpy.ops.render.render(write_still=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
if "--" not in sys.argv: | ||
argv = [] # as if no args are passed | ||
else: | ||
argv = sys.argv[sys.argv.index("--") + 1:] # get all args after "--" | ||
main(argv) |
File renamed without changes.
File renamed without changes.
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,11 @@ | ||
# This file is the config file for blender 4.0 | ||
# Define the default category for import and export | ||
# !include will include the yaml file in the same directory | ||
# Check the yaml file for more format details | ||
|
||
# version: 0.1 | ||
version: 0.1 | ||
|
||
Import: !include ./import_default.yaml | ||
Export: !include ./export_default.yaml | ||
Import-spio: !include ./import_spio.yaml |
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,104 @@ | ||
# config for default importer | ||
# example for custom importer config using bpy.ops.wm.obj_import() | ||
|
||
# English Example: | ||
# Wavefront (.obj) name must be unique | ||
# bl_idname: 'wm.obj_import' bl_idname, call this operator | ||
# icon: 'EXPORT' icon, use blender icon | ||
# category, use blender category | ||
# file_types: {'obj'} file_types, file extension | ||
# args: args, arguments for operator, default pass in 'filepath' | ||
# pre_script: pre_script, run before operator | ||
# post_script: post_script, run after operator | ||
|
||
# Chinese Example: | ||
# 导出Obj (.obj) 名称必须唯一 | ||
# bl_idname: 'wm.obj_import' bl_idname, 调用这个操作 | ||
# icon: 'EXPORT' icon, 使用blender图标 | ||
# category, 使用blender分类 | ||
# file_types: {'obj'} file_types, 文件扩展名 | ||
# args: args, 操作的参数, 默认传入'filepath' | ||
# pre_script: pre_script, 在操作前运行 | ||
# post_script: post_script, 在操作后运行 | ||
|
||
Collada (.dae): | ||
bl_idname: 'wm.collada_export' | ||
icon: 'EXPORT' | ||
file_types: { 'dae' } | ||
pre_script: | ||
post_script: | ||
args: | ||
selected: True | ||
|
||
Alembic (.abc): | ||
bl_idname: 'wm.alembic_export' | ||
icon: 'EXPORT' | ||
file_types: { 'abc' } | ||
pre_script: | ||
post_script: | ||
args: | ||
selected: True | ||
|
||
USD (.usd): | ||
bl_idname: 'wm.usd_export' | ||
icon: 'EXPORT' | ||
file_types: { 'usd', 'usda', 'usdc' } | ||
pre_script: | ||
post_script: | ||
args: | ||
selected_objects_only: True | ||
|
||
Stanford (.ply): | ||
bl_idname: 'import_mesh.ply' | ||
icon: 'EXPORT' | ||
file_types: { 'ply' } | ||
pre_script: | ||
post_script: | ||
args: | ||
use_selection: True | ||
|
||
Stl (.stl): | ||
bl_idname: 'import_mesh.stl' | ||
icon: 'EXPORT' | ||
file_types: { 'stl' } | ||
pre_script: | ||
post_script: | ||
args: | ||
use_selection: True | ||
|
||
FBX (.fbx): | ||
bl_idname: 'import_scene.fbx' | ||
icon: 'EXPORT' | ||
file_types: { 'fbx' } | ||
pre_script: | ||
post_script: | ||
args: | ||
use_selection: True | ||
|
||
Wavefront (.obj): | ||
bl_idname: 'wm.obj_export' | ||
icon: 'EXPORT' | ||
file_types: { 'obj' } | ||
pre_script: | ||
post_script: | ||
args: | ||
use_selection: True | ||
|
||
glTF 2.0 (.gltf/.glb): | ||
bl_idname: 'export_scene.gltf' | ||
icon: 'EXPORT' | ||
file_types: { 'gltf'} | ||
pre_script: | ||
post_script: | ||
args: | ||
use_selection: True | ||
export_format: GLTF_EMBEDDED | ||
|
||
X3D (.x3d/.wrl): | ||
bl_idname: 'export_scene.x3d' | ||
icon: 'EXPORT' | ||
file_types: {'x3d'} | ||
pre_script: | ||
post_script: | ||
args: | ||
|
Oops, something went wrong.