This commit is contained in:
2025-04-17 04:52:48 +08:00
commit 9985b73dc1
3708 changed files with 2387532 additions and 0 deletions

View File

@ -0,0 +1,238 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2023/03/30 10:00
# @Author : Jerry Tsai
# @Site : VIRTUOUS
# @Software: Maya2022
# @Title : NewTask
# @Version : Release 1.0
import maya.cmds as cmds
import pymel.core as pm
import importlib
import os
import sys
# #importlib.reload(sys)
sys.path.append("../..")
sys.path.append("..")
DockControl = 'DockControl'
window_name = 'NewTask'
window_title = 'NewTask'
column_01 = 'NewTask'
DefaultSubFolder = ["01_Brief",
"02_MP",
"02_MP/Screenshot",
"03_HP",
"03_HP/Screenshot",
"04_LP",
"04_LP/Screenshot",
"05_Bake",
"05_Bake/Screenshot",
"05_Bake/HP&LP",
"06_Texture",
"06_Texture/Screenshot",
"06_Texture/MeshMaps",
"06_Texture/SP",
"08_Engine",
"08_Engine/Screenshot",
"08_Engine/FBX",
"08_Engine/Assets"]
CharacterFolder = ["01_Brief",
"02_MP",
"02_MP/Screenshot",
"03_HP",
"03_HP/Screenshot",
"04_LP",
"04_LP/Screenshot",
"05_Bake",
"05_Bake/Screenshot",
"05_Bake/HP&LP",
"06_Texture",
"06_Texture/Screenshot",
"06_Texture/MeshMaps",
"06_Texture/SP",
"08_Engine",
"08_Engine/Screenshot",
"08_Engine/FBX",
"08_Engine/Assets"]
WeaponFolder = ["01_Brief",
"02_MP",
"02_MP/Screenshot",
"03_HP",
"03_HP/Screenshot",
"04_LP",
"04_LP/Screenshot",
"05_Bake",
"05_Bake/Screenshot",
"05_Bake/HP&LP",
"06_Texture",
"06_Texture/Screenshot",
"06_Texture/MeshMaps",
"06_Texture/SP",
"08_Engine",
"08_Engine/Screenshot",
"08_Engine/FBX",
"08_Engine/Assets"]
PropFolder = ["01_Brief",
"02_MP",
"02_MP/Screenshot",
"03_HP",
"03_HP/Screenshot",
"04_LP",
"04_LP/Screenshot",
"05_Bake",
"05_Bake/Screenshot",
"05_Bake/HP&LP",
"06_Texture",
"06_Texture/Screenshot",
"06_Texture/MeshMaps",
"06_Texture/SP",
"08_Engine",
"08_Engine/Screenshot",
"08_Engine/FBX",
"08_Engine/Assets"]
EnvironmentFolder = ["01_Brief",
"02_MP",
"02_MP/Screenshot",
"03_HP",
"03_HP/Screenshot",
"04_LP",
"04_LP/Screenshot",
"05_Bake",
"05_Bake/Screenshot",
"05_Bake/HP&LP",
"06_Texture",
"06_Texture/Screenshot",
"06_Texture/MeshMaps",
"06_Texture/SP",
"08_Engine",
"08_Engine/Screenshot",
"08_Engine/FBX",
"08_Engine/Assets"]
AnimationFolder = ["FBX",
"Maya",
"Mocap",
"Reference",
"Approved/FBX",
"Approved/Maya"]
RiggingFolder = ["Resource",
"Resource/ma",
"Resource/textures",
"Rig",
"Skin"]
OtherFolder = ["01_Brief",
"02_MP",
"02_MP/Screenshot",
"03_HP",
"03_HP/Screenshot",
"04_LP",
"04_LP/Screenshot",
"05_Bake",
"05_Bake/Screenshot",
"05_Bake/HP&LP",
"06_Texture",
"06_Texture/Screenshot",
"06_Texture/MeshMaps",
"06_Texture/SP",
"08_Engine",
"08_Engine/Screenshot",
"08_Engine/FBX",
"08_Engine/Assets"]
# ???
def create(Workspace, TaskType, Project, Task, SubFolder):
WorkspacePath = cmds.textFieldGrp(Workspace, q=True, text=True).replace("\\", "/")
TaskTypePath = cmds.optionMenuGrp(TaskType, q=True, v=True).replace("\\", "/")
ProjectPath = cmds.textFieldGrp(Project, q=True, text=True).replace("\\", "/")
TaskPath = cmds.textFieldGrp(Task, q=True, text=True).replace("\\", "/")
if TaskTypePath == "Character":
SubFolder = CharacterFolder
elif TaskTypePath == "Weapon":
SubFolder = WeaponFolder
elif TaskTypePath == "Prop":
SubFolder = PropFolder
elif TaskTypePath == "Environment":
SubFolder = EnvironmentFolder
elif TaskTypePath == "Animation":
SubFolder = AnimationFolder
elif TaskTypePath == "Rigging":
SubFolder = RiggingFolder
elif TaskTypePath == "Other":
SubFolder = OtherFolder
TaskPath = WorkspacePath + "/" + ProjectPath + "/" + TaskTypePath + "/" + TaskPath
SubFolderPath = [TaskPath + "/" + i for i in SubFolder]
def create_sub_folder(sub_folder_path):
for i in sub_folder_path:
if os.path.exists(i):
pass
else:
os.makedirs(i)
if os.path.exists(TaskPath):
create_sub_folder(SubFolderPath)
os.startfile(TaskPath)
print("Task Path: ", TaskPath)
else:
os.makedirs(TaskPath)
create_sub_folder(SubFolderPath)
os.startfile(TaskPath)
print("Task Path: ", TaskPath)
def window_content():
SubFolder = DefaultSubFolder
cmds.text(l='', h=5, bgc=[0.1, 0.15, 0.25])
cmds.text(l=u"««««««« ========== New Task ========== »»»»»»", h=30, bgc=[0.1, 0.15, 0.25])
cmds.text(l='', h=5, bgc=[0.1, 0.15, 0.25])
cmds.text("----------------------------------------------------------------------")
cmds.text(l='', h=5)
# ????????
cmds.text(" How to use:", align="left")
cmds.text(" 1. Enter the work path, the default is “D:\\Workspace” .", align="left")
cmds.text(" 2. Select the task type.", align="left")
cmds.text(" 3. Enter the project name, the default is “Project01”", align="left")
cmds.text(" 4. Enter the task name, the default is “Character_001”", align="left")
cmds.text(u" 5. Click the “Create” button to complete", align="left")
cmds.text("----------------------------------------------------------------------")
cmds.text(l='', h=5)
Workspace = cmds.textFieldGrp(label="Workspace : ", text="D:\\Workspace").replace("\\", "/")
Project = cmds.textFieldGrp(label="ProjectName : ", text="Project_001")
def change(*args):
task_type_path = cmds.optionMenuGrp(TaskType, q=True, v=True)
cmds.textFieldGrp(Task, e=True, text=task_type_path + "_001")
TaskType = cmds.optionMenuGrp(label="TaskType : ", cc=change)
cmds.menuItem(label="Character")
cmds.menuItem(label="Weapon")
cmds.menuItem(label="Prop")
cmds.menuItem(label="Environment")
cmds.menuItem(label="Animation")
cmds.menuItem(label="Rigging")
cmds.menuItem(label="Other")
TaskTypePath = cmds.optionMenuGrp(TaskType, q=True, v=True)
cmds.textFieldGrp(Project, q=True, text=True)
Task = cmds.textFieldGrp(label="TaskName : ", text=TaskTypePath + "_001")
cmds.text(l='', h=10)
cmds.button(label="Create", c=lambda *args: create(Workspace, TaskType, Project, Task, SubFolder))
cmds.text(l='', h=10)
class window_class(object):
def __init__(self):
self.win = None
self.create_window()
def create_window(self):
global window_name
global window_title
global column_01
global DefaultSubFolder
if pm.window(window_name, query=True, exists=True):
pm.deleteUI(window_name)
self.win = pm.window(window_name, title=window_title, sizeable=True)
pm.columnLayout(adjustableColumn=True)
window_content()
pm.showWindow(self.win)
if __name__ == "__main__":
window_class()

