Updated
This commit is contained in:
35
Scripts/Animation/dwpicker/scripts/change_namespace.py
Normal file
35
Scripts/Animation/dwpicker/scripts/change_namespace.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""
|
||||
The multiple nested namespaces is currently not supported by the namespace
|
||||
switch system. This can cause issue for picker having to support sub namespace
|
||||
on part of the rig.
|
||||
This piece of code allow to set manually a namespace through the selected
|
||||
shapes"""
|
||||
|
||||
|
||||
import dwpicker
|
||||
|
||||
namespace = 'write:nested:namespace:here'
|
||||
picker = dwpicker.current()
|
||||
|
||||
## Edit Shapes from picker view selection
|
||||
|
||||
# selection = [s for s in picker.shapes if s.selected]
|
||||
# for shape in selection:
|
||||
# targets = [namespace + ':' + t.split(':')[-1] for t in shape.targets()]
|
||||
# shape.options['action.targets'] = targets
|
||||
|
||||
# dwpicker._dwpicker.data_changed_from_picker(picker)
|
||||
|
||||
## Edit Shapes from advanced editor selection
|
||||
|
||||
index = dwpicker._dwpicker.pickers.index(picker)
|
||||
editor = dwpicker._dwpicker.editors[index]
|
||||
if editor is None:
|
||||
raise RuntimeWarning("Please open current picker's avanced editor")
|
||||
|
||||
selection = editor.shape_editor.selection
|
||||
for shape in selection:
|
||||
targets = [namespace + ':' + t.split(':')[-1] for t in shape.targets()]
|
||||
shape.options['action.targets'] = targets
|
||||
|
||||
editor.set_data_modified()
|
24
Scripts/Animation/dwpicker/scripts/clean_reload_dwpicker.py
Normal file
24
Scripts/Animation/dwpicker/scripts/clean_reload_dwpicker.py
Normal file
@ -0,0 +1,24 @@
|
||||
"""
|
||||
A developper hack to reload the Dreamwall picker without having to restart
|
||||
Maya each time.
|
||||
"""
|
||||
|
||||
|
||||
# If the picker is not in a known PYTHONPATH.
|
||||
import sys
|
||||
sys.path.insert(0, "<dwpicker path>")
|
||||
|
||||
# Code to clean modules and relaunch a Dreamwall picker with updated code.
|
||||
try:
|
||||
# Important step to not let some callbacks left behind.
|
||||
dwpicker.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
for module in list(sys.modules):
|
||||
if "dwpicker" in module:
|
||||
print("deleted: " + module)
|
||||
del sys.modules[module]
|
||||
|
||||
import dwpicker
|
||||
dwpicker.show()
|
@ -0,0 +1,13 @@
|
||||
# This code as to be ran in a Maya able to use 'dwpicker' package.
|
||||
import os
|
||||
from dwpicker.ingest import animschool
|
||||
|
||||
|
||||
SOURCE_DIRECTORY = "" # Replace those variables before conversion
|
||||
DESTINATION_DIRECTORY = ""
|
||||
|
||||
for f in os.listdir(SOURCE_DIRECTORY):
|
||||
if not f.lower().endswith(".pkr"):
|
||||
continue
|
||||
filepath = os.path.join(SOURCE_DIRECTORY, f)
|
||||
animschool.convert(filepath, DESTINATION_DIRECTORY)
|
33
Scripts/Animation/dwpicker/scripts/create_buttons.py
Normal file
33
Scripts/Animation/dwpicker/scripts/create_buttons.py
Normal file
@ -0,0 +1,33 @@
|
||||
import dwpicker
|
||||
from dwpicker.scenedata import load_local_picker_data, store_local_picker_data
|
||||
from dwpicker.templates import BUTTON
|
||||
|
||||
|
||||
def add_button(index, options, refresh_ui=True):
|
||||
"""
|
||||
This works with pick closed as well.
|
||||
@param int index: the tab position of the dwpicker.
|
||||
@param dict options:
|
||||
This is a dictionnary of the shape options. List of possible options
|
||||
are can be found here dwpicker.templates.BUTTON
|
||||
(too much very many long to be documented here ;) )
|
||||
@param bool refresh_ui:
|
||||
this update the ui. Can be disabled for loop purpose.
|
||||
"""
|
||||
pickers = load_local_picker_data()
|
||||
button = BUTTON.copy()
|
||||
button.update(options)
|
||||
pickers[index]['shapes'].append(button)
|
||||
store_local_picker_data(pickers)
|
||||
if refresh_ui:
|
||||
dwpicker.refresh()
|
||||
|
||||
|
||||
options = {
|
||||
'text.content': 'Button',
|
||||
'shape.left': 250,
|
||||
'shape.top': 150,
|
||||
'shape.width': 120.0,
|
||||
'shape.height': 25.0,
|
||||
}
|
||||
add_button(0, options)
|
@ -0,0 +1,7 @@
|
||||
import dwpicker
|
||||
from dwpicker.picker import detect_picker_namespace
|
||||
|
||||
|
||||
picker = dwpicker.current()
|
||||
if picker:
|
||||
namespace = detect_picker_namespace(picker.shapes)
|
@ -0,0 +1,22 @@
|
||||
# Example for td which would like to create a include a picker in a custom ui
|
||||
# this is most simple case possible to have it functionnal without using the
|
||||
# main application.
|
||||
|
||||
import json
|
||||
from dwpicker.interactive import Shape
|
||||
from dwpicker.picker import PickerView
|
||||
from dwpicker.qtutils import set_shortcut
|
||||
from PySide2 import QtCore
|
||||
|
||||
with open('-picker_file_path-', 'r') as f:
|
||||
data = json.load(f)
|
||||
shapes = [Shape(shape) for shape in data['shapes']]
|
||||
|
||||
view = PickerView(editable=False)
|
||||
view.register_callbacks()
|
||||
view.setWindowFlags(QtCore.Qt.Tool)
|
||||
view.set_shapes(shapes)
|
||||
view.reset()
|
||||
set_shortcut('F', view, view.reset)
|
||||
|
||||
view.show()
|
Reference in New Issue
Block a user