Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blender: Implement 'compress' settings extract blend #166

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class ExtractBlend(publish.Extractor, publish.OptionalPyblishPluginMixin):
families = ["model", "camera", "rig", "action", "layout", "blendScene"]
optional = True

# From settings
compress = False

def process(self, instance):
if not self.is_active(instance.data):
return
Expand Down Expand Up @@ -53,7 +56,7 @@ def process(self, instance):
if node.image and node.image.packed_file is None:
node.image.pack()

bpy.data.libraries.write(filepath, data_blocks)
bpy.data.libraries.write(filepath, data_blocks, compress=self.compress)

if "representations" not in instance.data:
instance.data["representations"] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class ExtractBlendAnimation(
families = ["animation"]
optional = True

# From settings
compress = False

def process(self, instance):
if not self.is_active(instance.data):
return
Expand Down Expand Up @@ -46,7 +49,7 @@ def process(self, instance):
data_blocks.add(child.animation_data.action)
data_blocks.add(obj)

bpy.data.libraries.write(filepath, data_blocks)
bpy.data.libraries.write(filepath, data_blocks, compress=self.compress)

if "representations" not in instance.data:
instance.data["representations"] = []
Expand Down
19 changes: 15 additions & 4 deletions server_addon/blender/server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,22 @@ class ExtractBlendModel(BaseSettingsModel):
default_factory=list,
title="Families"
)
compress: bool = SettingsField(True, title="Compress")


class ExtractBlendAnimationModel(BaseSettingsModel):
enabled: bool = SettingsField(True)
optional: bool = SettingsField(title="Optional")
active: bool = SettingsField(title="Active")
compress: bool = SettingsField(False, title="Compress")


class ExtractPlayblastModel(BaseSettingsModel):
enabled: bool = SettingsField(True)
optional: bool = SettingsField(title="Optional")
active: bool = SettingsField(title="Active")
presets: str = SettingsField("", title="Presets", widget="textarea")
compress: bool = SettingsField(False, title="Compress")

@validator("presets")
def validate_json(cls, value):
Expand Down Expand Up @@ -110,8 +119,8 @@ class PublishPuginsModel(BaseSettingsModel):
default_factory=ValidatePluginModel,
title="Extract ABC"
)
ExtractBlendAnimation: ValidatePluginModel = SettingsField(
default_factory=ValidatePluginModel,
ExtractBlendAnimation: ExtractBlendAnimationModel = SettingsField(
default_factory=ExtractBlendAnimationModel,
title="Extract Blend Animation"
)
ExtractAnimationFBX: ValidatePluginModel = SettingsField(
Expand Down Expand Up @@ -198,7 +207,8 @@ class PublishPuginsModel(BaseSettingsModel):
"action",
"layout",
"blendScene"
]
],
"compress": False
},
"ExtractFBX": {
"enabled": False,
Expand All @@ -213,7 +223,8 @@ class PublishPuginsModel(BaseSettingsModel):
"ExtractBlendAnimation": {
"enabled": True,
"optional": True,
"active": True
"active": True,
"compress": False
},
"ExtractAnimationFBX": {
"enabled": False,
Expand Down
2 changes: 1 addition & 1 deletion server_addon/blender/server/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.6"
__version__ = "0.1.7"