View File

@ -0,0 +1,417 @@
'''
from importlib import reload
import Rename
reload(Rename)
Rename.UI()
'''
# from Modeling.Manage import Rename
# this text can be entered from the script editor and can be made into a button
import maya.cmds as cmds # type: ignore
def UI():
global SelectName
global RenameText
global StartValue
global PaddingValue
global NumberCheck
global RemoveFirst
global RemoveEnd
global PrefixText
global SuffixText
global SearchText
global ReplaceText
global SRCheck
#UI Width
sizeX = 240
version = "v1.0"
if cmds.window("RenameWin", exists=True):
cmds.deleteUI("RenameWin", window=True)
#Creating UI
igEzRenamWin = cmds.window("RenameWin", title="Rename Tool "+version, width=sizeX+6, height=385, mnb = True, mxb = False, sizeable = False)
#Creating interface elements
mainLayout = cmds.columnLayout("mainColumnLayout", width = sizeX, adjustableColumn=False, co = ["both",2])
#Select All Button
cmds.separator(h=5, style = "none", parent = mainLayout)
cmds.button(label = "Select All", w=sizeX, h=25, c=SelectAll, ann = "Select ALL objects in scene")
cmds.separator(h=5, style = "none", parent = mainLayout)
#Select by Name
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 25), (2, 60)], cs = [(5,5), (5,5)])
cmds.button(label = "Select by Name", w=sizeX/3, h=25, c=SelectName, align = "Center", ann="Select objects by name")
SelectName = cmds.textField(w = sizeX*0.646, ann="Select by Name \n Use * after and/or before the text to select by prefix/suffix \n Example: *_grp")
cmds.separator(w = sizeX, h=15, style = "in", parent = mainLayout)
#Rename and Number
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 20), (2, 60)])
#Rename Field
cmds.text(label=" Rename:", font = "boldLabelFont", w = sizeX/4, align="left", ann="Write the name you want to rename the objects selected")
RenameText = cmds.textField(w = sizeX*0.75, ann="Write the name you want to rename the objects selected")
#Start Field
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 20), (2, 60)])
cmds.text(label=" Start:", font = "boldLabelFont", w = sizeX/4, align="left")
StartValue = cmds.textField(w = sizeX/4, tx="1", ann="Write the Start value for the sequence")
#Padding Field
cmds.text(label=" Padding:", font = "boldLabelFont", w = sizeX/4, align="left")
PaddingValue = cmds.textField(w = sizeX/4, tx="2", ann="Write the Padding value for the numbers")
#Number Letters
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 20), (2, 60)])
cmds.text(label="", font = "boldLabelFont", w = sizeX/4-2, align="left")
NumberCheck = cmds.radioButtonGrp(labelArray2=[ 'Numbers', 'Letters'], numberOfRadioButtons=2, w=sizeX, h=20, sl=1, cw = ([1,120]))
#ButtonRename and Number
cmds.separator(h=5, style = "none", parent = mainLayout)
cmds.button(label = "Rename and Number", w=sizeX, h=25, c=RenameNumber, align = "Center", parent = mainLayout)
cmds.separator(w = sizeX, h=15, style = "in", parent = mainLayout)
#RemoveCharacter
#Remove First/Last
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 25), (2, 60)], cs = [(5,5)])
cmds.text(label=" Remove:", font = "boldLabelFont", w = sizeX/3-12, align="left")
cmds.button(label = "First Char->", w=sizeX/3, h=25, c=lambda *args: Rename.Remove(True), align = "Center")
cmds.button(label = "<-Last Char", w=sizeX/3, h=25, c=lambda *args: Rename.Remove(False), align = "Center")
cmds.separator(h=5, style = "none", parent = mainLayout)
#Remove pasted__
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 25), (2, 60)], cs = [(90,90)])
cmds.text(label=" ", font = "boldLabelFont", w = sizeX/3-12, align="left")
cmds.button(label = "pasted__", w=sizeX/3, h=25, c=RemovePasted, align = "Center")
#Remove UI
cmds.separator(h=5, style = "none", parent = mainLayout)
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 25), (2, 60)], cs = [(8.5,8.5)])
RemoveFirst = cmds.textField(w = sizeX/5, tx="0", ann="Write the amount of characters you want to delete on text beginning")
cmds.button(label = "-", w=25, h=25, c=lambda *args: Rename.RemoveChar('begin'), align = "Center", ann="Delete on text beginning")
cmds.button(label = "Remove", w=sizeX/4, h=25, c=lambda *args: Rename.RemoveChar('all'), align = "Center", ann="Delete on text beginning and ending")
cmds.button(label = "-", w=25, h=25, c=lambda *args: Rename.RemoveChar('end'), align = "Center", ann="Delete on text ending")
RemoveEnd = cmds.textField(w = sizeX/5, tx="3", ann="Write the amount of characters you want to delete on text ending")
cmds.separator(w = sizeX, h=15, style = "in", parent = mainLayout)
#Suffix
#Control Suffix
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 20), (2, 60)], cs = [(5,5)])
cmds.text(label=" Prefix:", font = "boldLabelFont", w = sizeX/4-10, align="left", ann="Write the prefix")
PrefixText = cmds.textField(w = sizeX/2.5+33, tx="prefix_", ann="Write the prefix")
cmds.button(label = "Add", w=sizeX/4-10, h=25, c=lambda *args: Rename.PrefixSuffix(False), align = "Center")
cmds.separator(h=5, style = "none", parent = mainLayout)
#Group Suffix
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 20), (2, 60)], cs = [(5,5)])
cmds.text(label=" Suffix:", font = "boldLabelFont", w = sizeX/4-10, align="left", ann="Write the suffix")
SuffixText = cmds.textField(w = sizeX/2.5+33, tx="_suffix", ann="Write the suffix")
cmds.button(label = "Add", w=sizeX/4-10, h=25, c=lambda *args: Rename.PrefixSuffix(True), align = "Center")
cmds.separator(w = sizeX, h=15, style = "in", parent = mainLayout)
#Prefix
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 20), (2, 60)], cs = [(5,5)])
cmds.button(label = "_Grp", w=sizeX/5-4, h=25, c=lambda *args: Rename.Suffix('_Grp'), align = "Center", ann = "Add Grp suffix")
cmds.button(label = "_Geo", w=sizeX/5-4, h=25, c=lambda *args: Rename.Suffix('_Geo'), align = "Center", ann = "Add Geo suffix")
cmds.button(label = "_Ctrl", w=sizeX/5-4, h=25, c=lambda *args: Rename.Suffix('_Ctrl'), align = "Center", ann = "Add Ctrl suffix")
cmds.button(label = "_Jnt", w=sizeX/5-4, h=25, c=lambda *args: Rename.Suffix('_Jnt'), align = "Center", ann = "Add Jnt suffix")
cmds.button(label = "_Drv", w=sizeX/5-4, h=25, c=lambda *args: Rename.Suffix('_Drv'), align = "Center", ann = "Add Drv suffix")
cmds.separator(w = sizeX, h=15, style = "in", parent = mainLayout)
#Search and Replace
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 20), (2, 60)], cs = [(5,5)])
cmds.text(label=" Search:", font = "boldLabelFont", w = sizeX/4-10, align="left", ann="Write the text to search")
SearchText = cmds.textField(w = sizeX/2+100, ann="Write the text to search")
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 20), (2, 60)], cs = [(5,5)])
cmds.text(label=" Replace:", font = "boldLabelFont", w = sizeX/4-10, align="left", ann="Write the text to replace")
ReplaceText = cmds.textField(w = sizeX/2+100, ann="Write the text to replace")
cmds.rowColumnLayout( numberOfRows=1, w=sizeX, parent=mainLayout, rowHeight=[(1, 20), (2, 60)], cs = [(5,5)])
SRCheck = cmds.radioButtonGrp(labelArray3=[ 'Selected', 'Hierarchy', 'All'], numberOfRadioButtons=3, w=sizeX, h=20, sl=1, cw = ([1,95],[2,95],[3,95]))
cmds.button(label = "Apply", w=sizeX, h=25, c=SearchReplace, align = "Center", parent = mainLayout)
cmds.separator(h=5, style = "none", parent = mainLayout)
#Show UI:
cmds.showWindow(igEzRenamWin)
def SelectAll(*args):
cmds.select(ado=True, hi = True)
selection = cmds.ls(selection=True, sn=True)
selectionAdd = []
#Old select all code version
"""for objs in selection:
children = cmds.listRelatives(objs, c=True, f =True)
print "Children01:", children
shapes = cmds.listRelatives(objs, s=True, f = True)
print "Shapes:", shapes
if not children == None:
if not shapes == None:
for s in shapes:
children.remove(s)
for chi in children:
children2 = cmds.listRelatives(chi, c=True, f = True)
print "CHildren02:", children2
if not children2 == None:
for chi2 in children2:
children.append(chi2)
selectionAdd.append(chi)
for objs in selectionAdd:
cmds.select(objs, add=True)"""
def SelectName(*args):
cmds.select(cl=True)
name = cmds.textField(SelectName, text = 1, q=True)
try:
selection = cmds.ls(name, l = True)
except:
cmds.warning("Object Don't Exist")
for objs in selection:
cmds.select(objs, add=True)
def RenameNumber(*args):
number = cmds.textField(StartValue, text = 1, q=True)
number = int(number)
padding = cmds.textField(PaddingValue, text = 1, q=True)
padding = int(padding)
NumberLetters = cmds.radioButtonGrp(NumberCheck, q=True, select=True)
newName = cmds.textField(RenameText, text = 1, q=True)
selection = cmds.ls(selection=True, sn=True)
lettersList = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
#Number suffix
y = 0
for obj in selection:
try:
#Teste if has duplicate mesh with the same name on the scene and return the name without parents
trueName = testDuplicateName(obj)
#Save the original name
oldName = trueName
#If true use numbers, else use letters
if NumberLetters == 1:
zeros = ""
for x in range(int(padding)):
if len(str(number)) <= x:
zeros = zeros+"0"
#Create the newName and rename
name = newName+"_"+"{:0>"+str(padding)+"}"
newNameList = name.format(number)
cmds.rename(obj, name.format(number))
else:
newNameList = newName+"_"+lettersList[y]
cmds.rename(obj, newName+"_"+lettersList[y])
if y < len(lettersList)-1:
y+=1
else:
y=0
#For to rename all the oldNames on list to newNames
for x in range(len(selection)):
newParentName = selection[x].replace(oldName, newNameList)
selection[x] = newParentName
except:
pass
number = int(number+1)
def RemoveChar(Type):
first = cmds.textField(RemoveFirst, text = 1, q=True)
end = cmds.textField(RemoveEnd, text = 1, q=True)
selection = cmds.ls(selection = True, sn=True)
for objs in selection:
#Teste if has duplicate mesh with the same name on the scene
trueName = testDuplicateName(objs)
#Save the original name
oldName = trueName
if Type == "all":
name = trueName[:-int(end)]
name = name[int(first):]
if Type == "begin":
name = trueName[int(first):]
if Type == "end":
name = trueName[:-int(end)]
try:
cmds.rename(objs, str(name))
except:
pass
#For to rename all the oldNames on list to newNames
for x in range(len(selection)):
newParentName = selection[x].replace(oldName, name)
selection[x] = newParentName
def Remove(Type):
selection = cmds.ls(selection = True, sn = True)
for objs in selection:
#Teste if has duplicate mesh with the same name on the scene
trueName = testDuplicateName(objs)
#Save the original name
oldName = trueName
if Type:
name = trueName[1:]
else:
name = trueName[:-1]
try:
cmds.rename(objs, name)
except:
pass
#For to rename all the oldNames on list to newNames
for x in range(len(selection)):
newParentName = selection[x].replace(oldName, name)
selection[x] = newParentName
def RemovePasted(*args):
selection = cmds.ls("pasted__*", sn = True)
for objs in selection:
#Teste if has duplicate mesh with the same name on the scene
trueName = testDuplicateName(objs)
name = trueName[8:]
try:
cmds.rename(objs, name)
except:
cmds.warning("Don't Exist pasted Objects")
def PrefixSuffix(Suffix):
prefix = cmds.textField(PrefixText, text = 1, q=True)
suffix = cmds.textField(SuffixText, text = 1, q=True)
selection = cmds.ls(selection = True, sn = True)
for objs in selection:
#Teste if has duplicate mesh with the same name on the scene
trueName = testDuplicateName(objs)
#Save the original name
oldName = trueName
if Suffix:
name = str(trueName)+suffix
else:
name = prefix+str(trueName)
try:
cmds.rename(objs, name)
except:
pass
#For to rename all the oldNames on list to newNames
for x in range(len(selection)):
newParentName = selection[x].replace(oldName, name)
selection[x] = newParentName
def Suffix(Text):
selection = cmds.ls(selection = True, sn = True)
for objs in selection:
#Test if has duplicate mesh with the same name on the scene
trueName = testDuplicateName(objs)
#Save the original name
oldName = trueName
newName = trueName+Text
try:
cmds.rename(objs, newName)
except:
pass
#For to rename all the oldNames on list to newNames
for x in range(len(selection)):
newParentName = selection[x].replace(oldName, newName)
selection[x] = newParentName
def SearchReplace(*args):
search = cmds.textField(SearchText, text = 1, q=True)
replace = cmds.textField(ReplaceText, text = 1, q=True)
SRMethod = cmds.radioButtonGrp(SRCheck, q=True, select=True)
#Selected search and Replace method
if SRMethod == 1:
selection = cmds.ls(selection = True, sn = True)
#Hierarchy search and Replace method
if SRMethod == 2:
cmds.select(hi = True)
selection = cmds.ls(selection = True, sn = False)
#All search and Replace method
if SRMethod == 3:
#Select All DagObjects in scene
selection = []
cmds.select(ado = True, hi = True)
selection = cmds.ls(selection = True, sn=False)
#for to rename the objects
for obj in selection:
#Teste if has duplicate mesh with the same name on the scene and return the name without parents
trueName = testDuplicateName(obj)
#Save the original name
oldName = trueName
#Search and replace to create the new name
newName = trueName.replace(search, replace)
#Rename the object
try:
cmds.rename(obj, newName)
except:
pass
#For to rename all the oldNames on list to newNames
for x in range(len(selection)):
newParentName = selection[x].replace(oldName, newName)
selection[x] = newParentName
print("Slecao: ", selection)
def testDuplicateName(Obj):
try:
trueName = Obj.split("|")
return trueName[len(trueName)-1]
except:
return Obj

View File