Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Publish attributes in alembic cache (option)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-Duduf committed Dec 14, 2023
1 parent fc430d0 commit 70cc146
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off
:: Builds the module (copies needed files) to the build subfolder,

SET version=0.8.22-Beta
SET version=0.8.30-Beta

:: The repo (current dir)
SET repoPath=%~dp0
Expand Down
1 change: 1 addition & 0 deletions plug-ins/dumaf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .namespaces import Namespace
from . import animation
from . import rendering
from . import attributes
from .references import Reference
from .ui_progress import ProgressDialog
from . import mayapy
Expand Down
2 changes: 1 addition & 1 deletion plug-ins/dumaf/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_framerate():


return 1

def set_framerate(fps):
if type(fps) == int or type(fps) == float:
fps=str(fps)+'fps'
Expand Down
47 changes: 47 additions & 0 deletions plug-ins/dumaf/attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-

# ====================== 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, see <http://www.gnu.org/licenses/>.
#
# ======================= END GPL LICENSE BLOCK ========================

"""Tools to handle node attributes"""

import maya.cmds as cmds # pylint: disable=import-error

def get_all_extra( root_node_path, recursive=True):
"""List all extra attributes in this node (and its children)"""

# List this node attributes
attributes = cmds.listAttr(root_node_path, userDefined=True)
if attributes is None:
attributes = set()
else:
attributes = set(attributes)

# Recursion
if recursive:
children = cmds.listRelatives(
root_node_path,
ad=recursive,
fullPath=True
)
if not children:
return set(attributes)
for child in children:
child_attrs = get_all_extra( child, recursive=False)
attributes.update(child_attrs)

return attributes
50 changes: 42 additions & 8 deletions plug-ins/ramses_maya/publish_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,25 +396,59 @@ def publish_alembic(node, options, publish_info, name):
if get_option("world_space", options, True):
worldSpace = '-worldSpace'

abc_options = ' '.join([
'-frameRange ' + str(in_frame) + ' ' + str(out_frame),
attributes = set()
if get_option("add_extra_attributes", options, False):
# List all the extra attributes on all the nodes
attributes = maf.attributes.get_all_extra(node.path(), recursive=True)

attributes.update( get_option(
"attributes",
options,
set())
)

attrs_prefix = set(get_option(
"attributes_prefix",
options,
set())
)

abc_options = []
for attr in attributes:
attr = attr.strip()
if attr == '':
continue
abc_options.append("-attr")
abc_options.append(attr)

for pref in attrs_prefix:
pref = pref.strip()
if pref == '':
continue
abc_options.append("-attrPrefix ")
abc_options.append(pref)

abc_options = abc_options + [
'-frameRange', str(in_frame), str(out_frame),
filter_euler,
worldSpace,
'-step ' + str(frame_step),
'-step', str(frame_step),
'-autoSubd', # crease
'-uvWrite',
'-writeUVSets',
'-writeVisibility',
'-dataFormat hdf',
renderable,
'-root ' + node.path(),
'-file "' + file_path + '"',
])
'-root', node.path(),
'-file', '"' + file_path + '"',
]

abc_options_str = ' '.join( abc_options )

ram.log("These are the alembic options:\n" + abc_options, ram.LogLevel.Info)
ram.log("These are the alembic options:\n" + abc_options_str, ram.LogLevel.Info)

# Export
cmds.AbcExport(j=abc_options)
cmds.AbcExport(j=abc_options_str)
# Meta data
set_export_metadata( file_path, publish_info)

Expand Down
32 changes: 31 additions & 1 deletion plug-ins/ramses_maya/ui_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,20 @@ def __setup_ui(self):
alembic_layout.addRow("Frame step:", self.__ui_alembic_frame_step_box)

self.__ui_alembic_filter_euler_box = QCheckBox("Filter Euler rotations")
alembic_layout.addRow("", self.__ui_alembic_filter_euler_box)
alembic_layout.addRow("Rotations:", self.__ui_alembic_filter_euler_box)

self.__ui_abc_custom_attr_box = QCheckBox("Automatically add all custom/extra attributes")
alembic_layout.addRow("Custom Attributes:", self.__ui_abc_custom_attr_box)

self.__ui_abc_attr_edit = QTextEdit()
self.__ui_abc_attr_edit.setPlaceholderText("Add all the attributes with these exact names.\nOne attribute per line.")
self.__ui_abc_attr_edit.setMaximumHeight(100)
alembic_layout.addRow("Attributes:", self.__ui_abc_attr_edit)

self.__ui_abc_prefix_edit = QTextEdit()
self.__ui_abc_prefix_edit.setPlaceholderText("Add all the attributes with these prefix in their names.\nOne prefix per line.")
self.__ui_abc_prefix_edit.setMaximumHeight(100)
alembic_layout.addRow("Attributes prefix:", self.__ui_abc_prefix_edit)

# <-- OBJ -->

Expand Down Expand Up @@ -382,6 +395,9 @@ def __connect_events(self):
self.__ui_alembic_handle_end_box.valueChanged.connect( self.__update_preset )
self.__ui_alembic_frame_step_box.valueChanged.connect( self.__update_preset )
self.__ui_alembic_filter_euler_box.toggled.connect( self.__update_preset )
self.__ui_abc_custom_attr_box.toggled.connect( self.__update_preset )
self.__ui_abc_attr_edit.textChanged.connect( self.__update_preset )
self.__ui_abc_prefix_edit.textChanged.connect( self.__update_preset )

def __set_maya_defaults(self, frmt="mb"):
self.__ui_maya_scene_box.setChecked(True)
Expand All @@ -402,6 +418,9 @@ def __set_alembic_defaults(self):
self.__ui_alembic_handle_end_box.setValue(0)
self.__ui_alembic_frame_step_box.setValue(1)
self.__ui_alembic_filter_euler_box.setChecked(True)
self.__ui_abc_attr_edit.setText("")
self.__ui_abc_prefix_edit.setText("")
self.__ui_abc_custom_attr_box.setChecked(False)

def __set_obj_defaults(self):
self.__ui_obj_mtl_box.setChecked(True)
Expand Down Expand Up @@ -595,6 +614,10 @@ def get_alembic_options(self):

abc["filter_euler_rotations"] = self.__ui_alembic_filter_euler_box.isChecked()

abc["add_extra_attributes"] = self.__ui_abc_custom_attr_box.isChecked()
abc["attributes"] = self.__ui_abc_attr_edit.toPlainText().split("\n")
abc["attributes_prefix"] = self.__ui_abc_prefix_edit.toPlainText().split("\n")

options[ "abc" ] = abc
return options

Expand Down Expand Up @@ -733,6 +756,13 @@ def set_options(self, options):
load_number_preset( "frame_step", anim, self.__ui_alembic_frame_step_box, 1)
load_number_preset( "handle_in", anim, self.__ui_alembic_handle_start_box, 1)
load_number_preset( "handle_out", anim, self.__ui_alembic_handle_end_box, 1)
load_bool_preset("add_extra_attributes", frmt, self.__ui_abc_custom_attr_box, False)
if "attributes" in frmt:
attrs_str = "\n".join(options["attributes"])
self.__ui_abc_attr_edit.setPlainText(attrs_str)
if "attributes_prefix" in frmt:
pref_str = "\n".join(options["attributes_prefix"])
self.__ui_abc_prefix_edit.setPlainText(pref_str)

# <-- ASS -->

Expand Down

0 comments on commit 70cc146

Please sign in to comment.