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

Collect component #31

Merged
merged 11 commits into from
Jun 14, 2016
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
65 changes: 65 additions & 0 deletions dialogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ def set_icons():
global simple_warning_icon
global massage_icon
global users_icon
global archive_icon
global new_icon

warning_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"critical"))
simple_warning_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"warning"))
massage_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"massage"))
users_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"users"))
archive_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"archive"))
new_icon = QtGui.QPixmap(os.path.join(localIconPath, "%s.svg"%"new"))

def warning(icon, title, message ):

Expand Down Expand Up @@ -120,6 +125,9 @@ def __init__(self, parent = None, title = None):
self.setMinimumWidth(200)
self.setMaximumHeight(50)

self.label = QtGui.QLabel()
self.label.setPixmap(new_icon)

layout = QtGui.QVBoxLayout(self)
self.item_name = QtGui.QLabel(title)
self.text_input = QtGui.QLineEdit()
Expand All @@ -128,10 +136,12 @@ def __init__(self, parent = None, title = None):
self.exclude_radio = QtGui.QRadioButton("Include only textures")



layout.addWidget(self.item_name)
layout.addWidget(self.text_input)
layout.addWidget(self.include_radio)
layout.addWidget(self.exclude_radio)


buttons = QtGui.QDialogButtonBox(
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel,
Expand All @@ -149,7 +159,62 @@ def radio_selection(self):
def result(self):
return self.text_input.text(), self.radio_selection()

class collect_component_options(QtGui.QDialog):
def __init__(self, parent = None, title = None):
super(collect_component_options, self).__init__(parent)


self.setMaximumWidth(200)
self.setMinimumWidth(200)
self.setMaximumHeight(50)

self.label = QtGui.QLabel()
self.label.setPixmap(archive_icon)

layout = QtGui.QVBoxLayout(self)
self.item_name = QtGui.QLabel(title)

self.include_reference = QtGui.QCheckBox("Include referenced files")
self.include_reference.setChecked(True)
self.include_textures = QtGui.QCheckBox("Include textures")
self.include_textures.setChecked(True)


layout.addWidget(self.label)
layout.addStretch()
layout.addWidget(self.item_name)

layout.addWidget(self.HLine())
layout.addWidget(self.include_reference)
layout.addWidget(self.include_textures)

buttons = QtGui.QDialogButtonBox(
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel,
QtCore.Qt.Horizontal, self)
buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject)
layout.addWidget(buttons)

def options(self):
references = False
textures = False

if self.include_reference.isChecked():
references = True
if self.include_textures.isChecked():
textures = True

return references, textures


def result(self):
return self.options()

def HLine(self):
toto = QtGui.QFrame()
toto.setFrameShape(QtGui.QFrame.HLine)
toto.setFrameShadow(QtGui.QFrame.Sunken)
return toto

class Login(QtGui.QDialog):
def __init__(self, parent=None):
Expand Down
4 changes: 4 additions & 0 deletions icons/archive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 35 additions & 3 deletions modules/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import operator
import sys
import subprocess

import glob

def dir_rename(dir_fullpath, new_name):

Expand Down Expand Up @@ -88,7 +88,10 @@ def file_rename(fullpath, new_name):

def file_copy(source, dest):
if os.path.exists(source):
return shutil.copy2(source, dest)
try:
return shutil.copy2(source, dest)
except:
return None
else:
return None

Expand Down Expand Up @@ -164,6 +167,18 @@ def list_dir_folders(path):
return [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))]


def assure_path_exists(path):
dir = os.path.dirname(path)
if not os.path.exists(dir):
os.makedirs(dir)

def assure_folder_exists(path):
if not os.path.exists(path):
os.makedirs(path)

def reletive_path(absolute_path, path):
return os.path.relpath(path, absolute_path)

def create_directory(path):

if not os.path.exists(path):
Expand Down Expand Up @@ -255,4 +270,21 @@ def explore(path):
os.startfile(path)



def get_pipe_file_from_folder_or_parent_folder(path):

dir = os.path.dirname(path)
file = os.path.join(dir,"*.pipe")


if len(glob.glob(file)) == 1: #if its a master
return glob.glob(file)[0]

dir = os.path.dirname(dir)
file = os.path.join(dir,"*.pipe")

if len(glob.glob(file)) == 1: #if its a version
return glob.glob(file)[0]

return None


33 changes: 31 additions & 2 deletions modules/maya_warpper.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,36 @@ def import_scene(path = None):
namesspace = files.file_name_no_extension(files.file_name(path))
return cmds.file(path, i = True, f = True, ns = namesspace, esn = False)


def list_referenced_files():
results = []
links = cmds.filePathEditor(query=True, listDirectories="")
for link in links:
pairs = cmds.filePathEditor(query=True, listFiles=link, withAttribute=True, status=True)
'''
paris: list of strings ["file_name node status ...", "file_name node status ...",...]
we need to make this large list of ugly strings (good inforamtion seperated by white space) into a dictionry we can use
'''
l = len(pairs)
items = l/3
order = {}
index = 0

'''
order: dict of {node: [file_name, status],...}
'''

for i in range(0,items):
order[pairs[index+1]] = [os.path.join(link,pairs[index]),pairs[index+1],pairs[index+2]]
index = index + 3

for key in order:
# for each item in the dict, if the status is 0, repath it
if order[key][2] == "1":
results.append([order[key][0],cmds.nodeType(order[key][1])])

return results


def relink_pathes(project_path = None):
results = []
Expand Down Expand Up @@ -141,8 +170,8 @@ def relink_pathes(project_path = None):
if repath(key,order[key][0],project_path):
results.append(key)

return results

return results



Expand Down
Loading