diff --git a/Scripts/Modeling/Edit/ModIt/ModIt_2.7_Python3.py b/Scripts/Modeling/Edit/ModIt/ModIt_2.7_Python3.py new file mode 100644 index 0000000..444e994 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/ModIt_2.7_Python3.py @@ -0,0 +1,2880 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import maya.cmds as cmds +import maya.mel as mel +import json +import maya.OpenMaya as OpenMaya +import maya.OpenMayaUI as OpenMayaUI +# Import MayaAPI +import maya.api.OpenMaya as MayaAPI + +try: + import MASH.api as mapi +except ImportError: + print("MASH module could not be imported.") + mapi = None + +preferencePath = cmds.internalVar(upd = True)+"scripts/ModIt_script/Preferences/" + + +if cmds.workspaceControl("ModIt 2.6", exists =True): + cmds.deleteUI("ModIt 2.6") + +def createCustomWorkspaceControlModIt(*args): + #UI_______________________________________ + + cmds.columnLayout(adj = True, w=250, h=460) + + #_________________SUPP ERROR MESSAGE + cmds.warning() + print('', end=' ') + + #__________________________________________________________________PRIMITIVES + #________________ + cH1 = cmds.columnLayout(adj =True) + frameEdit = cmds.frameLayout(l = " PRIMITIVES", cll =1, cl =0, bgc= [0.15, 0.15, 0.15]) + cmds.rowColumnLayout ( numberOfColumns=5, columnWidth=[ (1,48), (2,48), (3,48), (4,48), (5,48) ], columnAlign=[ (1, 'center'), (2, 'center'), (3, 'center'), (4, 'center'), (5, 'center') ] ) + + imageSphere = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Sphere.png" + imageCube = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Cube.png" + imageCylindre = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Cylindre.png" + imagePlane = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Plane.png" + imageDisc = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Disc.png" + + + + PShpere = cmds.symbolButton( image= imageSphere, c= "PSphere20()", ann= "Create Sphere") + cmds.popupMenu() + cmds.menuItem(l= 'Sphere sbdv 10', c= 'PSphere10()') + cmds.menuItem(l= 'Sphere sbdv 12', c= 'PSphere12()') + cmds.menuItem(l= 'Sphere sbdv 14', c= 'PSphere14()') + cmds.menuItem(l= 'Sphere sbdv 16', c= 'PSphere16()') + cmds.menuItem(l= 'Sphere sbdv 18', c= 'PSphere18()') + cmds.menuItem(l= 'Sphere sbdv 20', c= 'PSphere20()') + + PCube = cmds.symbolButton( image= imageCube, c= "PCube1()", ann= "Create Cube ") + cmds.popupMenu() + cmds.menuItem(l= 'Cube sbdv 1', c= 'PCube1()') + cmds.menuItem(l= 'Cube sbdv 2', c= 'PCube2()') + cmds.menuItem(l= 'Cube sbdv 4', c= 'PCube4()') + + PCylindre = cmds.symbolButton( image= imageCylindre, c= "PCylY28()", ann= "Create Cylinder on X with 6 Subdiv)") + cmds.popupMenu() + cmds.menuItem(l= '__________X') + cmds.menuItem(l= 'Cylindre X 8', c= 'PCylX8()') + cmds.menuItem(l= 'Cylindre X 12', c= 'PCylX12()') + cmds.menuItem(l= 'Cylindre X 16', c= 'PCylX16()') + cmds.menuItem(l= 'Cylindre X 28', c= 'PCylX28()') + cmds.menuItem(l= '__________Y') + cmds.menuItem(l= 'Cylindre Y 8', c= 'PCylY8()') + cmds.menuItem(l= 'Cylindre Y 12', c= 'PCylY12()') + cmds.menuItem(l= 'Cylindre Y 16', c= 'PCylY16()') + cmds.menuItem(l= 'Cylindre Y 28', c= 'PCylY28()') + cmds.menuItem(l= '__________Z') + cmds.menuItem(l= 'Cylindre Z 8', c= 'PCylZ8()') + cmds.menuItem(l= 'Cylindre Z 12', c= 'PCylZ12()') + cmds.menuItem(l= 'Cylindre Z 16', c= 'PCylZ16()') + cmds.menuItem(l= 'Cylindre Z 28', c= 'PCylZ28()') + + + PPlane = cmds.symbolButton( image= imagePlane, c= "PPlaneX()", ann= "Create a Plane on X, Y or Z axis") + cmds.popupMenu() + cmds.menuItem(l= 'Plane X', c= 'PPlaneX()') + cmds.menuItem(l= 'Plane Y', c= 'PPlaneY()') + cmds.menuItem(l= 'Plane Z', c= 'PPlaneZ()') + PDisk = cmds.symbolButton( image= imageDisc, c= "PDiscZ12()", ann= "Create a Disc on X, Y or Z axis") + cmds.popupMenu() + cmds.menuItem(l= '__________X') + cmds.menuItem(l= 'Disc X 8', c= 'PDiscX8()') + cmds.menuItem(l= 'Disc X 12', c= 'PDiscX12()') + cmds.menuItem(l= 'Disc X 16', c= 'PDiscX16()') + cmds.menuItem(l= '__________Y') + cmds.menuItem(l= 'Disc Y 8', c= 'PDiscY8()') + cmds.menuItem(l= 'Disc Y 12', c= 'PDiscY12()') + cmds.menuItem(l= 'Disc Y 16', c= 'PDiscY16()') + cmds.menuItem(l= '__________Z') + cmds.menuItem(l= 'Disc Z 8', c= 'PDiscZ8()') + cmds.menuItem(l= 'Disc Z 12', c= 'PDiscZ12()') + cmds.menuItem(l= 'Disc Z 16', c= 'PDiscZ16()') + + cmds.setParent(cH1) + cmds.separator(h= 1, style = 'none') + + + #________________ + #__________________________________________________________________TOOLS + #________________ + + + cH2 = cmds.columnLayout(adj =True) + frameEdit = cmds.frameLayout(l = " TOOLS", cll =1, cl =0, bgc= [0.15, 0.15, 0.15]) + cmds.rowColumnLayout ( numberOfColumns=6, columnWidth=[ (1,40), (2,40), (3,40), (4,40), (5,40), (6,40) ], columnAlign=[ (1, 'center'), (2, 'center'), (3, 'center'), (4, 'center'), (5, 'center') ] ) + + imageCam = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Cameras.png" + imageHardEdge = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/HardEdge.png" + imageSym = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Sym.png" + imageBevAdd = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/BevAdd.png" + + CamO = cmds.symbolButton( image= imageCam, c= "CamOrtho()", ann= "Hide and Lock Orthographique Cameras") + + + Sym = cmds.symbolButton( image= imageSym, c= "SymX()", ann= "Make Symetrie") + cmds.popupMenu() + cmds.menuItem(l= '________Symmetry Merge') + cmds.menuItem(l= 'Symmetry on X', c= 'SymX()') + cmds.menuItem(l= 'Symmetry on Y', c= 'SymY()') + cmds.menuItem(l= 'Symmetry on Z', c= 'SymZ()') + cmds.menuItem(l= '________Flip Selection World') + cmds.menuItem(l= 'Flip on X World', c= 'FlipXWorld()') + cmds.menuItem(l= 'Flip on Y World', c= 'FlipYWorld()') + cmds.menuItem(l= 'Flip on Z World', c= 'FlipZWorld()') + cmds.menuItem(l= '________Flip Selection Pivot') + cmds.menuItem(l= 'Flip on X', c= 'FlipX()') + cmds.menuItem(l= 'Flip on Y', c= 'FlipY()') + cmds.menuItem(l= 'Flip on Z', c= 'FlipZ()') + + HardEdge = cmds.symbolButton( image= imageHardEdge, c= "HardEdges()", ann= "Be sure to be in edge mode") + cmds.popupMenu() + cmds.menuItem(l= 'Smooth 30', c= 'cmds.polySoftEdge(angle= 30)') + cmds.menuItem(l= 'Smooth 35', c= 'cmds.polySoftEdge(angle= 35)') + cmds.menuItem(l= 'Smooth 40', c= 'cmds.polySoftEdge(angle= 40)') + cmds.menuItem(l= 'Smooth 45', c= 'cmds.polySoftEdge(angle= 45)') + + Align = cmds.symbolButton( image= "CenterPivot.png", c= "Align()", ann= "Select at least 3 Vertices, 2 Edges or 1 Face") + cmds.popupMenu() + cmds.menuItem(l= 'A to B', c= 'BtoA()') + + BevAdd = cmds.symbolButton( image= imageBevAdd, c= "EdgeFlow()", ann= "Add Edge Flow") + + UVs = cmds.symbolButton( image= "polyAutoProjLarge.png", c= "UVsAuto()", ann= "Auto UVs") + cmds.popupMenu() + cmds.menuItem(l= 'Auto UVs', c= 'UVsAuto()') + cmds.menuItem(l= 'Planar UVs', c= 'UVsPlanar()') + cmds.menuItem(l= 'UVs Shader', c= 'UVs()') + + + cmds.setParent(cH2) + cmds.separator(h= 1, style = 'none') + + + #________________ + #__________________________________________________________________COLORS + #________________ + + cH3 = cmds.columnLayout(adj =True) + frameEdit = cmds.frameLayout(l = " COLORS", cll =1, cl =0, bgc= [0.15, 0.15, 0.15]) + cmds.rowColumnLayout ( numberOfColumns=6, columnWidth=[ (1,40), (2,40), (3,40), (4,40), (5,40), (6,40) ], columnAlign=[ (1, 'center'), (2, 'center'), (3, 'center'), (4, 'center'), (5, 'center'), (6, 'center') ] ) + + imageColorLambert = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/ColorLambert.png" + imageColorGreen = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/ColorGreen.png" + imageColorRed = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/ColorRed.png" + imageColorBlue = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/ColorBlue.png" + imageColorYellow = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/ColorYellow.png" + imageColorDarkGrey = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/ColorDarkGrey.png" + + ColorLambert = cmds.symbolButton( image= imageColorLambert, c= "lambert1()", ann= "Apply Face Color") + cmds.popupMenu() + cmds.menuItem(l= 'Select', c= 'SelectLambert()') + cmds.menuItem(l= 'Transparancy', c= 'TransLambert()') + cmds.menuItem(l= 'Attribut', c= 'AttributLambert()') + + ColorGreen = cmds.symbolButton( image= imageColorGreen, c= "SelGreen()", ann= "Apply Face Color") + cmds.popupMenu() + cmds.menuItem(l= 'Select', c= 'SelectGreen()') + cmds.menuItem(l= 'Transparancy', c= 'TransGreen()') + cmds.menuItem(l= 'Attribut', c= 'AttributGreen()') + + ColorRed = cmds.symbolButton( image= imageColorRed, c= "SelRed()", ann= "Apply Face Color") + cmds.popupMenu() + cmds.menuItem(l= 'Select', c= 'SelectRed()') + cmds.menuItem(l= 'Transparancy', c= 'TransRed()') + cmds.menuItem(l= 'Attribut', c= 'AttributRed()') + + ColorBlue = cmds.symbolButton( image= imageColorBlue, c= "SelBlue()", ann= "Apply Face Color") + cmds.popupMenu() + cmds.menuItem(l= 'Select', c= 'SelectBlue()') + cmds.menuItem(l= 'Transparancy', c= 'TransBlue()') + cmds.menuItem(l= 'Attribut', c= 'AttributBlue()') + + ColorYellow = cmds.symbolButton( image= imageColorYellow, c= "SelYellow()", ann= "Apply Face Color") + cmds.popupMenu() + cmds.menuItem(l= 'Select', c= 'SelectYellow()') + cmds.menuItem(l= 'Transparancy', c= 'TransYellow()') + cmds.menuItem(l= 'Attribut', c= 'AttributYellow()') + + ColorDarkGrey = cmds.symbolButton( image= imageColorDarkGrey, c= "SelGreyDark()", ann= "Apply Face Color") + cmds.popupMenu() + cmds.menuItem(l= 'Select', c= 'SelectDarkGrey()') + cmds.menuItem(l= 'Transparancy', c= 'TransDarkGrey()') + cmds.menuItem(l= 'Attribut', c= 'AttributDarkGrey()') + + + cmds.setParent(cH3) + cmds.separator(h= 1, style = 'none') + + #________________ + #__________________________________________________________________SELECTIONS + #________________ + + cH5f = cmds.columnLayout(adj =True) + frameEdit = cmds.frameLayout(l = " SELECTIONS", cll =1, cl =0, bgc= [0.15, 0.15, 0.15]) + cmds.rowColumnLayout ( numberOfColumns=5, columnWidth=[ (1,48), (2,48), (3,48), (4,48), (5,48)], columnAlign=[ (1, 'center'), (2, 'center'), (3, 'center'), (4, 'center'), (5, 'center') ] ) + + + imageSelIco1 = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SelIco1.png" + imageSelIco1b = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SelIco1b.png" + imageSelIco2 = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SelIco2.png" + imageSelIco3 = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SelIco3.png" + imageSelIco4 = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SelIco4.png" + + SelInt = cmds.symbolButton( image= imageSelIco1b, c= "selInner()", ann= "Select the Faces Inside selection") + SelIntPlus = cmds.symbolButton( image= imageSelIco1, c= "selInnerPlus()", ann= "Select the Faces Inside selection and keep selection") + SelRingN = cmds.symbolButton( image= imageSelIco3, c= "selRingN2()", ann= "Select 1 Edge each 2 edge in Ring mode") + cmds.popupMenu() + cmds.menuItem(l= 'Select 1 Edge each 2 edge in Ring mode', c= 'selRingN2()') + cmds.menuItem(l= 'Select 1 Edge each 3 edge in Ring mode', c= 'selRingN3()') + cmds.menuItem(l= 'Select 1 Edge each 4 edge in Ring mode', c= 'selRingN4()') + + SelLoopN = cmds.symbolButton( image= imageSelIco4, c= "selLoopN2()", ann= "Select 1 Edge each 2 edge in Loop mode") + cmds.popupMenu() + cmds.menuItem(l= 'Select 1 Edge each 2 edge in Loop mode', c= 'selLoopN2()') + cmds.menuItem(l= 'Select 1 Edge each 3 edge in Loop mode', c= 'selLoopN3()') + cmds.menuItem(l= 'Select 1 Edge each 4 edge in Loop mode', c= 'selLoopN4()') + + + PolyCheck = cmds.symbolButton( image= imageSelIco2, c= "checkNGon()", ann= "Select all Ngon on the select Mesh") + cmds.popupMenu() + cmds.menuItem(l= 'Select all Ngon Faces on the select Mesh', c= 'checkNGon()') + cmds.menuItem(l= 'Select all Quadrangle Faces on the select Mesh', c= 'checkQuad()') + cmds.menuItem(l= 'Select all Triangle Faces on the select Mesh', c= 'checkTri()') + cmds.menuItem(l= 'Select all Concave Faces on the select Mesh', c= 'checkNConcave()') + + + + + cmds.setParent(cH5f) + cmds.separator(h= 8, style='in') + cmds.rowColumnLayout ( numberOfColumns=5, columnWidth=[ (1,30), (2,110), (3,30), (4,30), (5,30) ], columnAlign=[ (1, 'center'), (2, 'center'), (3, 'right'), (4, 'right'), (5, 'right') ] ) + + imageMoins = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Moins.png" + imagePlus = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Plus.png" + imageDel = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Del.png" + imageSetSel = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SelSet.png" + + Moins1 = cmds.symbolButton( image= imageMoins, c= "Moins1()", ann= "Remove from Selection 1") + Store1 = cmds.button(l= "Store Selection 1", c= "Store1()", w= 110, bgc= [0.22, 0.22, 0.22]) + Plus1 = cmds.symbolButton( image= imagePlus, c= "Plus1()", ann= "Add to Selection 1") + Del1 = cmds.symbolButton( image= imageDel, c= "Del1()", ann= "Delete Selection 1") + SetSel1 = cmds.symbolButton( image= imageSetSel, c= "SetSel1()", ann= "Get Selection 1") + + Moins2 = cmds.symbolButton( image= imageMoins, c= "Moins2()", ann= "Remove from Selection 2") + Store2 = cmds.button(l= "Store Selection 2", c= "Store2()", w= 110, bgc= [0.22, 0.22, 0.22]) + Plus2 = cmds.symbolButton( image= imagePlus, c= "Plus2()", ann= "Add to Selection 2") + Del2 = cmds.symbolButton( image= imageDel, c= "Del2()", ann= "Delete Selection 2") + SetSel2 = cmds.symbolButton( image= imageSetSel, c= "SetSel2()", ann= "Get Selection 2") + + cmds.setParent(cH5f) + cmds.separator(h= 2, style = 'none') + + + #________________ + #__________________________________________________________________DUPLICATIONS + #________________ + + cH5d = cmds.columnLayout(adj =True) + frameEdit = cmds.frameLayout(l = " DUPLICATE", cll =1, cl =0, bgc= [0.15, 0.15, 0.15]) + + cmds.rowColumnLayout ( numberOfColumns=5, columnWidth=[ (1,56), (2,56), (3,18), (4,56), (5,56)], columnAlign=[ (1, 'center'), (2, 'center'), (3, 'center'), (4, 'center'), (5, 'center') ] ) + + imageSeparator = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/separator.png" + imageDup1 = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/DupliIcon1.png" + imageDup2 = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/DupliIcon2.png" + imageDup3 = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/DupliIcon3.png" + imageDup4 = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/DupliIcon4.png" + + SmartDupli = cmds.symbolButton( image= imageDup1, c= "SmartDupli()", ann= "Duplicate Using Previous Transform") + DupliLinear = cmds.symbolButton( image= imageDup2, c= "DupLinear()", ann= "Linear X,Y,Z Duplicate. For Multiple Mesh Group them before.") + separator = cmds.image( image= imageSeparator) + Chain = cmds.symbolButton( image= imageDup3, c= "Chain()", ann= "Duplicate Along Curve") + cmds.popupMenu() + cmds.menuItem(l= 'Bezier', c= "Bezier()") + cmds.menuItem(l= 'EPCurve', c= "EPCurve()") + cmds.menuItem(l= 'PencilCurve', c= "Pencil()") + cmds.menuItem(l= 'Chain_Asset', c= "ChainA()") + + ChainBake = cmds.symbolButton( image= imageDup4, c= "ChainBake()", ann= "Bake Chain") + + cmds.setParent(cH5d) + + + #________________ + #__________________________________________________________________ARNOLD + #________________ + + cH5b = cmds.columnLayout(adj =True) + frameEdit = cmds.frameLayout(l = " ARNOLD", cll =1, cl =0, bgc= [0.15, 0.15, 0.15]) + cmds.rowColumnLayout ( numberOfColumns=7, columnWidth=[ (1,36), (2,36), (3,18), (4,40), (5,40), (6,18), (7,40) ], columnAlign=[ (1, 'center'), (2, 'center'), (3, 'center'), (4, 'center'), (5, 'center'), (6, 'center'), (7, 'center') ] ) + + + imageArnoldSubdiv = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Arnold_Subdiv.png" + imageArnoldOpaque = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Arnold_Opaque.png" + imageArnoldStandInExport = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Arnold_StandIn_Export.png" + imageArnolStandInReplace = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Arnold_StandIn_Replace.png" + imageArnolDOFVisor = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Arnold_DOFvisor.png" + + + A_Subdiv = cmds.symbolButton( image= imageArnoldSubdiv, c= "Arnold_Sbdv_ON()", ann= "Activate Arnold Subdiv") + cmds.popupMenu() + cmds.menuItem(l= 'SubDv 1', c= "Arnold_Sbdv_1()") + cmds.menuItem(l= 'SubDv 2', c= "Arnold_Sbdv_ON()") + cmds.menuItem(l= 'SubDv 3', c= "Arnold_Sbdv_3()") + cmds.menuItem(l= 'SubDv 4', c= "Arnold_Sbdv_4()") + cmds.menuItem(l= 'Desactivate Arnold Subdiv', c= "Arnold_Sbdv_OFF()") + A_Opaque = cmds.symbolButton( image= imageArnoldOpaque, c= "Arnold_Opaque_ON()", ann= "Desactivate Arnold Opaque") + cmds.popupMenu() + cmds.menuItem(l= 'Activate Arnold Opaque', c= "Arnold_Opaque_OFF()") + separator = cmds.image( image= imageSeparator) + A_StandInExport = cmds.symbolButton( image= imageArnoldStandInExport, c= "setStandInPath()", ann= "Set a path for StandIn export") + A_StandInReplace = cmds.symbolButton( image= imageArnolStandInReplace, c= "Convert_To_StandIn()", ann= "Convert to StandIn") + separator = cmds.image( image= imageSeparator) + A_DOFVisor = cmds.symbolButton( image= imageArnolDOFVisor, c= "CamFocus()", ann= "Apply Face Color") + cmds.popupMenu() + cmds.menuItem(l= 'Aperture Attributes', c= "ApertureAttributes()") + cmds.menuItem(l= 'Delete Camera Focus', c= "CamFocusOFF()") + + cmds.setParent(cH5b) + cmds.separator(h= 1, style = 'none') + + + + + + #__________________________________________________________________SCREW and BOLTS + #________________ + + cH8 = cmds.columnLayout(adj =True) + frameEdit = cmds.frameLayout(l = " SREWS and BOLTS", cll =1, cl =1, bgc= [0.15, 0.15, 0.15]) + + + imageCustom= cmds.internalVar(upd = True)+"scripts/ShadeIt_script/Icons/Empty.png" + imageScrewA= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Screw_A.png" + imageScrewB= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Screw_B.png" + imageScrewC= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Screw_C.png" + imageScrewD= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Screw_D.png" + imageScrewE= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Screw_E.png" + imageScrewF= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Screw_F.png" + + imageBoltA= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_A.png" + imageBoltB= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_B.png" + imageBoltC= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_C.png" + imageBoltD= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_D.png" + imageBoltE= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_E.png" + imageWasher= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Washer.png" + + imageBoltG= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_G.png" + imageBoltH= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_H.png" + imageBoltI= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_I.png" + imageBoltJ= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_J.png" + imageBoltK= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_K.png" + imageBoltL= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Bolt_L.png" + + + imageSF1= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_1.png" + imageSF2= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_2.png" + imageSF3= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_3.png" + imageSF4= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_4.png" + imageSF5= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_5.png" + imageSF6= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_6.png" + imageSF7= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_7.png" + imageSF8= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_8.png" + imageSF9= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_9.png" + imageSF10= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_10.png" + imageSF11= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_11.png" + imageSF12= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_12.png" + imageSF13= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_13.png" + imageSF14= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_14.png" + imageSF15= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_15.png" + imageSF16= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_16.png" + imageSF17= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_17.png" + imageSF18= cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/SF_18.png" + + + cmds.rowColumnLayout ( numberOfColumns=6, columnWidth=[ (1,39), (2,39), (3,39), (4,39), (5,39), (6,39) ] ) + + ScrewA = cmds.symbolButton( image= imageScrewA, c= "ScrewA()", ann= "Add Screw A") + ScrewB = cmds.symbolButton( image= imageScrewB, c= "ScrewB()", ann= "Add Screw B") + ScrewC = cmds.symbolButton( image= imageScrewC, c= "ScrewC()", ann= "Add Screw C") + ScrewD = cmds.symbolButton( image= imageScrewD, c= "ScrewD()", ann= "Add Screw D") + ScrewE = cmds.symbolButton( image= imageScrewE, c= "ScrewE()", ann= "Add Screw E") + ScrewF = cmds.symbolButton( image= imageScrewF, c= "ScrewF()", ann= "Add Screw F") + + + BoltA = cmds.symbolButton( image= imageBoltA, c= "BoltA()", ann= "Add Bolt A") + BoltB = cmds.symbolButton( image= imageBoltB, c= "BoltB()", ann= "Add Bolt B") + BoltC = cmds.symbolButton( image= imageBoltC, c= "BoltC()", ann= "Add Bolt C") + BoltD = cmds.symbolButton( image= imageBoltD, c= "BoltD()", ann= "Add Bolt D") + BoltE = cmds.symbolButton( image= imageBoltE, c= "BoltE()", ann= "Add Bolt E") + Washer = cmds.symbolButton( image= imageWasher, c= "Washer()", ann= "Add Washer") + + BoltG = cmds.symbolButton( image= imageBoltG, c= "BoltG()", ann= "Add Bolt A") + BoltH = cmds.symbolButton( image= imageBoltH, c= "BoltH()", ann= "Add Bolt B") + BoltI = cmds.symbolButton( image= imageBoltI, c= "BoltI()", ann= "Add Bolt C") + BoltJ = cmds.symbolButton( image= imageBoltJ, c= "BoltJ()", ann= "Add Bolt D") + BoltK = cmds.symbolButton( image= imageBoltK, c= "BoltK()", ann= "Add Bolt E") + BoltL = cmds.symbolButton( image= imageBoltL, c= "BoltL()", ann= "Add Bolt E") + + cmds.popupMenu() + cmds.menuItem(l= 'Chain_B', c= "ChainB()") + cmds.setParent( '..' ) + + + cH9 = cmds.columnLayout(adj =True) + cmds.separator(h= 3, style='in') + + + cmds.rowColumnLayout ( numberOfColumns=6, columnWidth=[ (1,39), (2,39), (3,39), (4,39), (5,39), (6,39) ] ) + + SF1 = cmds.symbolButton( image= imageSF1, c= "SF1()", ann= "Add SF 1") + SF2 = cmds.symbolButton( image= imageSF2, c= "SF2()", ann= "Add SF 2") + SF3 = cmds.symbolButton( image= imageSF3, c= "SF3()", ann= "Add SF 3") + SF4 = cmds.symbolButton( image= imageSF4, c= "SF4()", ann= "Add SF 4") + SF5 = cmds.symbolButton( image= imageSF5, c= "SF5()", ann= "Add SF 5") + SF6 = cmds.symbolButton( image= imageSF6, c= "SF6()", ann= "Add SF 6") + + SF7 = cmds.symbolButton( image= imageSF7, c= "SF7()", ann= "Add SF 7") + SF8 = cmds.symbolButton( image= imageSF8, c= "SF8()", ann= "Add SF 8") + SF9 = cmds.symbolButton( image= imageSF9, c= "SF9()", ann= "Add SF 9") + SF10 = cmds.symbolButton( image= imageSF10, c= "SF10()", ann= "Add SF 10") + SF11 = cmds.symbolButton( image= imageSF11, c= "SF11()", ann= "Add SF 11") + SF12 = cmds.symbolButton( image= imageSF12, c= "SF12()", ann= "Add SF 12") + + SF13 = cmds.symbolButton( image= imageSF13, c= "SF13()", ann= "Add SF 13") + SF14 = cmds.symbolButton( image= imageSF14, c= "SF14()", ann= "Add SF 14") + SF15 = cmds.symbolButton( image= imageSF15, c= "SF15()", ann= "Add SF 15") + SF16 = cmds.symbolButton( image= imageSF16, c= "SF16()", ann= "Add SF 16") + SF17 = cmds.symbolButton( image= imageSF17, c= "SF17()", ann= "Add SF 17") + SF18 = cmds.symbolButton( image= imageSF18, c= "SF18()", ann= "Add SF 18") + + + cmds.setParent(cH8) + + cmds.separator(h= 1, style = 'none') + cmds.setParent( '..' ) + +#_________________________________________________________________________________________________________________HELP&INFO + cH9 = cmds.columnLayout(adj =True) + frameConvert = cmds.frameLayout(l = "Help & Info", cll =1, cl =1, bgc= [0.15, 0.15, 0.15]) + + DiscordIcon = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Discord.png" + WzxIcon = cmds.internalVar(upd = True)+"scripts/ModIt_script/Icons/Wzx.png" + + cmds.separator(h= 1, style = 'none') + Discord = cmds.symbolButton( image= DiscordIcon, c= "DiscordLink()", ann= "Help about Cable on the Disord") + cmds.separator(h= 8, style = 'none') + WzxStore = cmds.symbolButton( image= WzxIcon, c= "WzxStoreLink()", ann= "Other Scripts and Tutorials on the WzxStore") + + cmds.setParent( '..' ) + + + cmds.separator(h= 10, style = 'none') + cmds.setParent( '..' ) + cmds.setParent( '..' ) + +#________________ + + + + +cmds.workspaceControl("ModIt 2.6", retain=False, floating=True, li= True, uiScript="createCustomWorkspaceControlModIt()"); + + + + +class COMAND(): + def Comand(): + cmds.launch(web= "https://wizix.artstation.com/") + +###________________________________________PRIMITIVES_______________________________### +###_________SPHERE + +def PSphere10(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polySphere(r= 1, sx= 10, sy= 6, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Sphere_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polySphere(r= 1, sx= 10, sy= 6, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Sphere_001") + +def PSphere12(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polySphere(r= 1, sx= 12, sy= 6, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Sphere_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polySphere(r= 1, sx= 12, sy= 8, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Sphere_001") + +def PSphere14(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polySphere(r= 1, sx= 14, sy= 8, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Sphere_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polySphere(r= 1, sx= 14, sy= 8, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Sphere_001") + +def PSphere16(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polySphere(r= 1, sx= 16, sy= 10, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Sphere_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polySphere(r= 1, sx= 16, sy= 0o1, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Sphere_001") + +def PSphere18(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polySphere(r= 1, sx= 18, sy= 10, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Sphere_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polySphere(r= 1, sx= 18, sy= 10, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Sphere_001") + +def PSphere20(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polySphere(r= 1, sx= 20, sy= 12, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Sphere_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polySphere(r= 1, sx= 20, sy= 12, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Sphere_001") + +###_________CUBE + +def PCube1(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCube(w= 2, h= 2, d= 2, sx= 1,sy= 1,sz= 1, ax= [0, 1, 0], cuv= 4, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cube_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCube(w= 2, h= 2, d= 2, sx= 1,sy= 1,sz= 1, ax= [0, 1, 0], cuv= 4, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cube_001") + +def PCube2(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCube(w= 2, h= 2, d= 2, sx= 2,sy= 2,sz= 2, ax= [0, 1, 0], cuv= 4, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cube_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCube(w= 2, h= 2, d= 2, sx= 2,sy= 2,sz= 2, ax= [0, 1, 0], cuv= 4, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cube_001") + +def PCube4(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCube(w= 2, h= 2, d= 2, sx= 4,sy= 4,sz= 4, ax= [0, 1, 0], cuv= 4, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cube_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCube(w= 2, h= 2, d= 2, sx= 4,sy= 4,sz= 4, ax= [0, 1, 0], cuv= 4, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cube_001") + + +###_________CYLINDRE + +def PCylX8(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [1, 0, 0],sc= 0, cuv= 4, ch= 1, sa= 8) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [1, 0, 0],sc= 0, cuv= 4, ch= 1, sa= 8) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + + +def PCylX12(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [1, 0, 0],sc= 0, cuv= 4, ch= 1, sa= 12) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [1, 0, 0],sc= 0, cuv= 4, ch= 1, sa= 12) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + +def PCylX16(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [1, 0, 0],sc= 0, cuv= 4, ch= 1, sa= 16) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [1, 0, 0],sc= 0, cuv= 4, ch= 1, sa= 16) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + + +def PCylX28(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [1, 0, 0],sc= 0, cuv= 4, ch= 1, sa= 28) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [1, 0, 0],sc= 0, cuv= 4, ch= 1, sa= 28) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + + +def PCylY8(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 1, 0],sc= 0, cuv= 4, ch= 1, sa= 8) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 1, 0],sc= 0, cuv= 4, ch= 1, sa= 8) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + + +def PCylY12(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 1, 0],sc= 0, cuv= 4, ch= 1, sa= 12) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 1, 0],sc= 0, cuv= 4, ch= 1, sa= 12) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + + +def PCylY16(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 1, 0],sc= 0, cuv= 4, ch= 1, sa= 16) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 1, 0],sc= 0, cuv= 4, ch= 1, sa= 16) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + +def PCylY28(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 1, 0],sc= 0, cuv= 4, ch= 1, sa= 28) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 1, 0],sc= 0, cuv= 4, ch= 1, sa= 28) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + +def PCylZ8(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 0, 1],sc= 0, cuv= 4, ch= 1, sa= 8) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 0, 1],sc= 0, cuv= 4, ch= 1, sa= 8) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + + +def PCylZ12(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 0, 1],sc= 0, cuv= 4, ch= 1, sa= 12) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 0, 1],sc= 0, cuv= 4, ch= 1, sa= 12) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + + +def PCylZ16(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 0, 1],sc= 0, cuv= 4, ch= 1, sa= 16) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 0, 1],sc= 0, cuv= 4, ch= 1, sa= 16) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + + +def PCylZ28(): + selection = cmds.ls(sl= True) + if selection == []: + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 0, 1],sc= 0, cuv= 4, ch= 1, sa= 28) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.rename("Cylinder_001") + + else: + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + objectPrim = cmds.polyCylinder(r= 1, h= 2, sy= 1,sz= 0, ax= [0, 0, 1],sc= 0, cuv= 4, ch= 1, sa= 28) + cmds.polySoftEdge (a= 45, ch= 1) + cmds.select(objectPrim) + cmds.move(pos[0], pos[1], pos[2]) + constr = cmds.normalConstraint(selection, objectPrim, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename("Cylinder_001") + + + + +###_________PLANE + +def PPlaneX(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyPlane(w= 2, h= 2, sx= 1, sy= 1, ax= [1, 0, 0], cuv= 2, ch= 1) + cmds.rename("Plane_001") + + else: + + name = "Plane" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyPlane(w= 2, h= 2, sx= 1, sy= 1, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.rename("Plane") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_001") + + +def PPlaneY(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyPlane(w= 2, h= 2, sx= 1, sy= 1, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.rename("Plane_001") + + else: + + name = "Plane" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyPlane(w= 2, h= 2, sx= 1, sy= 1, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.rename("Plane") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_001") + + +def PPlaneZ(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyPlane(w= 2, h= 2, sx= 1, sy= 1, ax= [0, 0, 1], cuv= 2, ch= 1) + cmds.rename("Plane_001") + + else: + + name = "Plane" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyPlane(w= 2, h= 2, sx= 1, sy= 1, ax= [0, 1, 0], cuv= 2, ch= 1) + cmds.rename("Plane") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_001") + + +###_________DISK + +def PDiscX8(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyDisc(sides= 8, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(0, 0, -90) + cmds.rename("Disc_1") + + else: + + name = "Disc" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyDisc(sides= 8, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(0, 0, -90) + cmds.rename("Disc") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def PDiscX12(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyDisc(sides= 12, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(0, 0, -90) + cmds.rename("Disc_1") + + else: + + name = "Disc" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyDisc(sides= 12, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(0, 0, -90) + cmds.rename("Disc") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def PDiscX16(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyDisc(sides= 16, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(0, 0, -90) + cmds.rename("Disc_1") + + else: + + name = "Disc" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyDisc(sides= 16, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(0, 0, -90) + cmds.rename("Disc") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def PDiscY8(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyDisc(sides= 8, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rename("Disc_1") + + else: + + name = "Disc" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyDisc(sides= 8, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rename("Disc") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def PDiscY12(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyDisc(sides= 12, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rename("Disc_1") + + else: + + name = "Disc" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyDisc(sides= 12, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rename("Disc") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def PDiscY16(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyDisc(sides= 16, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rename("Disc_1") + + else: + + name = "Disc" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyDisc(sides= 16, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rename("Disc") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def PDiscZ8(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyDisc(sides= 8, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(90, 0, 0) + cmds.rename("Disc_1") + + else: + + name = "Disc" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyDisc(sides= 8, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(90, 0, 0) + cmds.rename("Disc") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def PDiscZ12(): + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyDisc(sides= 12, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(90, 0, 0) + cmds.rename("Disc_1") + + else: + + name = "Disc" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyDisc(sides= 12, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(90, 0, 0) + cmds.rename("Disc") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def PDiscZ16(): + + selection = cmds.ls(sl= True) + + if selection == []: + cmds.polyDisc(sides= 16, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(90, 0, 0) + cmds.rename("Disc_1") + + else: + + name = "Disc" + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + cmds.polyDisc(sides= 16, subdivisionMode= 4, subdivisions= 1,radius= 1) + cmds.rotate(90, 0, 0) + cmds.rename("Disc") + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + + + + +###________________________________________TOOLS_______________________________### +###_________CAMRRE + +def CamOrtho(): + cmds.setAttr( "top.visibility", 0) + cmds.setAttr( "top.v", lock= True) + + cmds.setAttr( "front.visibility", 0) + cmds.setAttr( "front.v", lock= True) + + cmds.setAttr( "side.visibility", 0) + cmds.setAttr( "side.v", lock= True) + + print("DONE") + + + +###_________SYM + +def SymX(): + selection = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + + for each in selection: + cmds.FreezeTransformations() + cmds.delete(ch= True) + cmds.duplicate() + cmds.rename("Dupli") + cmds.setAttr("Dupli.scaleX", -1) + cmds.polyUnite(selection, "Dupli", n = "polyTemps") + cmds.delete(ch= True) + cmds.CenterPivot() + cmds.polyMergeVertex( d = 0.001, am = 1,ch= 0) + cmds.rename("Combiningwzx") + + +def SymY(): + selection = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + + for each in selection: + cmds.FreezeTransformations() + cmds.delete(ch= True) + cmds.duplicate() + cmds.rename("Dupli") + cmds.setAttr("Dupli.scaleY", -1) + cmds.polyUnite(selection, "Dupli", n = "polyTemps") + cmds.delete(ch= True) + cmds.CenterPivot() + cmds.polyMergeVertex( d = 0.001, am = 1,ch= 0) + cmds.rename("Combiningwzx") + +def SymZ(): + selection = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + + for each in selection: + cmds.FreezeTransformations() + cmds.delete(ch= True) + cmds.duplicate() + cmds.rename("Dupli") + cmds.setAttr("Dupli.scaleZ", -1) + cmds.polyUnite(selection, "Dupli", n = "polyTemps") + cmds.delete(ch= True) + cmds.CenterPivot() + cmds.polyMergeVertex( d = 0.001, am = 1,ch= 0) + cmds.rename("Combiningwzx") + + +def FlipXWorld(): + selection = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + for each in selection: + DupSel = cmds.duplicate(rc= True) + cmds.group(em= True, n="DupliF") + cmds.parent(DupSel, 'DupliF') + cmds.setAttr("DupliF.scaleX", -1) + cmds.rename("DupliF", "DupliFlip") + +def FlipYWorld(): + selection = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + for each in selection: + DupSel = cmds.duplicate(rc= True) + cmds.group(em= True, n="DupliF") + cmds.parent(DupSel, 'DupliF') + cmds.setAttr("DupliF.scaleY", -1) + cmds.rename("DupliF", "DupliFlip") + +def FlipZWorld(): + selection = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + for each in selection: + DupSel = cmds.duplicate(rc= True) + cmds.group(em= True, n="DupliF") + cmds.parent(DupSel, 'DupliF') + cmds.setAttr("DupliF.scaleZ", -1) + cmds.rename("DupliF", "DupliFlip") + + +def FlipX(): + cmds.duplicate(rc= True) + cmds.rename("DupliF") + cmds.setAttr("DupliF.scaleX", -1) + cmds.rename("DupliF", "DupliFlip") + +def FlipY(): + cmds.duplicate(rc= True) + cmds.rename("DupliF") + cmds.setAttr("DupliF.scaleY", -1) + cmds.rename("DupliF", "DupliFlip") + +def FlipZ(): + cmds.duplicate(rc= True) + cmds.rename("DupliF") + cmds.setAttr("DupliF.scaleX", -1) + cmds.rename("DupliF", "DupliFlip") + +###___________________________________________________________________________HARDEDGES +def HardEdges(): + cmds.polySelectConstraint(m= 3, t= 0x8000, sm= 1) + cmds.polySelectConstraint(m= 0) + + + +def EdgeFlow(): + + storeSelection = cmds.ls(sl=True) + cmds.ConvertSelectionToContainedEdges() + origEdge = cmds.sets(n="origEdgeSet") + cmds.select(storeSelection) + cmds.polySubdivideFacet (duv= 2, dvv= 1, sbm= 1, ch= 1) + cmds.ConvertSelectionToContainedEdges() + newsEdge = cmds.sets(n="newsEdgeSet") + edge = cmds.sets("origEdgeSet", sub="newsEdgeSet") + cmds.select(edge) + cmds.polyEditEdgeFlow (constructionHistory= 1, adjustEdgeFlow= 1) + cmds.delete("newsEdgeSet", "origEdgeSet") + cmds.ConvertSelectionToFaces() + + + + + +###___________________________________________________________________________UVS + +def UVsAuto(): + selection = cmds.ls(sl = True, fl = True, dag = True, type= 'mesh') + + for each in selection: + cmds.DeleteHistory() + cmds.polyAutoProjection(lm= 0, pb= 0, ibd= 1, sc= 1, o= 1, p= 3, ps= 0.1, ws= 0) + cmds.polyEditUV(pu= 0.5, pv= 0.5, su= 0.5, sv= 0.5, u= -0.25, v= 0.25) + cmds.select(each) + cmds.DeleteHistory() + print("UV Done") + +def UVsPlanar(): + + selection = cmds.ls(sl = True, fl = True, dag = True, type= 'mesh') + + for each in selection: + cmds.DeleteHistory() + cmds.polyProjection( each + '.f[*]', ch= 1, type= "planar", ibd= True, kir= True, md= "c" ) + cmds.polyEditUV(pu= 0.5, pv= 0.5, su= 0.5, sv= 0.5, u= -0.25, v= 0.25) + cmds.select(each) + cmds.DeleteHistory() + print("UV Done") + +def UVs(): + + UVsPath = cmds.internalVar(upd = True)+"scripts/ModIt_script/Shaders/Uvs.ma" + selection = cmds.ls(sl = True, fl = True, dag = True) + + if cmds.objExists('UVs'): + print("UVs_EXIST") + for each in selection: + cmds.hyperShade( a= "UVs") + cmds.select("UVs") + print("Done") + + else: + cmds.sets(n= "Settemps") + cmds.file(UVsPath, i = True) + cmds.binMembership("UVs", addToBin= "Viewport_Shaders") + cmds.select("Settemps") + cmds.ls(selection= True) + cmds.delete("Settemps") + for each in selection: + cmds.hyperShade( a= "UVs") + cmds.select("UVs") + print("Done") + +def BtoA(): + cmds.MatchTranslation() + cmds.MatchRotation() + + +###________________________________________________________________________FACES COLORS +def lambert1(): + + cmds.hyperShade( assign= "lambert1" ) + + +def SelGreen(): + + selection = cmds.ls(sl= True) + + if cmds.objExists('Sel_Green'): + cmds.hyperShade( assign= "Sel_Green" ) + + else: + LambertGreen = cmds.shadingNode("lambert",asShader=True) + cmds.setAttr(LambertGreen + ".color", 0.0, 0.798, 0.292, type = 'double3') + cmds.rename("Sel_Green") + cmds.select(selection) + cmds.hyperShade( assign= "Sel_Green" ) + + + +def SelRed(): + + selection = cmds.ls(sl= True) + + if cmds.objExists('Sel_Red'): + cmds.hyperShade( assign= "Sel_Red" ) + + else: + LambertRed = cmds.shadingNode("lambert",asShader=True) + cmds.setAttr(LambertRed + ".color", 0.7, 0.011, 0.011, type = 'double3') + cmds.rename("Sel_Red") + cmds.select(selection) + cmds.hyperShade( assign= "Sel_Red" ) + +def SelBlue(): + + selection = cmds.ls(sl= True) + + if cmds.objExists('Sel_Blue'): + cmds.hyperShade( assign= "Sel_Blue" ) + + else: + LambertBlue = cmds.shadingNode("lambert",asShader=True) + cmds.setAttr(LambertBlue + ".color", 0, 0.432, 0.7, type = 'double3') + cmds.rename("Sel_Blue") + cmds.select(selection) + cmds.hyperShade( assign= "Sel_Blue" ) + +def SelYellow(): + + selection = cmds.ls(sl= True) + + if cmds.objExists('Sel_Yellow'): + cmds.hyperShade( assign= "Sel_Yellow" ) + + else: + LambertYellow = cmds.shadingNode("lambert",asShader=True) + cmds.setAttr(LambertYellow + ".color", 0.9, 0.450, 0.0, type = 'double3') + cmds.rename("Sel_Yellow") + cmds.select(selection) + cmds.hyperShade( assign= "Sel_Yellow" ) + +def SelGreyDark(): + + selection = cmds.ls(sl= True) + + if cmds.objExists('Sel_GreyDark'): + cmds.hyperShade( assign= "Sel_GreyDark" ) + + else: + LambertGreyDark = cmds.shadingNode("lambert",asShader=True) + cmds.setAttr(LambertGreyDark + ".color", 0.05, 0.05, 0.05, type = 'double3') + cmds.rename("Sel_GreyDark") + cmds.select(selection) + cmds.hyperShade( assign= "Sel_GreyDark" ) + + +def SelectLambert(): + + if cmds.objExists('lambert1'): + cmds.hyperShade( objects= "lambert1" ) + + else: + print("Please First Create this FaceColor Shader") + + +def SelectGreen(): + + if cmds.objExists('Sel_Green'): + cmds.hyperShade( objects= "Sel_Green" ) + + else: + print("Please First Create this FaceColor Shader") + + +def SelectRed(): + + if cmds.objExists('Sel_Red'): + cmds.hyperShade( objects= "Sel_Red" ) + + else: + print("Please First Create this FaceColor Shader") + + +def SelectBlue(): + + if cmds.objExists('Sel_Blue'): + cmds.hyperShade( objects= "Sel_Blue" ) + + else: + print("Please First Create this FaceColor Shader") + +def SelectYellow(): + + if cmds.objExists('Sel_Yellow'): + cmds.hyperShade( objects= "Sel_Yellow" ) + + else: + print("Please First Create this FaceColor Shader") + +def SelectDarkGrey(): + + if cmds.objExists('Sel_GreyDark'): + cmds.hyperShade( objects= "Sel_GreyDark" ) + + else: + print("Please First Create this FaceColor Shader") + + +def TransGreen(): + + if cmds.objExists('Sel_Green'): + cmds.window( title='Green Transparancy' ) + cmds.columnLayout() + cmds.attrColorSliderGrp( at='Sel_Green.transparency') + cmds.showWindow() + + else: + print("Please First Create this FaceColor Shader") + + +def AttributGreen(): + + if cmds.objExists('Sel_Green'): + cmds.select('Sel_Green') + + else: + print("Please First Create this FaceColor Shader") + + +def TransLambert(): + + if cmds.objExists('lambert1'): + cmds.window( title='Lambert Transparancy' ) + cmds.columnLayout() + cmds.attrColorSliderGrp( at='lambert1.transparency') + cmds.showWindow() + + else: + print("Please First Create this FaceColor Shader") + + +def AttributLambert(): + + if cmds.objExists('lambert1'): + cmds.select('lambert1') + + else: + print("Please First Create this FaceColor Shader") + +def TransRed(): + + if cmds.objExists('Sel_Red'): + cmds.window( title='Red Transparancy' ) + cmds.columnLayout() + cmds.attrColorSliderGrp( at='Sel_Red.transparency') + cmds.showWindow() + + else: + print("Please First Create this FaceColor Shader") + + +def AttributRed(): + + if cmds.objExists('Sel_Red'): + cmds.select('Sel_Red') + + else: + print("Please First Create this FaceColor Shader") + + +def TransBlue(): + + if cmds.objExists('Sel_Blue'): + cmds.window( title='Blue Transparancy' ) + cmds.columnLayout() + cmds.attrColorSliderGrp( at='Sel_Blue.transparency') + cmds.showWindow() + + else: + print("Please First Create this FaceColor Shader") + + +def AttributBlue(): + + if cmds.objExists('Sel_Blue'): + cmds.select('Sel_Blue') + + else: + print("Please First Create this FaceColor Shader") + + +def TransYellow(): + + if cmds.objExists('Sel_Yellow'): + cmds.window( title='Yellow Transparancy' ) + cmds.columnLayout() + cmds.attrColorSliderGrp( at='Sel_Yellow.transparency') + cmds.showWindow() + + else: + print("Please First Create this FaceColor Shader") + + +def AttributYellow(): + + if cmds.objExists('Sel_Yellow'): + cmds.select('Sel_Yellow') + + else: + print("Please First Create this FaceColor Shader") + + +def TransDarkGrey(): + + if cmds.objExists('Sel_GreyDark'): + cmds.window( title='GreyDark Transparancy' ) + cmds.columnLayout() + cmds.attrColorSliderGrp( at='Sel_GreyDark.transparency') + cmds.showWindow() + + else: + print("Please First Create this FaceColor Shader") + + +def AttributDarkGrey(): + + if cmds.objExists('Sel_GreyDark'): + cmds.select('Sel_GreyDark') + + else: + print("Please First Create this FaceColor Shader") + + +class ALIGN(): + def Comand(): + cmds.launch(web= "https://wizix.artstation.com/") + + +###________________________________________________________________________ALIGN +def Align(): + cmds.setToolTo('Move') + getPivotPos = mel.eval("float $getPivotPos[] = `manipMoveContext -q -p Move`;") + mel.eval("ConvertSelectionToVertices;") + vtxSel=cmds.ls(fl=1, sl=1) + selectedObjectStore= cmds.ls(o=1, sl=1) + objectSelectionStore= cmds.listRelatives(selectedObjectStore[0], p=1) + if len(vtxSel)<3: + cmds.warning("Please select at least 3 Vertices, 2 Edges or 1 Face") + + plane=cmds.polyPlane(cuv=2, sy=1, sx=1, h=1, n='rotationPlane', ch=1, w=1, ax=(0, 1, 0)) + cmds.select((plane[0] + ".vtx[0:2]"), + vtxSel[0], vtxSel[1], vtxSel[2]) + mel.eval("snap3PointsTo3Points(0)") + cmds.parent(objectSelectionStore, plane[0]) + cmds.makeIdentity(objectSelectionStore, apply=True, s=0, r=1, t=0, n=0) + cmds.xform(ws=1, piv=(getPivotPos[0], getPivotPos[1], getPivotPos[2])) + cmds.parent(objectSelectionStore, world=1) + cmds.delete(plane) + + + + + + + +###________________________________________SELECTIONS_______________________________### +###_________STORE1 + +def Store1(): + + if cmds.objExists('ModSet1'): + cmds.sets(add = "ModSet1") + + else : + newSet1 = cmds.sets(n = "ModSet1") + + +def Plus1(): + cmds.sets(add = "ModSet1") + + +def Moins1(): + cmds.sets(rm = "ModSet1") + + +def Del1(): + cmds.delete("ModSet1") + + +def SetSel1(): + selection = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + + cmds.select( "ModSet1" ) + cmds.ls( selection= True ) + import maya.mel as mel + mel.eval('setSelectMode components Components; selectType -smp 0 -sme 1 -smf 0 -smu 0 -pv 0 -pe 1 -pf 0 -puv 0; HideManipulators;') + + +###_________STORE2 + +def Store2(): + + if cmds.objExists('ModSet2'): + cmds.sets(add = "ModSet2") + + else : + newSet1 = cmds.sets(n = "ModSet2") + + +def Plus2(): + cmds.sets(add = "ModSet2") + + +def Moins2(): + cmds.sets(rm = "ModSet2") + + +def Del2(): + cmds.delete("ModSet2") + + +def SetSel2(): + selection = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + + cmds.select( "ModSet2" ) + cmds.ls( selection= True ) + import maya.mel as mel + mel.eval('setSelectMode components Components; selectType -smp 0 -sme 1 -smf 0 -smu 0 -pv 0 -pe 1 -pf 0 -puv 0; HideManipulators;') + + + +def Clean(): + cmds.sets(n = "selInnerPlusSet1") + cmds.sets(add = "selInnerPlusSet1") + cmds.SelectFacetMask() + cmds.polyUVSet(d= True, uvSet = "ModIt_UvLayout") + cmds.select( clear=True ) + cmds.select( "selInnerPlusSet1" ) + cmds.delete( "selInnerPlusSet1" ) + +def CleanPluss(): + cmds.sets(n = "selInnerPlusSet1") + cmds.sets(add = "selInnerPlusSet1") + cmds.SelectFacetMask() + cmds.polyUVSet(d= True, uvSet = "ModIt_UvLayout") + cmds.select( clear=True ) + cmds.select( "selInnerPlusSet1" ) + cmds.delete( "selInnerPlusSet1" ) + cmds.GrowPolygonSelectionRegion() + + + +def selInner(): + selFace=cmds.ls(sl=True) + selObj = cmds.ls(sl=1, fl=1, o=1) + + cmds.polyProjection (selObj, ch=1, type= "Planar", ibd = False, cm= True, uvSetName = "ModIt_UvLayout", kir = True, md= "c") + cmds.polyUVSet(cuv= True, uvSet = "ModIt_UvLayout") + + selEdgePeri = cmds.ConvertSelectionToEdgePerimeter() + cmds.polyMapCut() + + cmds.SelectMeshUVShell() + + cmds.scriptJob( runOnce=True, e = ["SelectionChanged", Clean]) + + +def selInnerPlus(): + selFace=cmds.ls(sl=True) + selObj = cmds.ls(sl=1, fl=1, o=1) + + cmds.polyProjection (selObj, ch=1, type= "Planar", ibd = False, cm= True, uvSetName = "ModIt_UvLayout", kir = True, md= "c") + cmds.polyUVSet(cuv= True, uvSet = "ModIt_UvLayout") + + selEdgePeri = cmds.ConvertSelectionToEdgePerimeter() + cmds.polyMapCut() + + cmds.SelectMeshUVShell() + + cmds.scriptJob( runOnce=True, e = ["SelectionChanged", CleanPluss]) + + + + +def selRingN2(): + mel.eval('polySelectEdgesEveryN "%s" %s;' % ("edgeRing", 2)) + +def selRingN3(): + mel.eval('polySelectEdgesEveryN "%s" %s;' % ("edgeRing", 3)) + +def selRingN4(): + mel.eval('polySelectEdgesEveryN "%s" %s;' % ("edgeRing", 4)) + +def selLoopN2(): + mel.eval('polySelectEdgesEveryN "%s" %s;' % ("edgeLoop", 2)) + +def selLoopN3(): + mel.eval('polySelectEdgesEveryN "%s" %s;' % ("edgeLoop", 3)) + +def selLoopN4(): + mel.eval('polySelectEdgesEveryN "%s" %s;' % ("edgeLoop", 4)) + + +def checkNGon(): + cmds.selectMode(q=True, co=True) + cmds.polySelectConstraint(m=3 ,t = 0x0008, sz=3) + cmds.polySelectConstraint(dis=True) + +def checkTri(): + cmds.selectMode(q=True, co=True) + cmds.polySelectConstraint(m=3 ,t = 0x0008, sz=1) + cmds.polySelectConstraint(dis=True) + +def checkQuad(): + cmds.selectMode(q=True, co=True) + cmds.polySelectConstraint(m=3 ,t = 0x0008, sz=2) + cmds.polySelectConstraint(dis=True) + + +def checkNConcave(): + cmds.selectMode(q=True, co=True) + cmds.polySelectConstraint(m=3 ,t = 0x0008, c=1) + cmds.polySelectConstraint(dis=True) + + + + + + + +###________________________________________ARNOLD______________________________### +###_________ +def Arnold_Sbdv_ON(): + selection = cmds.ls(sl = True, fl = True, dag = True, type= "mesh") + + for each in selection: + cmds.setAttr(each + ".aiSubdivType", 1) + cmds.setAttr(each + ".aiSubdivIterations", 2) + +def Arnold_Sbdv_1(): + selection = cmds.ls(sl = True, fl = True, dag = True, type= "mesh") + + for each in selection: + cmds.setAttr(each + ".aiSubdivType", 1) + cmds.setAttr(each + ".aiSubdivIterations", 1) + + +def Arnold_Sbdv_3(): + selection = cmds.ls(sl = True, fl = True, dag = True, type= "mesh") + + for each in selection: + cmds.setAttr(each + ".aiSubdivType", 1) + cmds.setAttr(each + ".aiSubdivIterations", 3) + +def Arnold_Sbdv_4(): + selection = cmds.ls(sl = True, fl = True, dag = True, type= "mesh") + + for each in selection: + cmds.setAttr(each + ".aiSubdivType", 1) + cmds.setAttr(each + ".aiSubdivIterations", 4) + +def Arnold_Sbdv_OFF(): + selection = cmds.ls(sl = True, fl = True, dag = True, type= "mesh") + + for each in selection: + cmds.setAttr(each + ".aiSubdivType", 0) + cmds.setAttr(each + ".aiSubdivIterations", 0) + +def Arnold_Opaque_ON(): + selection = cmds.ls(sl = True, fl = True, dag = True, type= "mesh") + + for each in selection: + cmds.setAttr(each + ".aiOpaque", 0) + +def Arnold_Opaque_OFF(): + selection = cmds.ls(sl = True, fl = True, dag = True, type= "mesh") + + for each in selection: + cmds.setAttr(each + ".aiOpaque", 1) + + +def setStandInPath(): + Path = cmds.fileDialog2(ds=1,cap="Select your path",fm=2) + Path=Path[0] + print(Path) + d = {'path': Path} + s = json.dumps(d) + open(preferencePath + 'StandIn_path.json',"w").write(s) + +def Convert_To_StandIn(): + pref_path=open(preferencePath + 'StandIn_path.json',"r") + data_pref = json.load(pref_path) + global Path + Path=(data_pref['path']) + d = {'path': Path} + + selName = cmds.ls(sl=True)[0] + sel = cmds.ls(sl=True) + + cmds.file(Path + "/" + selName + ".ass", force=True, typ="ASS Export", pr=True, es=True) + cmds.delete(sel) + importASS = cmds.file(Path + "/" + selName + ".ass", rnn=True, i=True, type= "ASS", ignoreVersion=True, mergeNamespacesOnClash=False) + cmds.select(importASS) + cmds.CenterPivot() + transforms = cmds.ls(importASS, type='transform') + for i, object in enumerate(transforms): + cmds.rename(object, selName) + + cmds.setAttr(selName + "Shape.mode", 5) + cmds.setAttr(selName + "Shape.overrideEnabled", 1) + cmds.setAttr(selName + "Shape.overrideRGBColors", 1) + cmds.setAttr(selName + "Shape.overrideColorRGB", 0.05, 0.05, 0.05) + cmds.delete("ArnoldStandInDefaultLightSet") + print("ASS Convert") + + +def CamFocus(): + + FD_toolPath = cmds.internalVar(upd = True)+"scripts/ModIt_script/Tools/FocusDistanceTool.ma" + + + view = OpenMayaUI.M3dView.active3dView() + cam = OpenMaya.MDagPath() + view.getCamera(cam) + camPath = cam.fullPathName() + cmds.select(camPath) + + + if cmds.objExists('CamOrgin'): + print("Delete Existing Focus First") + + if camPath == "|persp|perspShape": + cmds.warning("Don't work on Persp Camera") + + + else: + cmds.file(FD_toolPath,i=True) + + cmds.matchTransform("FD_Group",camPath , pos=True,rot=True, piv=True) + cmds.parent("FD_Group",camPath) + + + cmds.setAttr(camPath +".aiEnableDOF", 1) + cmds.connectAttr("FocusDistance.distance", camPath + ".aiFocusDistance") + +def CamFocusOFF(): + cmds.delete("FD_Group") + + +def ApertureAttributes(): + if cmds.window("DOFWindows", exists =True): + cmds.deleteUI("DOFWindows") + + + cmds.window("DOFWindows", title='Aperture Size', s= True, w= 500 ) + cmds.columnLayout(adj =True, w= 400) + + cmds.separator(h= 8, style = 'none') + cmds.checkBox("Enable_DOF", onc = "enableDOF_ON()", ofc ="enableDOF_OFF()" , w= 200, align='right') + cmds.separator(h= 4, style = 'none') + + cmds.floatSliderGrp('Slider_Aperture', l = "Aperture Size",pre= 3, min =0, max =5 ,po =True, field =True, cc="ApertureSize()", dc="ApertureSize()", adj =0, cat= [1, "left", 3], cw= [1, 80]) + cmds.separator(h= 5, style = 'none') + + + + def UpdateInfo(): + ApertureValue = GetApertureSize() + EnableDOFValue = GetEnableDOF() + cmds.floatSliderGrp( "Slider_Aperture",e=True, value = ApertureValue) + cmds.checkBox( "Enable_DOF",e=True, value = EnableDOFValue) + + UpdateInfo() + + + cmds.showWindow() + + +def enableDOF_ON(): + + view = OpenMayaUI.M3dView.active3dView() + cam = OpenMaya.MDagPath() + view.getCamera(cam) + camPath = cam.fullPathName() + + cmds.setAttr(camPath + ".aiEnableDOF", 1) + +def enableDOF_OFF(): + + view = OpenMayaUI.M3dView.active3dView() + cam = OpenMaya.MDagPath() + view.getCamera(cam) + camPath = cam.fullPathName() + + cmds.setAttr(camPath + ".aiEnableDOF", 0) + + +def ApertureSize(): + + view = OpenMayaUI.M3dView.active3dView() + cam = OpenMaya.MDagPath() + view.getCamera(cam) + camPath = cam.fullPathName() + + myValueWidght = cmds.floatSliderGrp("Slider_Aperture", q= True, value=True) + cmds.setAttr(camPath + ".aiApertureSize", myValueWidght) + +def GetApertureSize(): + + view = OpenMayaUI.M3dView.active3dView() + cam = OpenMaya.MDagPath() + view.getCamera(cam) + camPath = cam.fullPathName() + + getValue = cmds.getAttr(camPath + ".aiApertureSize") + return getValue + +def GetEnableDOF(): + + view = OpenMayaUI.M3dView.active3dView() + cam = OpenMaya.MDagPath() + view.getCamera(cam) + camPath = cam.fullPathName() + + getValue = cmds.getAttr(camPath + ".aiEnableDOF") + return getValue + + +###________________________________________DUPLICATION_______________________________### +def DupLinear(): + + AssetSel = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + cmds.parent(AssetSel, world=True ) + cmds.FreezeTransformations() + cmds.rename(AssetSel, "DuplicateAsset") + # create a new MASH network + mashNetwork = mapi.Network() + mashNetwork.createNetwork(name = "ModIt_Duplicate", geometry="Instancer") + + if cmds.window("Duplicate", exists =True): + cmds.deleteUI("Duplicate") + + cmds.window("Duplicate", title='Duplicate Attribute', s= True, w= 500 ) + cmds.columnLayout(adj =True, w= 400) + cmds.separator(h= 8, style = 'none') + cmds.floatSliderGrp('Slider_Iteration', l = "Number",pre= 3, min =0, max =500 ,po =True, field =True, cc="Iteration()", dc="Iteration()", adj =0, cat= [1, "left", 3], cw= [1, 80]) + cmds.floatSliderGrp('Slider_IterationX', l = "Distance X",pre= 3, min =-500, max =500 ,po =True, field =True, cc="IterationX()", dc="IterationX()", adj =0, cat= [1, "left", 3], cw= [1, 80]) + cmds.floatSliderGrp('Slider_IterationY', l = "Distance Y",pre= 3, min =-500, max =500 ,po =True, field =True, cc="IterationY()", dc="IterationY()", adj =0, cat= [1, "left", 3], cw= [1, 80]) + cmds.floatSliderGrp('Slider_IterationZ', l = "Distance Z",pre= 3, min =-500, max =500 ,po =True, field =True, cc="IterationZ()", dc="IterationZ()", adj =0, cat= [1, "left", 3], cw= [1, 80]) + cmds.separator(h= 5, style = 'none') + + def UpdateInfo(): + IterationValue = GetIteration() + IterationXValue = GetIterationX() + IterationYValue = GetIterationY() + IterationZValue = GetIterationZ() + cmds.floatSliderGrp( "Slider_Iteration",e=True, value = IterationValue) + cmds.floatSliderGrp( "Slider_IterationX",e=True, value = IterationXValue) + cmds.floatSliderGrp( "Slider_IterationY",e=True, value = IterationYValue) + cmds.floatSliderGrp( "Slider_IterationZ",e=True, value = IterationZValue) + + UpdateInfo() + cmds.showWindow() + cmds.scriptJob(uiDeleted=['Duplicate' , atClose]) + + +def Iteration(): + myValueWidght = cmds.floatSliderGrp("Slider_Iteration", q= True, value=True) + cmds.setAttr("ModIt_Duplicate_Distribute" + '.pointCount', myValueWidght) + +def GetIteration(): + getValue = cmds.getAttr("ModIt_Duplicate_Distribute" + '.pointCount') + return getValue + +def IterationX(): + myValueWidght = cmds.floatSliderGrp("Slider_IterationX", q= True, value=True) + cmds.setAttr("ModIt_Duplicate_Distribute" + '.amplitudeX', myValueWidght) + +def GetIterationX(): + getValue = cmds.getAttr("ModIt_Duplicate_Distribute" + '.amplitudeX') + return getValue + +def IterationY(): + myValueWidght = cmds.floatSliderGrp("Slider_IterationY", q= True, value=True) + cmds.setAttr("ModIt_Duplicate_Distribute" + '.amplitudeY', myValueWidght) + +def GetIterationY(): + getValue = cmds.getAttr("ModIt_Duplicate_Distribute" + '.amplitudeY') + return getValue + +def IterationZ(): + myValueWidght = cmds.floatSliderGrp("Slider_IterationZ", q= True, value=True) + cmds.setAttr("ModIt_Duplicate_Distribute" + '.amplitudeZ', myValueWidght) + +def GetIterationZ(): + getValue = cmds.getAttr("ModIt_Duplicate_Distribute" + '.amplitudeZ') + return getValue + +def atClose(): + cmds.select("ModIt_Duplicate_Instancer") + import maya.mel as mel + mel.eval('MASHBakeGUI;') + cmds.select("ModIt_Duplicate_Instancer") + try: + import MASHbakeInstancer + except ImportError: + cmds.warning("Unable to import MASHbakeInstancer. Please ensure the MASH plugin is installed and enabled.") + else: + MASHbakeInstancer.MASHbakeInstancer(False) + cmds.deleteUI("mashBakeStill", window=True ) + + cmds.select("ModIt_Duplicate_Instancer_objects") + cmds.SelectHierarchy("M_Chain_Instancer_objects") + cmds.CenterPivot() + cmds.delete(ch= True) + cmds.showHidden(a= True) + cmds.delete("DuplicateAsset") + cmds.rename("ModIt_Duplicate_Instancer_objects", "Duplicate") + cmds.delete("ModIt_Duplicate_Instancer") + cmds.delete("ModIt_Duplicate") + +def SmartDupli(): + cmds.duplicate(rr= True, st=True) + + + + +###________________________________________CHAIN_______________________________### + +def Chain(): + + if cmds.objExists('M_Chain'): + cmds.window("Chain", title='Chain Attribute', s= True, w= 500 ) + cmds.columnLayout(adj =True, w= 400) + cmds.separator(h= 8, style = 'none') + cmds.floatSliderGrp('Slider_ChainNumver', l = "Number",pre= 3, min =0, max =200 ,po =True, field =True, cc="ChainNumber()", dc="ChainNumber()", adj =0, cat= [1, "left", 3], cw= [1, 80]) + cmds.separator(h= 5, style = 'none') + + def UpdateInfo(): + ChainIterationValue = GetChainNumber() + + cmds.floatSliderGrp( "Slider_ChainNumver",e=True, value = ChainIterationValue) + + UpdateInfo() + cmds.showWindow() + + else: + selection1 = cmds.ls(sl = True, fl = True, dag = True, hd = 1) + selection2 = cmds.ls(sl = True, fl = True, dag = True, tl= 1, shapes= True) + + cmds.select(selection1) + + # create a new MASH network + mashNetwork = mapi.Network() + mashNetwork.createNetwork(name = "M_Chain", geometry="Instancer") + cmds.setAttr(mashNetwork.distribute + '.pointCount', 30) + cmds.setAttr(mashNetwork.distribute + '.arrangement', 8) + # create a world node + curveNode = mashNetwork.addNode("MASH_Curve") + cmds.connectAttr(selection2[0]+".worldSpace[0]", "M_Chain_Curve.inCurves[0]") + cmds.setAttr("M_Chain_Curve.parametricLength", 1) + + if cmds.window("Chain", exists =True): + cmds.deleteUI("Chain") + + cmds.window("Chain", title='Chain Attribute', s= True, w= 500 ) + cmds.columnLayout(adj =True, w= 400) + cmds.separator(h= 8, style = 'none') + cmds.floatSliderGrp('Slider_ChainNumver', l = "Number",pre= 3, min =0, max =200 ,po =True, field =True, cc="ChainNumber()", dc="ChainNumber()", adj =0, cat= [1, "left", 3], cw= [1, 80]) + cmds.separator(h= 5, style = 'none') + + def UpdateInfo(): + ChainIterationValue = GetChainNumber() + + cmds.floatSliderGrp( "Slider_ChainNumver",e=True, value = ChainIterationValue) + + + UpdateInfo() + cmds.showWindow() + + + +def ChainNumber(): + myValueWidght = cmds.floatSliderGrp("Slider_ChainNumver", q= True, value=True) + cmds.setAttr("M_Chain_Distribute" + '.pointCount', myValueWidght) + +def GetChainNumber(): + getValue = cmds.getAttr("M_Chain_Distribute" + '.pointCount') + return getValue + +def ChainBake(): + cmds.select("M_Chain_Instancer") + import maya.mel as mel + mel.eval('MASHBakeGUI;') + cmds.select("M_Chain_Instancer") + try: + import MASHbakeInstancer + except ImportError: + cmds.warning("Unable to import MASHbakeInstancer. Please ensure the MASH plugin is installed and enabled.") + else: + MASHbakeInstancer.MASHbakeInstancer(False) + cmds.deleteUI("mashBakeStill", window=True ) + + cmds.select("M_Chain_Instancer_objects") + cmds.SelectHierarchy("M_Chain_Instancer_objects") + cmds.CenterPivot() + cmds.delete(ch= True) + cmds.showHidden(a= True) + cmds.delete("M_Chain_Instancer") + cmds.rename("M_Chain_Instancer_objects", "Chain_Duplicate") + cmds.delete("M_Chain") + + + + +def Bezier(): + cmds.CreateBezierCurveTool() + +def EPCurve(): + cmds.EPCurveTool() + +def Pencil(): + cmds.PencilCurveTool() + + + + + + + + + + +###________________________________________SCREW AND BOLTS______________________________### +###_________SCREW1 + +def ScrewA(): + + name = "Screw_A" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Screw_A.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def ScrewB(): + + name = "Screw_B" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Screw_B.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def ScrewC(): + + name = "Screw_C" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Screw_C.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def ScrewD(): + + name = "Screw_D" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Screw_D.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def ScrewE(): + + name = "Screw_E" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Screw_E.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def ScrewF(): + + name = "Screw_F" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Screw_F.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def BoltA(): + + name = "Bolt_A" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_A.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def BoltB(): + + name = "Bolt_B" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_B.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def BoltC(): + + name = "Bolt_C" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_C.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + + +def BoltD(): + + name = "Bolt_D" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_D.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + + +def BoltE(): + + name = "Bolt_E" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_E.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def Washer(): + + name = "Washer" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Washer.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def ChainA(): + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Chain_A.ma" + target = cmds.file(fileO, i= True) + + cmds.rename("Chain_A", "Chain_A_01") + +def BoltG(): + + name = "Bolt_G" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_G.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def BoltH(): + + name = "Bolt_H" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_H.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def BoltI(): + + name = "Bolt_I" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_I.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def BoltJ(): + + name = "Bolt_J" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_J.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def BoltK(): + + name = "Bolt_K" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_K.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def BoltL(): + + name = "Bolt_L" + # get current position of the move manipulator + import maya.mel as mel + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + + # get the current selection + selection = cmds.ls(selection=True) + + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/Bolt_L.ma" + target = cmds.file(fileO, i= True) + + cmds.move(pos[0], pos[1], pos[2], name) + + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF1(): + + name = "SF_1" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_1.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF2(): + + name = "SF_2" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_2.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF3(): + + name = "SF_3" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_3.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF4(): + + name = "SF_4" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_4.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF5(): + + name = "SF_5" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_5.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF6(): + + name = "SF_6" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_6.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF7(): + + name = "SF_7" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_7.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF8(): + + name = "SF_8" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_8.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF9(): + + name = "SF_9" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_9.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF10(): + + name = "SF_10" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_10.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF11(): + + name = "SF_11" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_11.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF12(): + + name = "SF_12" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_12.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + + +def SF13(): + + name = "SF_13" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_13.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF14(): + + name = "SF_14" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_14.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF15(): + + name = "SF_15" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_15.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF16(): + + name = "SF_16" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_16.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF17(): + + name = "SF_17" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_17.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def SF18(): + + name = "SF_18" + mel.eval("setToolTo $gMove;") + pos = cmds.manipMoveContext('Move', query=True, position=True) + selection = cmds.ls(selection=True) + fileO = cmds.internalVar(upd = True)+"scripts/ModIt_script/Mesh/SF_18.ma" + target = cmds.file(fileO, i= True) + cmds.move(pos[0], pos[1], pos[2], name) + constr = cmds.normalConstraint(selection, name, aimVector = (0,1,0), worldUpType= 0) + cmds.delete(constr) + cmds.rename(name, name + "_01") + +def DiscordLink(): + cmds.showHelp("https://discord.gg/2mkvw9r", absolute=True) + +def WzxStoreLink(): + cmds.showHelp("http://www.wzxstore.com/", absolute=True) \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/ModIt_3.0_Shelf.txt b/Scripts/Modeling/Edit/ModIt/ModIt_3.0_Shelf.txt new file mode 100644 index 0000000..58f2267 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/ModIt_3.0_Shelf.txt @@ -0,0 +1,4 @@ +from ModIt import ModIt_UI +import importlib +importlib.reload(ModIt_UI) +ModIt_UI \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/ModIt_CSS.py b/Scripts/Modeling/Edit/ModIt/ModIt_CSS.py new file mode 100644 index 0000000..f2b1fae --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/ModIt_CSS.py @@ -0,0 +1,722 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +##GLOBAL VARIABLEs +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui + + +##THEME_SET +USERAPPDIR = cmds.internalVar(userAppDir=True) +VERSION = cmds.about(v=True) +IconPath = os.path.join(USERAPPDIR, VERSION+'/scripts/ModIt/Icons/Theme_Classic/') + + +# Attention l'ordre est important notamen pour le QPushButton!! +##COLORS SCHEME +### GREY BG : #272727 +### GREY Line : #444444 +### GREEN : #b3b523 +### YELLOW : #c49e19 + +### GREY MODIT COLOR + #TABS BG : 292929 + #SECTION BG : 303030 + #BLUE : 29b1ea + + +## Add border: 0px; to Background to remove border lines +##GLOBAL VARIABLEs +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui + + + +ModIt_CSS = """ + + *{ + background: #303030; + border: 0px; + } + + + + QTabWidget::pane { /* Ligne Ar a la suite des tabs */ + background: #202020; + } + + QToolTip { + background-color : #202020; + color : #b7b7b7; + font-size: 16px; + } + + + + QPushButton{ background-color: #303030; + } + QPushButton:hover{ background-color: #606060; + border-radius: 3px; + } + QPushButton:pressed{ background-color: #282828; + } + + + + + + QPushButton[objectName^="TABS_BTN_OFF"]{ + background-color :#292929; + border-top: 1px solid gray; + border-right: 1px solid gray; + border-left: 1px solid gray; + border-color: #222222; + } + QPushButton[objectName^="TABS_BTN_OFF"]:hover{ + background-color : #181818; + border-top: 2px solid gray; + border-color: #303030; + } + QPushButton[objectName^="TABS_BTN_OFF"]:pressed{ + background-color : #65BEF1; + } + + + + + + + QPushButton[objectName^="StoreSet"]{ + background-color :#292929; + border: 1px solid gray; + border-color: #222222; + } + QPushButton[objectName^="StoreSet"]:hover{ + background-color :#303030; + border: 1px solid gray; + border-color: #424242; + } + QPushButton[objectName^="StoreSet"]:pressed{ + background-color : #65BEF1; + } + + + + + QPushButton[objectName^="AssetIt"]{ + background-color :#222222; + border: 1px solid gray; + border-color: #222222; + color : #65BEF1 + } + QPushButton[objectName^="AssetIt"]:hover{ + background-color :#303030; + border: 1px solid gray; + border-color: #424242; + } + QPushButton[objectName^="AssetIt"]:pressed{ + background-color : #65BEF1; + } + + + + + + QPushButton[objectName^="Separator"]{ + background-color: #464646; + } + + + + QComboBox { + border: 1px solid gray; + border-radius: 4px; + background: #2f2f2f; + border-color: #202020; + padding: 1px 2px 1px 3px; + color: #C2C2C2; + font-size: 14px; + } + + QComboBox::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + } + + QComboBox::down-arrow { + image: url(""" + IconPath + """Arrow_Down.png); + + } + + + QSlider { + min-height: 14; + max-height: 14; + } + + + QSlider::handle:horizontal { + background: #65BEF1; + width: 6px; + margin-top: -6px; + margin-bottom: -6px; + border-radius: 2px; + min-height: 12; + max-height: 12; + } + + + QSlider::groove:horizontal { + background: #242424; + height: 2px; + } + + + + + QDoubleSpinBox{ + background-color: #2f2f2f; + border: 1px solid gray; + border-color: #202020; + border-radius: 4px; + font-size: 14px; + + } + + QDoubleSpinBox::focus{ + border: 1px solid #b3b523; + border-color: #65BEF1; + border-radius: 2px; + } + + QLineEdit{ + background-color: #262626; + border: 1px solid gray; + border-radius: 3px; + border-color: #444444; + + } + + + QLineEdit:hover{ + background-color: #222222; + border: 1px solid gray; + border-radius: 3px; + border-color: #999999; + + } + + + QLineEdit:focus{ + background-color: #222222; + border: 1px solid gray; + border-radius: 3px; + border-color: #65BEF1; + + } + + + + QCheckBox::indicator:unchecked { + border: 1px solid #385E74; + } + QCheckBox::indicator:checked {image: url(""" + IconPath + """Apply.png); + border: 1px solid #385E74; + } + + + + + + """ + +AssetIt_CSS = """ + + *{ + background: #272727; + border: 0px; + } + + QMenu{ + background-color: #222222; + border: 1px solid gray; + border-radius: 2px; + border-color: #385E74; + } + + QMenu::item{ + color: #909090; + } + + + QMenu::item:selected{ + background-color: #262626; + color: #65BEF1; + } + + + + + QLineEdit{ + background-color: #222222; + border: 1px solid gray; + border-radius: 3px; + border-color: #444444; + + } + + + QLineEdit:hover{ + background-color: #222222; + border: 1px solid gray; + border-radius: 3px; + border-color: #999999; + + } + + + QLineEdit:focus{ + background-color: #222222; + border: 1px solid gray; + border-radius: 3px; + border-color: #65BEF1; + + } + + + + + + QScrollBar::handle:vertical { + background: #2094D6; + border-radius: 3px; + + } + + + QScrollBar:vertical { + width: 12px; + + } + + + + + + + QListWidget{ + background: #202020; /* Background de la fenetre Widgets */ + border: 2px solid #202020; + border-radius: 3px; + padding: 0px; + } + + + QListView::item:hover{ + border : 2px solid black; + background : green; + } + + + + + + /*QWidget:hover{ + background: #808080; + }*/ + + + + + + + + QTabWidget::pane { /* Ligne Ar a la suite des tabs */ + background: #202020; + + } + + + + QTabBar::tab { + background: #282828; + border: 1px solid #202020; + border-radius: 3px; + min-width: 12ex;/* taille du Tab Largeur */ + padding: 5px;/* taille du Tab Hauteur */ + color: #909090 + + } + + QTabBar::tab:hover { + background: #454545; + border: 1px solid #202020; + border-top: 1px solid #E3E3E3; + border-radius: 3px; + color: #E3E3E3 + } + + + QTabBar::tab:selected { + background: #292929; + border: 1px solid #202020; + border-top: 1px solid #419ED3; + border-radius: 3px; + color: #419ED3 + } + + + + + + + + QSlider { + min-height: 12; + max-height: 12; + } + + + QSlider::handle:horizontal { + background: #65BEF1; + width: 22px; + margin-top: -4px; + margin-bottom: -4px; + border-radius: 2px; + min-height: 10; + max-height: 10; + } + + + + QSlider::groove:horizontal { + background: #404040; + height: 1px; + + } + + + + + + QToolTip { + background-color : #202020; + color : #65BEF1; + font-size: 16px; + } + + + + QPushButton{ background-color: #282828; + + } + + + QPushButton:hover{ background-color: #404040; + border-radius: 3px; + } + + QPushButton:pressed{ background-color: #222222; + + } + + + QPushButton[objectName^="Items"]{ + background-color: #232323; + border: 1px solid gray; + border-color: #202020; + } + + QPushButton[objectName^="Items"]:hover{ + background-color: #303030; + border: 2px solid gray; + border-color: #505050; + } + + + QToolButton{ + color : #404040; + } + + QToolButton:hover{ + color : #606060; + } + + + + + + + + QPushButton[objectName^="AddAsset"]{ + background-color : #222222; + color : #808080; + } + + QPushButton[objectName^="AddAsset"]:hover{ + background-color : #252525; + border: 1px solid gray; + border-color: #65BEF1; + color : #65BEF1; + } + + QPushButton[objectName^="AddAsset"]:pressed{ + background-color : #141414; + border: 1px solid gray; + border-color: #222222; + color : #404040; + } + + + + + + QPushButton[objectName^="SaveSetting"]:hover{ + background-color : #252525; + border: 1px solid gray; + border-color: #FFFFFF; + border-radius: 2px; + color : #FFFFFF; + } + + QPushButton[objectName^="SaveSetting"]{ + background-color : #252525; + border: 1px solid gray; + border-color: #65BEF1; + border-radius: 2px; + color : #65BEF1; + } + + QPushButton[objectName^="SaveSetting"]:pressed{ + background-color : #202020; + border: 1px solid gray; + border-color: #606060; + border-radius: 2px; + color : #606060; + } + + + + + + + + QPushButton[objectName^="CleanFav"]{ + background-color : #252525; + border: 1px solid gray; + border-color: #b7842a; + color : #b7842a; + } + + QPushButton[objectName^="CleanFav"]:hover{ + background-color : #252525; + border: 1px solid gray; + border-color: #FF9B22; + color : #FF9B22; + } + + QPushButton[objectName^="CleanFav"]:pressed{ + background-color : #141414; + border: 1px solid gray; + border-color: #222222; + color : #404040; + } + + + + + QPushButton[objectName^="Separator"]{ + background-color: #272727; + } + + + + QLineEdit[objectName^="UserLibPathField"]{ + background-color: #222222; + color: #65BEF1; + } + + + + + QLabel[objectName^="AssetName"]{ + background-color : #1E1E1E; + color : #65BEF1; + border: 1px solid gray; + border-color: #353535; + border-radius: 2px; + } + + QLabel[objectName^="AssetTitle"]{ + color : #65BEF1; + } + + + QLabel[objectName^="ThumbAsset"]{ + background-color : #232323; + color : #65BEF1; + border: 1px solid gray; + border-color: #383838; + border-radius: 2px; + } + + + + QDoubleSpinBox{ + font-size:17px; + background-color: #242424; + width: 60px; + } + + QDoubleSpinBox::focus{ + border: 1px solid #b3b523; + font-size:17px; + background-color: #1e1e1e; + border-color: #65BEF1; + border-radius: 2px; + width: 60px; + } + + + + + + QComboBox { + border: 2px solid gray; + border-radius: 4px; + background: #232323; + border-color: #232323; + padding: 1px 2px 1px 3px; + min-width: 6em; + color: #C2C2C2; + } + + QComboBox::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 15px; + + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + } + + QComboBox::down-arrow { + image: url(""" + IconPath + """ComboBox_Arrow.png); + + } + + + + + + + QCheckBox[objectName^="ClayRender"]::indicator:Unchecked:hover{image: url(""" + IconPath + """ClayRender_ON.png); + border: 0px solid #444444; + } + QCheckBox[objectName^="ClayRender"]::indicator:checked {image: url(""" + IconPath + """ClayRender_ON.png); + border: 0px solid #444444; + } + QCheckBox[objectName^="ClayRender"]::indicator:Unchecked {image: url(""" + IconPath + """ClayRender_OFF.png); + border: 0px solid #444444; + } + QCheckBox[objectName^="ClayRender"]::indicator:checked:hover{image: url(""" + IconPath + """ClayRender_OVER.png); + border: 0px solid #444444; + } + + + + QGroupBox { + border: 1px solid gray; + border-color: #444444; + border-radius: 4px; + color : #65BEF1; + margin-top: 18px; + font-size: 16px; + + } + + QGroupBox::title { + subcontrol-origin: margin; + subcontrol-position: top left; + border-top-left-radius: 10px; + border-top-right-radius: 10x; + padding: 1px 12px; + + } + + + QRadioButton::indicator::unchecked{ + border: 1px solid; + border-color: #444444; + border-radius: 5px; + background-color: #444444; + width: 9px; + height: 9px; + } + + QRadioButton::indicator:unchecked:hover + { + border: 1px solid; + border-color: #888888; + border-radius: 5px; + background-color: #888888; + width: 9px; + height: 9px; + } + + + + QRadioButton::indicator::checked{ + border: 1px solid; + border-color: #65BEF1; + border-radius: 5px; + background-color: #65BEF1; + width: 9px; + height: 9px; + } + + + + + + + + """ + +Maya_CSS = """ + + *{ + + } + + QPushButton{ + border: 0px; + + } + + + QPushButton:hover{ background-color: #656565; + + } + + QPushButton:pressed{ background-color: #303030; + + } + + + + """ + diff --git a/Scripts/Modeling/Edit/ModIt/ModIt_Global.py b/Scripts/Modeling/Edit/ModIt/ModIt_Global.py new file mode 100644 index 0000000..eb3a341 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/ModIt_Global.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +##GLOBAL VARIABLEs +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.mel as mel +import json +from .Qt import QtWidgets, QtCore, QtCompat +import os +import maya.cmds as cmds +from maya import OpenMayaUI as omui + +# Special cases for different Maya versions +try: + from shiboken2 import wrapInstance +except ImportError: + from shiboken import wrapInstance + +try: + from PySide2.QtGui import QIcon + from PySide2.QtWidgets import QWidget +except ImportError: + from PySide.QtGui import QIcon, QWidget + +from . import ModIt_CSS + + +##_____________________________________________PATH +ModItPath = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/') +PlugInsPath = ModItPath +IconsPathThemeClassic = os.path.join(ModItPath+'/Icons/Theme_Classic/') +ToolPath = os.path.join(ModItPath+'/Tools/') +PreferencePath = os.path.join(ModItPath+'/Preferences/') +PrefIcons = os.path.join(ModItPath+'/Icons/') +RessourcePath = os.path.join(ModItPath+'/Ressources/') + + + +##_____________________________________________PREFERENCES +ModItTitle = "ModIt" + + +##_____________________________________________UI +#_____________#Theme +Theme_pref = json.load(open(PreferencePath + 'Pref_Theme.json', "r")) +PREF_THEME = (Theme_pref['THEME']) + +if PREF_THEME == 0: + Theme = ModIt_CSS.ModIt_CSS + IconPath = IconsPathThemeClassic +elif PREF_THEME == 1: + Theme = ModIt_CSS.Maya_CSS + IconPath = IconsPathThemeClassic + +#_____________#IconSize +IconSize_pref = json.load(open(PreferencePath + 'Pref_IconSize.json', "r")) +PREF_ICONSIZE = (IconSize_pref['ICONSIZE']) + +IconButtonSize = PREF_ICONSIZE + +# ****************************************** +# BUTTONS PARAMS +# ****************************************** +iconFixeSize = 30 +iconButtonSize = 30 +separatorWidth = 1 + + +##_____________________________________________WARNING POP UP +def WarningWindow(message, size, *args): + BackgroundColor = 0.16 + # ________________// + if cmds.window("WarningWindow", exists=True): + cmds.deleteUI("WarningWindow") + cmds.window("WarningWindow", title=' Warning ', s=False, vis=True, rtf=False) + cmds.columnLayout(adj=True, rs=3, bgc=[BackgroundColor, BackgroundColor, BackgroundColor]) + cmds.separator(h=8, style='none') + cmds.text(l=" " + message + " ", al="center") + cmds.separator(h=8, style='none') + cmds.button(l="OK", c=WarningOKButton) + cmds.window("WarningWindow", e=True, wh=(size, 80)) + + qw = omui.MQtUtil.findWindow("WarningWindow") + widget = wrapInstance(int(qw), QWidget) + icon = QIcon(IconPath + "Windows_Ico_Warning.png") + widget.setWindowIcon(icon) + + cmds.showWindow() + +def WarningOKButton(*args): + cmds.deleteUI("WarningWindow") + + + +def LoadingWindow(message, size, *args): + BackgroundColor = 0.110 + # ________________// + if cmds.window("LoadingWindow", exists=True): + cmds.deleteUI("LoadingWindow") + cmds.window("LoadingWindow", title='Loading Asset', s=False, vis=True, rtf=False) + cmds.columnLayout(adj=True, rs=3, bgc=[BackgroundColor, BackgroundColor, BackgroundColor]) + cmds.separator(h=5, style='none') + cmds.text(l=" " + message + " ", al="center") + cmds.iconTextButton(image1= IconPath + "Refresh_Button.png") + cmds.window("LoadingWindow", e=True, wh=(size, 70)) + + qw = omui.MQtUtil.findWindow("LoadingWindow") + widget = wrapInstance(int(qw), QWidget) + icon = QIcon(IconPath + "Windows_Ico2.png") + widget.setWindowIcon(icon) + + cmds.showWindow() + + + + + + + + + + + + + + + + + diff --git a/Scripts/Modeling/Edit/ModIt/ModIt_IconShelf.png b/Scripts/Modeling/Edit/ModIt/ModIt_IconShelf.png new file mode 100644 index 0000000..d6cf325 Binary files /dev/null and b/Scripts/Modeling/Edit/ModIt/ModIt_IconShelf.png differ diff --git a/Scripts/Modeling/Edit/ModIt/ModIt_LAUNCH.py b/Scripts/Modeling/Edit/ModIt/ModIt_LAUNCH.py new file mode 100644 index 0000000..f320443 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/ModIt_LAUNCH.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +##-------------------------------------------------------------------------- I M P O R T +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.cmds as cmds +import maya.mel as mel +import json +from .Qt import QtWidgets, QtCore, QtCompat +import os +from maya import OpenMayaUI as omui +from functools import partial +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget +##---------------------------------------- Import Modules +import importlib +from . import ModIt_Global +importlib.reload(ModIt_Global) + + +##-------------------------------------------------------------------------- G L O B A L V A R +##PATH_SET +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath + +DOCK =(json.load(open(PreferencePath + 'Dockable.json',"r"))['VALUE']) + +if DOCK == 0: + print("MODIT FLOATING MODE") + + open(PreferencePath + 'UI_Adapt_Height.json', "w").write(json.dumps({"VALUE": 660})) + open(PreferencePath + 'Section_Utilities.json', "w").write(json.dumps({"VALUE": 1})) + open(PreferencePath + 'Section_Primitives.json', "w").write(json.dumps({"VALUE": 1})) + open(PreferencePath + 'Section_Colors.json', "w").write(json.dumps({"VALUE": 1})) + open(PreferencePath + 'Section_Selections.json', "w").write(json.dumps({"VALUE": 1})) + open(PreferencePath + 'Section_Mesh.json', "w").write(json.dumps({"VALUE": 1})) + open(PreferencePath + 'Section_Sets.json', "w").write(json.dumps({"VALUE": 1})) + open(PreferencePath + 'Section_Tools.json', "w").write(json.dumps({"VALUE": 1})) + + + from . import ModIt_UI + importlib.reload(ModIt_UI) + ui = ModIt_UI + +else: + print("MODIT DOCKABLE MODE") + from . import ModIt_UI + importlib.reload(ModIt_UI) + ui = ModIt_UI.showUI() + + diff --git a/Scripts/Modeling/Edit/ModIt/ModIt_UI.py b/Scripts/Modeling/Edit/ModIt/ModIt_UI.py new file mode 100644 index 0000000..57cc402 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/ModIt_UI.py @@ -0,0 +1,628 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +##-------------------------------------------------------------------------- +## ScriptName : ModIt 3.0 +## Author : Wizix +## StartDate : 2022/09/09 +## LastUpdate : 2022/13/09 +## Version : 0.0.1 +##-------------------------------------------------------------------------- I M P O R T +from PySide2 import QtWidgets, QtCore, QtGui +from maya import cmds as mc +import maya.cmds as cmds +import maya.mel as mel +import json +from .Qt import QtWidgets, QtCore, QtCompat +import os +from maya import OpenMayaUI as omui +from functools import partial +# Special cases for different Maya versions +from shiboken2 import wrapInstance +from PySide2.QtGui import QIcon +from PySide2.QtWidgets import QWidget +##---------------------------------------- Import Modules +import importlib +from . import ModIt_Global +importlib.reload(ModIt_Global) +from . import ModIt_CSS +importlib.reload(ModIt_CSS) + +##---------------------------------------- Import Classes +from .Class import Collapsible +importlib.reload(Collapsible) +from .Modeling import Section_PRIMITIVES +importlib.reload(Section_PRIMITIVES) +from .Modeling import Section_COLORS +importlib.reload(Section_COLORS) +from .Modeling import Section_SETS +importlib.reload(Section_SETS) +from .Modeling import Section_SELECTIONS +importlib.reload(Section_SELECTIONS) +from .Modeling import Section_MESH +importlib.reload(Section_MESH) +from .Modeling import Section_TOOLS +importlib.reload(Section_TOOLS) +from .Modeling import Section_UTILITIES +importlib.reload(Section_UTILITIES) + +from .Placement import Layout_PLACEMENT +importlib.reload(Layout_PLACEMENT) + +from .Setting import Layout_SETTING +importlib.reload(Layout_SETTING) +from .Shading import Layout_SHADING +importlib.reload(Layout_SHADING) + + + +##-------------------------------------------------------------------------- G L O B A L V A R +##PATH_SET +IconPath = ModIt_Global.IconsPathThemeClassic +PreferencePath = ModIt_Global.PreferencePath +ToolsPath = ModIt_Global.ToolPath +RessourcePath = ModIt_Global.RessourcePath + +#GLOBAR VAR UI +WINDOW_TITLE = ModIt_Global.ModItTitle + + +##JSON PREF DATA +ADAP_HEIGHT = (json.load(open(PreferencePath + 'UI_Adapt_Height.json',"r"))['VALUE']) +TAB_OPEN =(json.load(open(PreferencePath + 'TabOpen.json',"r"))['TAB_OPEN']) + +S_UTILITIES_VALUE =(json.load(open(PreferencePath + 'Section_Utilities.json',"r"))['VALUE']) +S_PRIMITIVES_VALUE =(json.load(open(PreferencePath + 'Section_Primitives.json',"r"))['VALUE']) +S_COLORS_VALUE =(json.load(open(PreferencePath + 'Section_Colors.json',"r"))['VALUE']) +S_SELECTIONS_VALUE =(json.load(open(PreferencePath + 'Section_Selections.json',"r"))['VALUE']) +S_MESH_VALUE =(json.load(open(PreferencePath + 'Section_Mesh.json',"r"))['VALUE']) +S_SETS_VALUE =(json.load(open(PreferencePath + 'Section_Sets.json',"r"))['VALUE']) +S_TOOLS_VALUE =(json.load(open(PreferencePath + 'Section_Tools.json',"r"))['VALUE']) + +WIN_DISPLAY_SIZE =(json.load(open(PreferencePath + 'WinSize.json',"r"))['VALUE']) + +DOCK =(json.load(open(PreferencePath + 'Dockable.json',"r"))['VALUE']) + + + +##-------------------------------------------------------------------------- B U I L D U I +def maya_main_window(): + main_window_ptr = omui.MQtUtil.mainWindow() ##Return the Maya main window widget as a Python object + return wrapInstance(int(main_window_ptr), QtWidgets.QWidget) + +class ModIt_UI(QtWidgets.QDialog): + if DOCK == 0: + def __init__(self, parent=maya_main_window()): + super(ModIt_UI, self).__init__(parent) + ##__________________________________________________________________ SAVE UI POSITION + self.settings_path = os.path.join(PreferencePath + "settingsFile.ini") + + + ##__________________________________________________________________ WINDOWS SETTING + self.setWindowTitle(WINDOW_TITLE) + self.setFixedSize(340, ADAP_HEIGHT) + icon = QIcon(IconPath + "ModIt_Window_Ico.png") + self.setWindowIcon(icon) + + self.buildUI() + + else: + def __init__(self, parent=None): + super(ModIt_UI, self).__init__() + + ##__________________________________________________________________ SAVE UI POSITION + self.settings_path = os.path.join(PreferencePath + "settingsFile.ini") + self.setMinimumSize(400, 660) + self.buildUI() + + + + def buildUI(self): + open(PreferencePath + 'JobNumber.json', "w").write(json.dumps({"JOB_NUMBER": 0})) + # ****************************************** + # BUTTONS PARAMS + # ****************************************** + Tab_iconFixeSize = 30 + Tab_iconButtonSize = 24 + iconFixeSize = ModIt_Global.iconFixeSize + iconButtonSize = ModIt_Global.iconButtonSize + separatorWidth = ModIt_Global.separatorWidth + + ##__________________// UI - Import CSS + self.setStyleSheet(ModIt_Global.Theme) + ##_________________// Restore Previous Position + settings_obj = QtCore.QSettings(self.settings_path, QtCore.QSettings.IniFormat) + self.restoreGeometry(settings_obj.value("windowGeometry")) + ##_________________// GLOBAL LAYOUT + GLOBAL_Lyt = QtWidgets.QVBoxLayout(self) + GLOBAL_Lyt.setSpacing(0) + GLOBAL_Lyt.setContentsMargins(0, 0, 0, 0) + + ##------------------------------------------------------------------------------------// + ##------------------------------------------------------------------------------------------------------// TABS + ##------------------------------------------------------------------------------------// + self.TABSBAR_Widget = QtWidgets.QWidget() + self.TABSBAR_Widget.setStyleSheet("background-color:#222222;") #TABS BG - Pose problem bg color + self.TABSBAR_Lyt = QtWidgets.QHBoxLayout(self.TABSBAR_Widget) + self.TABSBAR_Lyt.setAlignment(QtCore.Qt.AlignTop) + self.TABSBAR_Lyt.setContentsMargins(0, 0, 0, 0) + self.TABSBAR_Lyt.setSpacing(0) + GLOBAL_Lyt.addWidget(self.TABSBAR_Widget) + + ##______________________________________________________/ BTN MODELING TAB + self.ModelingTab_Btn = QtWidgets.QPushButton() + if TAB_OPEN == 0: + self.ModelingTab_Btn.setIcon(QtGui.QIcon(IconPath + "MODELING_ON.png")) + self.ModelingTab_Btn.setStyleSheet("background-color:#303030;") + else: + self.ModelingTab_Btn.setIcon(QtGui.QIcon(IconPath + "MODELING_OFF.png")) + self.ModelingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + self.ModelingTab_Btn.setFixedSize(Tab_iconFixeSize,Tab_iconFixeSize) + self.ModelingTab_Btn.setIconSize(QtCore.QSize(Tab_iconButtonSize, Tab_iconButtonSize)) + self.ModelingTab_Btn.setToolTip(" ModIt ") + + self.ModelingTab_Btn.clicked.connect(self.ModelingTab_ON) + self.TABSBAR_Lyt.addWidget(self.ModelingTab_Btn) + + ##______________________________________________________/ BTN SHADING TAB + self.ShadingTab_Btn = QtWidgets.QPushButton() + if TAB_OPEN == 1: + self.ShadingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SHADING_ON.png")) + self.ShadingTab_Btn.setStyleSheet("background-color:#303030;") + else: + self.ShadingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SHADING_OFF.png")) + self.ShadingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + + self.ShadingTab_Btn.setFixedSize(Tab_iconFixeSize,Tab_iconFixeSize) + self.ShadingTab_Btn.setIconSize(QtCore.QSize(Tab_iconButtonSize, Tab_iconButtonSize)) + + self.ShadingTab_Btn.clicked.connect(self.ShadingTab_ON) + self.ShadingTab_Btn.setToolTip(" ViewportIt ") + self.TABSBAR_Lyt.addWidget(self.ShadingTab_Btn) + + ##______________________________________________________/ BTN PLACEMENT TAB + self.PlacementTab_Btn = QtWidgets.QPushButton() + if TAB_OPEN == 2: + self.PlacementTab_Btn.setIcon(QtGui.QIcon(IconPath + "PLACEMENT_ON.png")) + self.PlacementTab_Btn.setStyleSheet("background-color:#303030;") + else: + self.PlacementTab_Btn.setIcon(QtGui.QIcon(IconPath + "PLACEMENT_OFF.png")) + self.PlacementTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\QPushButton::hover{background-color : #343434;}") + + self.PlacementTab_Btn.setFixedSize(Tab_iconFixeSize,Tab_iconFixeSize) + self.PlacementTab_Btn.setIconSize(QtCore.QSize(Tab_iconButtonSize, Tab_iconButtonSize)) + + self.PlacementTab_Btn.clicked.connect(self.PlacementTab_ON) + self.PlacementTab_Btn.setToolTip(" Placement ") + self.TABSBAR_Lyt.addWidget(self.PlacementTab_Btn) + + + ##______________________________________________________/ BTN SETTING TAB + self.SettingTab_Btn = QtWidgets.QPushButton() + if TAB_OPEN == 3: + self.SettingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SETTING_ON.png")) + self.SettingTab_Btn.setStyleSheet("background-color:#303030;") + else: + self.SettingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SETTING_OFF.png")) + self.SettingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\QPushButton::hover{background-color : #343434;}") + + self.SettingTab_Btn.setFixedSize(Tab_iconFixeSize,Tab_iconFixeSize) + self.SettingTab_Btn.setIconSize(QtCore.QSize(Tab_iconButtonSize, Tab_iconButtonSize)) + + self.SettingTab_Btn.clicked.connect(self.SettingTab_ON) + self.SettingTab_Btn.setToolTip(" Setting ") + self.TABSBAR_Lyt.addWidget(self.SettingTab_Btn) + + ##------------------------------------------------------------------------------------// + ##------------------------------------------------------------------------------------------------------// T A B M O D E L I N G + ##------------------------------------------------------------------------------------// + self.TAB_MODELING_Widget = QtWidgets.QWidget() + GLOBAL_Lyt.addWidget(self.TAB_MODELING_Widget) + self.ALL_SECTIONS_HLyt = QtWidgets.QVBoxLayout(self.TAB_MODELING_Widget) + self.ALL_SECTIONS_HLyt.setContentsMargins(0, 0, 0, 0) + self.ALL_SECTIONS_HLyt.setSpacing(5)# BETWEEN SECTIONS + self.ALL_SECTIONS_HLyt.setAlignment(QtCore.Qt.AlignTop) + + + + + ##_________________________________________________________________________________________________________________/ U T I L I T E S + self.Collapsible_wdg_SETS = Collapsible.CollapsibleWidget("U T I L I T E S") + self.Collapsible_wdg_SETS.set_expanded(S_UTILITIES_VALUE) + self.Collapsible_wdg_SETS.collapsed_signal.connect(partial(self.Section_OpenClose_btn, "Utilities", 40)) + self.Collapsible_wdg_SETS.add_widget(Section_UTILITIES.UTILITIES_LAYOUT()) + self.ALL_SECTIONS_HLyt.addWidget(self.Collapsible_wdg_SETS) + ## _____________________________________________________/ Separator + self.ALL_SECTIONS_HLyt.addSpacing(2) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(2000,2) + self.Separator.setStyleSheet("background-color:#262626;") + self.ALL_SECTIONS_HLyt.addWidget(self.Separator) + + + ##_________________________________________________________________________________________________________________/ P R I M I T I V E S + self.Collapsible_wdg_PRIMITIVES = Collapsible.CollapsibleWidget("P R I M I T I V E S") + self.Collapsible_wdg_PRIMITIVES.set_expanded(S_PRIMITIVES_VALUE) + self.Collapsible_wdg_PRIMITIVES.collapsed_signal.connect(partial(self.Section_OpenClose_btn, "Primitives", 40)) + self.Collapsible_wdg_PRIMITIVES.add_widget(Section_PRIMITIVES.PRIMITIVES_LAYOUT()) + self.ALL_SECTIONS_HLyt.addWidget(self.Collapsible_wdg_PRIMITIVES) + ## _____________________________________________________/ Separator + self.ALL_SECTIONS_HLyt.addSpacing(2) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(2000,2) + self.Separator.setStyleSheet("background-color:#262626;") + self.ALL_SECTIONS_HLyt.addWidget(self.Separator) + + + ##_________________________________________________________________________________________________________________/ C O L O R S + self.Collapsible_wdg_COLORS = Collapsible.CollapsibleWidget("C O L O R S") + self.Collapsible_wdg_COLORS.set_expanded(S_COLORS_VALUE) + self.Collapsible_wdg_COLORS.collapsed_signal.connect(partial(self.Section_OpenClose_btn, "Colors", 40)) + self.Collapsible_wdg_COLORS.add_widget(Section_COLORS.COLORS_LAYOUT()) + self.ALL_SECTIONS_HLyt.addWidget(self.Collapsible_wdg_COLORS) + ## _____________________________________________________/ Separator + self.ALL_SECTIONS_HLyt.addSpacing(2) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(2000,2) + self.Separator.setStyleSheet("background-color:#262626;") + self.ALL_SECTIONS_HLyt.addWidget(self.Separator) + + + ##_________________________________________________________________________________________________________________/ S E L E C T I O N S + self.Collapsible_wdg_SELECTIONS = Collapsible.CollapsibleWidget("S E L E C T I O N S") + self.Collapsible_wdg_SELECTIONS.set_expanded(S_SELECTIONS_VALUE) + self.Collapsible_wdg_SELECTIONS.collapsed_signal.connect(partial(self.Section_OpenClose_btn, "Selections", 40)) + self.Collapsible_wdg_SELECTIONS.add_widget(Section_SELECTIONS.SELECTIONS_LAYOUT()) + self.ALL_SECTIONS_HLyt.addWidget(self.Collapsible_wdg_SELECTIONS) + ## _____________________________________________________/ Separator + self.ALL_SECTIONS_HLyt.addSpacing(2) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(2000,2) + self.Separator.setStyleSheet("background-color:#262626;") + self.ALL_SECTIONS_HLyt.addWidget(self.Separator) + + ##_________________________________________________________________________________________________________________/ M E S H + self.Collapsible_wdg_MESH = Collapsible.CollapsibleWidget("M E S H") + self.Collapsible_wdg_MESH.set_expanded(S_MESH_VALUE) + self.Collapsible_wdg_MESH.collapsed_signal.connect(partial(self.Section_OpenClose_btn, "Mesh", 110)) + self.Collapsible_wdg_MESH.add_widget(Section_MESH.MESH_LAYOUT()) + self.ALL_SECTIONS_HLyt.addWidget(self.Collapsible_wdg_MESH) + ## _____________________________________________________/ Separator + self.ALL_SECTIONS_HLyt.addSpacing(2) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(2000,2) + self.Separator.setStyleSheet("background-color:#262626;") + self.ALL_SECTIONS_HLyt.addWidget(self.Separator) + + + ##_________________________________________________________________________________________________________________/ S E T S + self.Collapsible_wdg_SETS = Collapsible.CollapsibleWidget("S E T S") + self.Collapsible_wdg_SETS.set_expanded(S_SETS_VALUE) + self.Collapsible_wdg_SETS.collapsed_signal.connect(partial(self.Section_OpenClose_btn, "Sets", 85)) + self.Collapsible_wdg_SETS.add_widget(Section_SETS.SETS_LAYOUT()) + self.ALL_SECTIONS_HLyt.addWidget(self.Collapsible_wdg_SETS) + ## _____________________________________________________/ Separator + self.ALL_SECTIONS_HLyt.addSpacing(2) + self.Separator = QtWidgets.QLabel() + self.Separator.setFixedSize(2000,2) + self.Separator.setStyleSheet("background-color:#262626;") + self.ALL_SECTIONS_HLyt.addWidget(self.Separator) + + + + ##_________________________________________________________________________________________________________________/ T O O L S + self.Collapsible_wdg_TOOLS = Collapsible.CollapsibleWidget("T O O L S") + self.Collapsible_wdg_TOOLS.set_expanded(S_TOOLS_VALUE) + self.Collapsible_wdg_TOOLS.collapsed_signal.connect(partial(self.Section_OpenClose_btn, "Tools", 40)) + self.Collapsible_wdg_TOOLS.add_widget(Section_TOOLS.TOOLS_LAYOUT()) + self.ALL_SECTIONS_HLyt.addWidget(self.Collapsible_wdg_TOOLS) + + + + + + + ##------------------------------------------------------------------------------------// + ##------------------------------------------------------------------------------------------------------// T A B S H A D I N G + ##------------------------------------------------------------------------------------// + self.TAB_SHADING_Widget = QtWidgets.QWidget() + GLOBAL_Lyt.addWidget(self.TAB_SHADING_Widget) + self.TAB_SHADING_Lyt = QtWidgets.QVBoxLayout(self.TAB_SHADING_Widget) + self.TAB_SHADING_Lyt.addWidget(Layout_SHADING.SHADING_LAYOUT()) + + + + + ##------------------------------------------------------------------------------------// + ##------------------------------------------------------------------------------------------------------// T A B P L A C E M E N T + ##------------------------------------------------------------------------------------// + self.TAB_PLACEMENT_Widget = QtWidgets.QWidget() + GLOBAL_Lyt.addWidget(self.TAB_PLACEMENT_Widget) + self.TAB_PLACEMENT_Lyt = QtWidgets.QVBoxLayout(self.TAB_PLACEMENT_Widget) + self.TAB_PLACEMENT_Lyt.addWidget(Layout_PLACEMENT.PLACEMENT_LAYOUT()) + + + + + + ##------------------------------------------------------------------------------------// + ##------------------------------------------------------------------------------------------------------// T A B S E T T I N G + ##------------------------------------------------------------------------------------// + self.TAB_SETTING_Widget = QtWidgets.QWidget() + GLOBAL_Lyt.addWidget(self.TAB_SETTING_Widget) + self.TAB_SETTING_Lyt = QtWidgets.QVBoxLayout(self.TAB_SETTING_Widget) + self.TAB_SETTING_Lyt.addWidget(Layout_SETTING.SETTING_LAYOUT()) + + + + + + ##__________________________________________________________________// UI - END + self.ALL_SECTIONS_HLyt.addStretch() + self.TAB_SHADING_Lyt.addStretch() + self.TAB_PLACEMENT_Lyt.addStretch() + self.TAB_SETTING_Lyt.addStretch() + + ##_______________/ AT SCRIPT OPENING SET HIDE/SHOW TABS + if TAB_OPEN == 0: + self.ModelingTab_ON() + if TAB_OPEN == 1: + self.ShadingTab_ON() + if TAB_OPEN == 2: + self.PlacementTab_ON() + if TAB_OPEN == 3: + self.SettingTab_ON() + + + + ##_________________________________________________________________________________// ACTIONS DEF + ##_____________________________________________________________ + ##______________________________________________________/ TABS BAR + def ModelingTab_ON(self): + ADAP_HEIGHT = (json.load(open(PreferencePath + 'UI_Adapt_Height.json', "r"))['VALUE']) + self.TAB_MODELING_Widget.show() + self.TAB_SHADING_Widget.hide() + self.TAB_PLACEMENT_Widget.hide() + self.TAB_SETTING_Widget.hide() + + if DOCK == 0: + self.setFixedHeight(ADAP_HEIGHT) + self.resize(self.width(), ADAP_HEIGHT) + + self.ModelingTab_Btn.setIcon(QtGui.QIcon(IconPath + "MODELING_ON.png")) + self.ModelingTab_Btn.setStyleSheet("background-color:#303030;") # TABS BTN BG - ACTIF + + self.ShadingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SHADING_OFF.png")) + self.ShadingTab_Btn.setStyleSheet("QPushButton{background-color :#292929;}\QPushButton::hover{background-color : #343434;}") + + self.PlacementTab_Btn.setIcon(QtGui.QIcon(IconPath + "TabScrew_OFF.png")) + self.PlacementTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + + self.SettingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SETTING_OFF.png")) + self.SettingTab_Btn.setStyleSheet("QPushButton{background-color :#292929;}\ QPushButton::hover{background-color : #343434;}") + + + open(PreferencePath + 'TabOpen.json', "w").write(json.dumps({"TAB_OPEN" : 0})) + + + + def ShadingTab_ON(self): + self.TAB_MODELING_Widget.hide() + self.TAB_SHADING_Widget.show() + self.TAB_PLACEMENT_Widget.hide() + self.TAB_SETTING_Widget.hide() + + if DOCK == 0: + if WIN_DISPLAY_SIZE == 0: # 125 + self.setFixedHeight(535) + else: + self.setFixedHeight(555) + self.resize(self.width(), 40) + + self.ShadingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SHADING_ON.png")) + self.ShadingTab_Btn.setStyleSheet("background-color:#303030;") + + + self.ModelingTab_Btn.setIcon(QtGui.QIcon(IconPath + "MODELING_OFF.png")) + self.ModelingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + self.PlacementTab_Btn.setIcon(QtGui.QIcon(IconPath + "TabScrew_OFF.png")) + self.PlacementTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + + self.SettingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SETTING_OFF.png")) + self.SettingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + open(PreferencePath + 'TabOpen.json', "w").write(json.dumps({"TAB_OPEN" : 1})) + + def PlacementTab_ON(self): + self.TAB_MODELING_Widget.hide() + self.TAB_SHADING_Widget.hide() + self.TAB_PLACEMENT_Widget.show() + self.TAB_SETTING_Widget.hide() + + if DOCK == 0: + self.setFixedHeight(680) + self.resize(self.width(), 40) + + self.PlacementTab_Btn.setIcon(QtGui.QIcon(IconPath + "TabScrew_ON.png")) + self.PlacementTab_Btn.setStyleSheet("background-color:#303030;") + + self.ModelingTab_Btn.setIcon(QtGui.QIcon(IconPath + "MODELING_OFF.png")) + self.ModelingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + + self.ShadingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SHADING_OFF.png")) + self.ShadingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + self.SettingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SETTING_OFF.png")) + self.SettingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + + open(PreferencePath + 'TabOpen.json', "w").write(json.dumps({"TAB_OPEN" : 2})) + + + def SettingTab_ON(self): + self.TAB_MODELING_Widget.hide() + self.TAB_SHADING_Widget.hide() + self.TAB_PLACEMENT_Widget.hide() + self.TAB_SETTING_Widget.show() + + if DOCK == 0: + if WIN_DISPLAY_SIZE == 0: # 125 + self.setFixedHeight(440) + else: + self.setFixedHeight(480) + + + self.resize(self.width(), 40) + + self.SettingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SETTING_ON.png")) + self.SettingTab_Btn.setStyleSheet("background-color:#303030;") + + self.ModelingTab_Btn.setIcon(QtGui.QIcon(IconPath + "MODELING_OFF.png")) + self.ModelingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + self.PlacementTab_Btn.setIcon(QtGui.QIcon(IconPath + "TabScrew_OFF.png")) + self.PlacementTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + + self.ShadingTab_Btn.setIcon(QtGui.QIcon(IconPath + "SHADING_OFF.png")) + self.ShadingTab_Btn.setStyleSheet("QPushButton{background-color :#272727;}\ QPushButton::hover{background-color : #343434;}") + + open(PreferencePath + 'TabOpen.json', "w").write(json.dumps({"TAB_OPEN" : 3})) + + + + + def Section_OpenClose_btn(self, name, size, signal): + ADAP_HEIGHT = (json.load(open(PreferencePath + 'UI_Adapt_Height.json',"r"))['VALUE']) + userWidht = self.width() + + if signal == 1: + NEW_ADAP_HEIGHT = ADAP_HEIGHT + size + self.setMinimumHeight(NEW_ADAP_HEIGHT) + self.resize(userWidht, NEW_ADAP_HEIGHT) + open(PreferencePath + 'Section_' + str(name) + '.json', "w").write(json.dumps({"VALUE": 1})) + open(PreferencePath + 'UI_Adapt_Height.json', "w").write(json.dumps({"VALUE": NEW_ADAP_HEIGHT})) + + + + else: + NEW_ADAP_HEIGHT = ADAP_HEIGHT - size + self.setMinimumHeight(NEW_ADAP_HEIGHT) + self.resize(userWidht, NEW_ADAP_HEIGHT) + open(PreferencePath + 'Section_'+ str(name) + '.json', "w").write(json.dumps({"VALUE": 0})) + open(PreferencePath + 'UI_Adapt_Height.json', "w").write(json.dumps({"VALUE": NEW_ADAP_HEIGHT})) + + + + + + + + def closeEvent(self, event): + # Save window's geometry + settings_obj = QtCore.QSettings(self.settings_path, QtCore.QSettings.IniFormat) + settings_obj.setValue("windowGeometry", self.saveGeometry()) + + ##KILL INTERACTIVE PRIM SCRIPT JOB + JOB_NUMBER = (json.load(open(PreferencePath + 'JobNumber.json', "r"))['JOB_NUMBER']) + try: + mc.scriptJob(kill=JOB_NUMBER, force=True) + except: + pass + + ##DELETE PopUp UI + if mc.window("Bevel2", exists=True): + mc.deleteUI("Bevel2") + if mc.window("Bend", exists=True): + mc.deleteUI("Bend") + if mc.window("Linear Duplication", exists=True): + mc.deleteUI("Linear Duplication") + if mc.window("Radial Duplication", exists=True): + mc.deleteUI("Radial Duplication") + if mc.window("Curve Duplication", exists=True): + mc.deleteUI("Curve Duplication") +##_____________________________________________________________ +##_________________________________________________________________________________// UI +##_____________________________________________________________ + + +if DOCK == 0: + try: + UI.close() # pylint: disable=E0601 + UI.deleteLater() + except: + pass + + UI = ModIt_UI() + UI.show() + +else: + + def Dock(Widget, width=200, height=200, hp="free", show=True): + name = ModIt_Global.ModItTitle + label = getattr(Widget, "label", name) + + try: + cmds.deleteUI(name) + except RuntimeError: + pass + + dockControl = cmds.workspaceControl( + name, + initialWidth=width, + minimumWidth=False, + widthProperty=hp, + heightProperty=hp, + label=label + ) + + dockPtr = omui.MQtUtil.findControl(dockControl) + dockWidget = QtCompat.wrapInstance(int(dockPtr), QtWidgets.QWidget) + dockWidget.setAttribute(QtCore.Qt.WA_DeleteOnClose) + child = Widget(dockWidget) + dockWidget.layout().addWidget(child) + + if show: + cmds.evalDeferred( + lambda *args: cmds.workspaceControl( + dockControl, + edit=True, + widthProperty="free", + restore=True + ) + ) + return child + + + def atClose(): + print("At MODIT CLOSE") + if mc.window("ModIt_Global.ModItTitle", exists=True): + mc.deleteUI("ModIt_Global.ModItTitle") + + + + + + def showUI(): + ui = Dock(ModIt_UI) + ui.show() + + + + # # Get a pointer and convert it to Qt Widget object + # qw = omui.MQtUtil.findWindow(ModIt_Global.ModItTitle) + # try: + # widget = wrapInstance(int(qw), QWidget) + # # Create a QIcon object + # icon = QIcon(IconPath + "ModIt_Window_Ico.png") + # # Assign the icon + # widget.setWindowIcon(icon) + # except: + # pass # Pour si on reload alos qu'il est dock + + # return ui \ No newline at end of file diff --git a/Scripts/Modeling/Edit/ModIt/Qt.py b/Scripts/Modeling/Edit/ModIt/Qt.py new file mode 100644 index 0000000..ec4c910 --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/Qt.py @@ -0,0 +1,1834 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Minimal Python 2 & 3 shim around all Qt bindings + +DOCUMENTATION + Qt.py was born in the film and visual effects industry to address + the growing need for the development of software capable of running + with more than one flavour of the Qt bindings for Python - PySide, + PySide2, PyQt4 and PyQt5. + + 1. Build for one, run with all + 2. Explicit is better than implicit + 3. Support co-existence + + Default resolution order: + - PySide2 + - PyQt5 + - PySide + - PyQt4 + + Usage: + >> import sys + >> from Qt import QtWidgets + >> app = QtWidgets.QApplication(sys.argv) + >> button = QtWidgets.QPushButton("Hello World") + >> button.show() + >> app.exec_() + + All members of PySide2 are mapped from other bindings, should they exist. + If no equivalent member exist, it is excluded from Qt.py and inaccessible. + The idea is to highlight members that exist across all supported binding, + and guarantee that code that runs on one binding runs on all others. + + For more details, visit https://github.com/mottosso/Qt.py + +LICENSE + + See end of file for license (MIT, BSD) information. + +""" + +import os +import sys +import types +import shutil + + +__version__ = "1.2.0.b2" + +# Enable support for `from Qt import *` +__all__ = [] + +# Flags from environment variables +QT_VERBOSE = bool(os.getenv("QT_VERBOSE")) +QT_PREFERRED_BINDING = os.getenv("QT_PREFERRED_BINDING", "") +QT_SIP_API_HINT = os.getenv("QT_SIP_API_HINT") + +# Reference to Qt.py +Qt = sys.modules[__name__] +Qt.QtCompat = types.ModuleType("QtCompat") + +try: + int +except NameError: + # Python 3 compatibility + long = int + + +"""Common members of all bindings + +This is where each member of Qt.py is explicitly defined. +It is based on a "lowest common denominator" of all bindings; +including members found in each of the 4 bindings. + +The "_common_members" dictionary is generated using the +build_membership.sh script. + +""" + +_common_members = { + "QtCore": [ + "QAbstractAnimation", + "QAbstractEventDispatcher", + "QAbstractItemModel", + "QAbstractListModel", + "QAbstractState", + "QAbstractTableModel", + "QAbstractTransition", + "QAnimationGroup", + "QBasicTimer", + "QBitArray", + "QBuffer", + "QByteArray", + "QByteArrayMatcher", + "QChildEvent", + "QCoreApplication", + "QCryptographicHash", + "QDataStream", + "QDate", + "QDateTime", + "QDir", + "QDirIterator", + "QDynamicPropertyChangeEvent", + "QEasingCurve", + "QElapsedTimer", + "QEvent", + "QEventLoop", + "QEventTransition", + "QFile", + "QFileInfo", + "QFileSystemWatcher", + "QFinalState", + "QGenericArgument", + "QGenericReturnArgument", + "QHistoryState", + "QItemSelectionRange", + "QIODevice", + "QLibraryInfo", + "QLine", + "QLineF", + "QLocale", + "QMargins", + "QMetaClassInfo", + "QMetaEnum", + "QMetaMethod", + "QMetaObject", + "QMetaProperty", + "QMimeData", + "QModelIndex", + "QMutex", + "QMutexLocker", + "QObject", + "QParallelAnimationGroup", + "QPauseAnimation", + "QPersistentModelIndex", + "QPluginLoader", + "QPoint", + "QPointF", + "QProcess", + "QProcessEnvironment", + "QPropertyAnimation", + "QReadLocker", + "QReadWriteLock", + "QRect", + "QRectF", + "QRegExp", + "QResource", + "QRunnable", + "QSemaphore", + "QSequentialAnimationGroup", + "QSettings", + "QSignalMapper", + "QSignalTransition", + "QSize", + "QSizeF", + "QSocketNotifier", + "QState", + "QStateMachine", + "QSysInfo", + "QSystemSemaphore", + "QT_TRANSLATE_NOOP", + "QT_TR_NOOP", + "QT_TR_NOOP_UTF8", + "QTemporaryFile", + "QTextBoundaryFinder", + "QTextCodec", + "QTextDecoder", + "QTextEncoder", + "QTextStream", + "QTextStreamManipulator", + "QThread", + "QThreadPool", + "QTime", + "QTimeLine", + "QTimer", + "QTimerEvent", + "QTranslator", + "QUrl", + "QVariantAnimation", + "QWaitCondition", + "QWriteLocker", + "QXmlStreamAttribute", + "QXmlStreamAttributes", + "QXmlStreamEntityDeclaration", + "QXmlStreamEntityResolver", + "QXmlStreamNamespaceDeclaration", + "QXmlStreamNotationDeclaration", + "QXmlStreamReader", + "QXmlStreamWriter", + "Qt", + "QtCriticalMsg", + "QtDebugMsg", + "QtFatalMsg", + "QtMsgType", + "QtSystemMsg", + "QtWarningMsg", + "qAbs", + "qAddPostRoutine", + "qChecksum", + "qCritical", + "qDebug", + "qFatal", + "qFuzzyCompare", + "qIsFinite", + "qIsInf", + "qIsNaN", + "qIsNull", + "qRegisterResourceData", + "qUnregisterResourceData", + "qVersion", + "qWarning", + "qrand", + "qsrand" + ], + "QtGui": [ + "QAbstractTextDocumentLayout", + "QActionEvent", + "QBitmap", + "QBrush", + "QClipboard", + "QCloseEvent", + "QColor", + "QConicalGradient", + "QContextMenuEvent", + "QCursor", + "QDesktopServices", + "QDoubleValidator", + "QDrag", + "QDragEnterEvent", + "QDragLeaveEvent", + "QDragMoveEvent", + "QDropEvent", + "QFileOpenEvent", + "QFocusEvent", + "QFont", + "QFontDatabase", + "QFontInfo", + "QFontMetrics", + "QFontMetricsF", + "QGradient", + "QHelpEvent", + "QHideEvent", + "QHoverEvent", + "QIcon", + "QIconDragEvent", + "QIconEngine", + "QImage", + "QImageIOHandler", + "QImageReader", + "QImageWriter", + "QInputEvent", + "QInputMethodEvent", + "QIntValidator", + "QKeyEvent", + "QKeySequence", + "QLinearGradient", + "QMatrix2x2", + "QMatrix2x3", + "QMatrix2x4", + "QMatrix3x2", + "QMatrix3x3", + "QMatrix3x4", + "QMatrix4x2", + "QMatrix4x3", + "QMatrix4x4", + "QMouseEvent", + "QMoveEvent", + "QMovie", + "QPaintDevice", + "QPaintEngine", + "QPaintEngineState", + "QPaintEvent", + "QPainter", + "QPainterPath", + "QPainterPathStroker", + "QPalette", + "QPen", + "QPicture", + "QPictureIO", + "QPixmap", + "QPixmapCache", + "QPolygon", + "QPolygonF", + "QQuaternion", + "QRadialGradient", + "QRegExpValidator", + "QRegion", + "QResizeEvent", + "QSessionManager", + "QShortcutEvent", + "QShowEvent", + "QStandardItem", + "QStandardItemModel", + "QStatusTipEvent", + "QSyntaxHighlighter", + "QTabletEvent", + "QTextBlock", + "QTextBlockFormat", + "QTextBlockGroup", + "QTextBlockUserData", + "QTextCharFormat", + "QTextCursor", + "QTextDocument", + "QTextDocumentFragment", + "QTextFormat", + "QTextFragment", + "QTextFrame", + "QTextFrameFormat", + "QTextImageFormat", + "QTextInlineObject", + "QTextItem", + "QTextLayout", + "QTextLength", + "QTextLine", + "QTextList", + "QTextListFormat", + "QTextObject", + "QTextObjectInterface", + "QTextOption", + "QTextTable", + "QTextTableCell", + "QTextTableCellFormat", + "QTextTableFormat", + "QTouchEvent", + "QTransform", + "QValidator", + "QVector2D", + "QVector3D", + "QVector4D", + "QWhatsThisClickedEvent", + "QWheelEvent", + "QWindowStateChangeEvent", + "qAlpha", + "qBlue", + "qGray", + "qGreen", + "qIsGray", + "qRed", + "qRgb", + "qRgba" + ], + "QtHelp": [ + "QHelpContentItem", + "QHelpContentModel", + "QHelpContentWidget", + "QHelpEngine", + "QHelpEngineCore", + "QHelpIndexModel", + "QHelpIndexWidget", + "QHelpSearchEngine", + "QHelpSearchQuery", + "QHelpSearchQueryWidget", + "QHelpSearchResultWidget" + ], + "QtMultimedia": [ + "QAbstractVideoBuffer", + "QAbstractVideoSurface", + "QAudio", + "QAudioDeviceInfo", + "QAudioFormat", + "QAudioInput", + "QAudioOutput", + "QVideoFrame", + "QVideoSurfaceFormat" + ], + "QtNetwork": [ + "QAbstractNetworkCache", + "QAbstractSocket", + "QAuthenticator", + "QHostAddress", + "QHostInfo", + "QLocalServer", + "QLocalSocket", + "QNetworkAccessManager", + "QNetworkAddressEntry", + "QNetworkCacheMetaData", + "QNetworkConfiguration", + "QNetworkConfigurationManager", + "QNetworkCookie", + "QNetworkCookieJar", + "QNetworkDiskCache", + "QNetworkInterface", + "QNetworkProxy", + "QNetworkProxyFactory", + "QNetworkProxyQuery", + "QNetworkReply", + "QNetworkRequest", + "QNetworkSession", + "QSsl", + "QTcpServer", + "QTcpSocket", + "QUdpSocket" + ], + "QtOpenGL": [ + "QGL", + "QGLContext", + "QGLFormat", + "QGLWidget" + ], + "QtPrintSupport": [ + "QAbstractPrintDialog", + "QPageSetupDialog", + "QPrintDialog", + "QPrintEngine", + "QPrintPreviewDialog", + "QPrintPreviewWidget", + "QPrinter", + "QPrinterInfo" + ], + "QtSql": [ + "QSql", + "QSqlDatabase", + "QSqlDriver", + "QSqlDriverCreatorBase", + "QSqlError", + "QSqlField", + "QSqlIndex", + "QSqlQuery", + "QSqlQueryModel", + "QSqlRecord", + "QSqlRelation", + "QSqlRelationalDelegate", + "QSqlRelationalTableModel", + "QSqlResult", + "QSqlTableModel" + ], + "QtSvg": [ + "QGraphicsSvgItem", + "QSvgGenerator", + "QSvgRenderer", + "QSvgWidget" + ], + "QtTest": [ + "QTest" + ], + "QtWidgets": [ + "QAbstractButton", + "QAbstractGraphicsShapeItem", + "QAbstractItemDelegate", + "QAbstractItemView", + "QAbstractScrollArea", + "QAbstractSlider", + "QAbstractSpinBox", + "QAction", + "QActionGroup", + "QApplication", + "QBoxLayout", + "QButtonGroup", + "QCalendarWidget", + "QCheckBox", + "QColorDialog", + "QColumnView", + "QComboBox", + "QCommandLinkButton", + "QCommonStyle", + "QCompleter", + "QDataWidgetMapper", + "QDateEdit", + "QDateTimeEdit", + "QDesktopWidget", + "QDial", + "QDialog", + "QDialogButtonBox", + "QDirModel", + "QDockWidget", + "QDoubleSpinBox", + "QErrorMessage", + "QFileDialog", + "QFileIconProvider", + "QFileSystemModel", + "QFocusFrame", + "QFontComboBox", + "QFontDialog", + "QFormLayout", + "QFrame", + "QGesture", + "QGestureEvent", + "QGestureRecognizer", + "QGraphicsAnchor", + "QGraphicsAnchorLayout", + "QGraphicsBlurEffect", + "QGraphicsColorizeEffect", + "QGraphicsDropShadowEffect", + "QGraphicsEffect", + "QGraphicsEllipseItem", + "QGraphicsGridLayout", + "QGraphicsItem", + "QGraphicsItemGroup", + "QGraphicsLayout", + "QGraphicsLayoutItem", + "QGraphicsLineItem", + "QGraphicsLinearLayout", + "QGraphicsObject", + "QGraphicsOpacityEffect", + "QGraphicsPathItem", + "QGraphicsPixmapItem", + "QGraphicsPolygonItem", + "QGraphicsProxyWidget", + "QGraphicsRectItem", + "QGraphicsRotation", + "QGraphicsScale", + "QGraphicsScene", + "QGraphicsSceneContextMenuEvent", + "QGraphicsSceneDragDropEvent", + "QGraphicsSceneEvent", + "QGraphicsSceneHelpEvent", + "QGraphicsSceneHoverEvent", + "QGraphicsSceneMouseEvent", + "QGraphicsSceneMoveEvent", + "QGraphicsSceneResizeEvent", + "QGraphicsSceneWheelEvent", + "QGraphicsSimpleTextItem", + "QGraphicsTextItem", + "QGraphicsTransform", + "QGraphicsView", + "QGraphicsWidget", + "QGridLayout", + "QGroupBox", + "QHBoxLayout", + "QHeaderView", + "QInputDialog", + "QItemDelegate", + "QItemEditorCreatorBase", + "QItemEditorFactory", + "QKeyEventTransition", + "QLCDNumber", + "QLabel", + "QLayout", + "QLayoutItem", + "QLineEdit", + "QListView", + "QListWidget", + "QListWidgetItem", + "QMainWindow", + "QMdiArea", + "QMdiSubWindow", + "QMenu", + "QMenuBar", + "QMessageBox", + "QMouseEventTransition", + "QPanGesture", + "QPinchGesture", + "QPlainTextDocumentLayout", + "QPlainTextEdit", + "QProgressBar", + "QProgressDialog", + "QPushButton", + "QRadioButton", + "QRubberBand", + "QScrollArea", + "QScrollBar", + "QShortcut", + "QSizeGrip", + "QSizePolicy", + "QSlider", + "QSpacerItem", + "QSpinBox", + "QSplashScreen", + "QSplitter", + "QSplitterHandle", + "QStackedLayout", + "QStackedWidget", + "QStatusBar", + "QStyle", + "QStyleFactory", + "QStyleHintReturn", + "QStyleHintReturnMask", + "QStyleHintReturnVariant", + "QStyleOption", + "QStyleOptionButton", + "QStyleOptionComboBox", + "QStyleOptionComplex", + "QStyleOptionDockWidget", + "QStyleOptionFocusRect", + "QStyleOptionFrame", + "QStyleOptionGraphicsItem", + "QStyleOptionGroupBox", + "QStyleOptionHeader", + "QStyleOptionMenuItem", + "QStyleOptionProgressBar", + "QStyleOptionRubberBand", + "QStyleOptionSizeGrip", + "QStyleOptionSlider", + "QStyleOptionSpinBox", + "QStyleOptionTab", + "QStyleOptionTabBarBase", + "QStyleOptionTabWidgetFrame", + "QStyleOptionTitleBar", + "QStyleOptionToolBar", + "QStyleOptionToolBox", + "QStyleOptionToolButton", + "QStyleOptionViewItem", + "QStylePainter", + "QStyledItemDelegate", + "QSwipeGesture", + "QSystemTrayIcon", + "QTabBar", + "QTabWidget", + "QTableView", + "QTableWidget", + "QTableWidgetItem", + "QTableWidgetSelectionRange", + "QTapAndHoldGesture", + "QTapGesture", + "QTextBrowser", + "QTextEdit", + "QTimeEdit", + "QToolBar", + "QToolBox", + "QToolButton", + "QToolTip", + "QTreeView", + "QTreeWidget", + "QTreeWidgetItem", + "QTreeWidgetItemIterator", + "QUndoCommand", + "QUndoGroup", + "QUndoStack", + "QUndoView", + "QVBoxLayout", + "QWhatsThis", + "QWidget", + "QWidgetAction", + "QWidgetItem", + "QWizard", + "QWizardPage" + ], + "QtX11Extras": [ + "QX11Info" + ], + "QtXml": [ + "QDomAttr", + "QDomCDATASection", + "QDomCharacterData", + "QDomComment", + "QDomDocument", + "QDomDocumentFragment", + "QDomDocumentType", + "QDomElement", + "QDomEntity", + "QDomEntityReference", + "QDomImplementation", + "QDomNamedNodeMap", + "QDomNode", + "QDomNodeList", + "QDomNotation", + "QDomProcessingInstruction", + "QDomText", + "QXmlAttributes", + "QXmlContentHandler", + "QXmlDTDHandler", + "QXmlDeclHandler", + "QXmlDefaultHandler", + "QXmlEntityResolver", + "QXmlErrorHandler", + "QXmlInputSource", + "QXmlLexicalHandler", + "QXmlLocator", + "QXmlNamespaceSupport", + "QXmlParseException", + "QXmlReader", + "QXmlSimpleReader" + ], + "QtXmlPatterns": [ + "QAbstractMessageHandler", + "QAbstractUriResolver", + "QAbstractXmlNodeModel", + "QAbstractXmlReceiver", + "QSourceLocation", + "QXmlFormatter", + "QXmlItem", + "QXmlName", + "QXmlNamePool", + "QXmlNodeModelIndex", + "QXmlQuery", + "QXmlResultItems", + "QXmlSchema", + "QXmlSchemaValidator", + "QXmlSerializer" + ] +} + + +def _qInstallMessageHandler(handler): + """Install a message handler that works in all bindings + + Args: + handler: A function that takes 3 arguments, or None + """ + def messageOutputHandler(*args): + # In Qt4 bindings, message handlers are passed 2 arguments + # In Qt5 bindings, message handlers are passed 3 arguments + # The first argument is a QtMsgType + # The last argument is the message to be printed + # The Middle argument (if passed) is a QMessageLogContext + if len(args) == 3: + msgType, logContext, msg = args + elif len(args) == 2: + msgType, msg = args + logContext = None + else: + raise TypeError( + "handler expected 2 or 3 arguments, got {0}".format(len(args))) + + if isinstance(msg, bytes): + # In python 3, some bindings pass a bytestring, which cannot be + # used elsewhere. Decoding a python 2 or 3 bytestring object will + # consistently return a unicode object. + msg = msg.decode() + + handler(msgType, logContext, msg) + + passObject = messageOutputHandler if handler else handler + if Qt.IsPySide or Qt.IsPyQt4: + return Qt._QtCore.qInstallMsgHandler(passObject) + elif Qt.IsPySide2 or Qt.IsPyQt5: + return Qt._QtCore.qInstallMessageHandler(passObject) + + +def _getcpppointer(object): + if hasattr(Qt, "_shiboken2"): + return getattr(Qt, "_shiboken2").getCppPointer(object)[0] + elif hasattr(Qt, "_shiboken"): + return getattr(Qt, "_shiboken").getCppPointer(object)[0] + elif hasattr(Qt, "_sip"): + return getattr(Qt, "_sip").unwrapinstance(object) + raise AttributeError("'module' has no attribute 'getCppPointer'") + + +def _wrapinstance(ptr, base=None): + """Enable implicit cast of pointer to most suitable class + + This behaviour is available in sip per default. + + Based on http://nathanhorne.com/pyqtpyside-wrap-instance + + Usage: + This mechanism kicks in under these circumstances. + 1. Qt.py is using PySide 1 or 2. + 2. A `base` argument is not provided. + + See :func:`QtCompat.wrapInstance()` + + Arguments: + ptr (long): Pointer to QObject in memory + base (QObject, optional): Base class to wrap with. Defaults to QObject, + which should handle anything. + + """ + + assert isinstance(ptr, int), "Argument 'ptr' must be of type " + assert (base is None) or issubclass(base, Qt.QtCore.QObject), ( + "Argument 'base' must be of type ") + + if Qt.IsPyQt4 or Qt.IsPyQt5: + func = getattr(Qt, "_sip").wrapinstance + elif Qt.IsPySide2: + func = getattr(Qt, "_shiboken2").wrapInstance + elif Qt.IsPySide: + func = getattr(Qt, "_shiboken").wrapInstance + else: + raise AttributeError("'module' has no attribute 'wrapInstance'") + + if base is None: + q_object = func(int(ptr), Qt.QtCore.QObject) + meta_object = q_object.metaObject() + class_name = meta_object.className() + super_class_name = meta_object.superClass().className() + + if hasattr(Qt.QtWidgets, class_name): + base = getattr(Qt.QtWidgets, class_name) + + elif hasattr(Qt.QtWidgets, super_class_name): + base = getattr(Qt.QtWidgets, super_class_name) + + else: + base = Qt.QtCore.QObject + + return func(int(ptr), base) + + +def _translate(context, sourceText, *args): + # In Qt4 bindings, translate can be passed 2 or 3 arguments + # In Qt5 bindings, translate can be passed 2 arguments + # The first argument is disambiguation[str] + # The last argument is n[int] + # The middle argument can be encoding[QtCore.QCoreApplication.Encoding] + if len(args) == 3: + disambiguation, encoding, n = args + elif len(args) == 2: + disambiguation, n = args + encoding = None + else: + raise TypeError( + "Expected 4 or 5 arguments, got {0}.".format(len(args) + 2)) + + if hasattr(Qt.QtCore, "QCoreApplication"): + app = getattr(Qt.QtCore, "QCoreApplication") + else: + raise NotImplementedError( + "Missing QCoreApplication implementation for {binding}".format( + binding=Qt.__binding__, + ) + ) + if Qt.__binding__ in ("PySide2", "PyQt5"): + sanitized_args = [context, sourceText, disambiguation, n] + else: + sanitized_args = [ + context, + sourceText, + disambiguation, + encoding or app.CodecForTr, + n + ] + return app.translate(*sanitized_args) + + +def _loadUi(uifile, baseinstance=None): + """Dynamically load a user interface from the given `uifile` + + This function calls `uic.loadUi` if using PyQt bindings, + else it implements a comparable binding for PySide. + + Documentation: + http://pyqt.sourceforge.net/Docs/PyQt5/designer.html#PyQt5.uic.loadUi + + Arguments: + uifile (str): Absolute path to Qt Designer file. + baseinstance (QWidget): Instantiated QWidget or subclass thereof + + Return: + baseinstance if `baseinstance` is not `None`. Otherwise + return the newly created instance of the user interface. + + """ + if hasattr(Qt, "_uic"): + return Qt._uic.loadUi(uifile, baseinstance) + + elif hasattr(Qt, "_QtUiTools"): + # Implement `PyQt5.uic.loadUi` for PySide(2) + + class _UiLoader(Qt._QtUiTools.QUiLoader): + """Create the user interface in a base instance. + + Unlike `Qt._QtUiTools.QUiLoader` itself this class does not + create a new instance of the top-level widget, but creates the user + interface in an existing instance of the top-level class if needed. + + This mimics the behaviour of `PyQt5.uic.loadUi`. + + """ + + def __init__(self, baseinstance): + super(_UiLoader, self).__init__(baseinstance) + self.baseinstance = baseinstance + + def load(self, uifile, *args, **kwargs): + from xml.etree.ElementTree import ElementTree + + # For whatever reason, if this doesn't happen then + # reading an invalid or non-existing .ui file throws + # a RuntimeError. + etree = ElementTree() + etree.parse(uifile) + + widget = Qt._QtUiTools.QUiLoader.load( + self, uifile, *args, **kwargs) + + # Workaround for PySide 1.0.9, see issue #208 + widget.parentWidget() + + return widget + + def createWidget(self, class_name, parent=None, name=""): + """Called for each widget defined in ui file + + Overridden here to populate `baseinstance` instead. + + """ + + if parent is None and self.baseinstance: + # Supposed to create the top-level widget, + # return the base instance instead + return self.baseinstance + + # For some reason, Line is not in the list of available + # widgets, but works fine, so we have to special case it here. + if class_name in self.availableWidgets() + ["Line"]: + # Create a new widget for child widgets + widget = Qt._QtUiTools.QUiLoader.createWidget(self, + class_name, + parent, + name) + + else: + raise Exception("Custom widget '%s' not supported" + % class_name) + + if self.baseinstance: + # Set an attribute for the new child widget on the base + # instance, just like PyQt5.uic.loadUi does. + setattr(self.baseinstance, name, widget) + + return widget + + widget = _UiLoader(baseinstance).load(uifile) + Qt.QtCore.QMetaObject.connectSlotsByName(widget) + + return widget + + else: + raise NotImplementedError("No implementation available for loadUi") + + +"""Misplaced members + +These members from the original submodule are misplaced relative PySide2 + +""" +_misplaced_members = { + "PySide2": { + "QtGui.QStringListModel": "QtCore.QStringListModel", + "QtCore.Property": "QtCore.Property", + "QtCore.Signal": "QtCore.Signal", + "QtCore.Slot": "QtCore.Slot", + "QtCore.QAbstractProxyModel": "QtCore.QAbstractProxyModel", + "QtCore.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel", + "QtCore.QItemSelection": "QtCore.QItemSelection", + "QtCore.QItemSelectionModel": "QtCore.QItemSelectionModel", + "QtCore.QItemSelectionRange": "QtCore.QItemSelectionRange", + "QtUiTools.QUiLoader": ["QtCompat.loadUi", _loadUi], + "shiboken2.wrapInstance": ["QtCompat.wrapInstance", _wrapinstance], + "shiboken2.getCppPointer": ["QtCompat.getCppPointer", _getcpppointer], + "QtWidgets.qApp": "QtWidgets.QApplication.instance()", + "QtCore.QCoreApplication.translate": [ + "QtCompat.translate", _translate + ], + "QtWidgets.QApplication.translate": [ + "QtCompat.translate", _translate + ], + "QtCore.qInstallMessageHandler": [ + "QtCompat.qInstallMessageHandler", _qInstallMessageHandler + ], + }, + "PyQt5": { + "QtCore.pyqtProperty": "QtCore.Property", + "QtCore.pyqtSignal": "QtCore.Signal", + "QtCore.pyqtSlot": "QtCore.Slot", + "QtCore.QAbstractProxyModel": "QtCore.QAbstractProxyModel", + "QtCore.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel", + "QtCore.QStringListModel": "QtCore.QStringListModel", + "QtCore.QItemSelection": "QtCore.QItemSelection", + "QtCore.QItemSelectionModel": "QtCore.QItemSelectionModel", + "QtCore.QItemSelectionRange": "QtCore.QItemSelectionRange", + "uic.loadUi": ["QtCompat.loadUi", _loadUi], + "sip.wrapinstance": ["QtCompat.wrapInstance", _wrapinstance], + "sip.unwrapinstance": ["QtCompat.getCppPointer", _getcpppointer], + "QtWidgets.qApp": "QtWidgets.QApplication.instance()", + "QtCore.QCoreApplication.translate": [ + "QtCompat.translate", _translate + ], + "QtWidgets.QApplication.translate": [ + "QtCompat.translate", _translate + ], + "QtCore.qInstallMessageHandler": [ + "QtCompat.qInstallMessageHandler", _qInstallMessageHandler + ], + }, + "PySide": { + "QtGui.QAbstractProxyModel": "QtCore.QAbstractProxyModel", + "QtGui.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel", + "QtGui.QStringListModel": "QtCore.QStringListModel", + "QtGui.QItemSelection": "QtCore.QItemSelection", + "QtGui.QItemSelectionModel": "QtCore.QItemSelectionModel", + "QtCore.Property": "QtCore.Property", + "QtCore.Signal": "QtCore.Signal", + "QtCore.Slot": "QtCore.Slot", + "QtGui.QItemSelectionRange": "QtCore.QItemSelectionRange", + "QtGui.QAbstractPrintDialog": "QtPrintSupport.QAbstractPrintDialog", + "QtGui.QPageSetupDialog": "QtPrintSupport.QPageSetupDialog", + "QtGui.QPrintDialog": "QtPrintSupport.QPrintDialog", + "QtGui.QPrintEngine": "QtPrintSupport.QPrintEngine", + "QtGui.QPrintPreviewDialog": "QtPrintSupport.QPrintPreviewDialog", + "QtGui.QPrintPreviewWidget": "QtPrintSupport.QPrintPreviewWidget", + "QtGui.QPrinter": "QtPrintSupport.QPrinter", + "QtGui.QPrinterInfo": "QtPrintSupport.QPrinterInfo", + "QtUiTools.QUiLoader": ["QtCompat.loadUi", _loadUi], + "shiboken.wrapInstance": ["QtCompat.wrapInstance", _wrapinstance], + "shiboken.unwrapInstance": ["QtCompat.getCppPointer", _getcpppointer], + "QtGui.qApp": "QtWidgets.QApplication.instance()", + "QtCore.QCoreApplication.translate": [ + "QtCompat.translate", _translate + ], + "QtGui.QApplication.translate": [ + "QtCompat.translate", _translate + ], + "QtCore.qInstallMsgHandler": [ + "QtCompat.qInstallMessageHandler", _qInstallMessageHandler + ], + }, + "PyQt4": { + "QtGui.QAbstractProxyModel": "QtCore.QAbstractProxyModel", + "QtGui.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel", + "QtGui.QItemSelection": "QtCore.QItemSelection", + "QtGui.QStringListModel": "QtCore.QStringListModel", + "QtGui.QItemSelectionModel": "QtCore.QItemSelectionModel", + "QtCore.pyqtProperty": "QtCore.Property", + "QtCore.pyqtSignal": "QtCore.Signal", + "QtCore.pyqtSlot": "QtCore.Slot", + "QtGui.QItemSelectionRange": "QtCore.QItemSelectionRange", + "QtGui.QAbstractPrintDialog": "QtPrintSupport.QAbstractPrintDialog", + "QtGui.QPageSetupDialog": "QtPrintSupport.QPageSetupDialog", + "QtGui.QPrintDialog": "QtPrintSupport.QPrintDialog", + "QtGui.QPrintEngine": "QtPrintSupport.QPrintEngine", + "QtGui.QPrintPreviewDialog": "QtPrintSupport.QPrintPreviewDialog", + "QtGui.QPrintPreviewWidget": "QtPrintSupport.QPrintPreviewWidget", + "QtGui.QPrinter": "QtPrintSupport.QPrinter", + "QtGui.QPrinterInfo": "QtPrintSupport.QPrinterInfo", + # "QtCore.pyqtSignature": "QtCore.Slot", + "uic.loadUi": ["QtCompat.loadUi", _loadUi], + "sip.wrapinstance": ["QtCompat.wrapInstance", _wrapinstance], + "sip.unwrapinstance": ["QtCompat.getCppPointer", _getcpppointer], + "QtCore.QString": "str", + "QtGui.qApp": "QtWidgets.QApplication.instance()", + "QtCore.QCoreApplication.translate": [ + "QtCompat.translate", _translate + ], + "QtGui.QApplication.translate": [ + "QtCompat.translate", _translate + ], + "QtCore.qInstallMsgHandler": [ + "QtCompat.qInstallMessageHandler", _qInstallMessageHandler + ], + } +} + +""" Compatibility Members + +This dictionary is used to build Qt.QtCompat objects that provide a consistent +interface for obsolete members, and differences in binding return values. + +{ + "binding": { + "classname": { + "targetname": "binding_namespace", + } + } +} +""" +_compatibility_members = { + "PySide2": { + "QWidget": { + "grab": "QtWidgets.QWidget.grab", + }, + "QHeaderView": { + "sectionsClickable": "QtWidgets.QHeaderView.sectionsClickable", + "setSectionsClickable": + "QtWidgets.QHeaderView.setSectionsClickable", + "sectionResizeMode": "QtWidgets.QHeaderView.sectionResizeMode", + "setSectionResizeMode": + "QtWidgets.QHeaderView.setSectionResizeMode", + "sectionsMovable": "QtWidgets.QHeaderView.sectionsMovable", + "setSectionsMovable": "QtWidgets.QHeaderView.setSectionsMovable", + }, + "QFileDialog": { + "getOpenFileName": "QtWidgets.QFileDialog.getOpenFileName", + "getOpenFileNames": "QtWidgets.QFileDialog.getOpenFileNames", + "getSaveFileName": "QtWidgets.QFileDialog.getSaveFileName", + }, + }, + "PyQt5": { + "QWidget": { + "grab": "QtWidgets.QWidget.grab", + }, + "QHeaderView": { + "sectionsClickable": "QtWidgets.QHeaderView.sectionsClickable", + "setSectionsClickable": + "QtWidgets.QHeaderView.setSectionsClickable", + "sectionResizeMode": "QtWidgets.QHeaderView.sectionResizeMode", + "setSectionResizeMode": + "QtWidgets.QHeaderView.setSectionResizeMode", + "sectionsMovable": "QtWidgets.QHeaderView.sectionsMovable", + "setSectionsMovable": "QtWidgets.QHeaderView.setSectionsMovable", + }, + "QFileDialog": { + "getOpenFileName": "QtWidgets.QFileDialog.getOpenFileName", + "getOpenFileNames": "QtWidgets.QFileDialog.getOpenFileNames", + "getSaveFileName": "QtWidgets.QFileDialog.getSaveFileName", + }, + }, + "PySide": { + "QWidget": { + "grab": "QtWidgets.QPixmap.grabWidget", + }, + "QHeaderView": { + "sectionsClickable": "QtWidgets.QHeaderView.isClickable", + "setSectionsClickable": "QtWidgets.QHeaderView.setClickable", + "sectionResizeMode": "QtWidgets.QHeaderView.resizeMode", + "setSectionResizeMode": "QtWidgets.QHeaderView.setResizeMode", + "sectionsMovable": "QtWidgets.QHeaderView.isMovable", + "setSectionsMovable": "QtWidgets.QHeaderView.setMovable", + }, + "QFileDialog": { + "getOpenFileName": "QtWidgets.QFileDialog.getOpenFileName", + "getOpenFileNames": "QtWidgets.QFileDialog.getOpenFileNames", + "getSaveFileName": "QtWidgets.QFileDialog.getSaveFileName", + }, + }, + "PyQt4": { + "QWidget": { + "grab": "QtWidgets.QPixmap.grabWidget", + }, + "QHeaderView": { + "sectionsClickable": "QtWidgets.QHeaderView.isClickable", + "setSectionsClickable": "QtWidgets.QHeaderView.setClickable", + "sectionResizeMode": "QtWidgets.QHeaderView.resizeMode", + "setSectionResizeMode": "QtWidgets.QHeaderView.setResizeMode", + "sectionsMovable": "QtWidgets.QHeaderView.isMovable", + "setSectionsMovable": "QtWidgets.QHeaderView.setMovable", + }, + "QFileDialog": { + "getOpenFileName": "QtWidgets.QFileDialog.getOpenFileName", + "getOpenFileNames": "QtWidgets.QFileDialog.getOpenFileNames", + "getSaveFileName": "QtWidgets.QFileDialog.getSaveFileName", + }, + }, +} + + +def _apply_site_config(): + try: + import QtSiteConfig + except ImportError: + # If no QtSiteConfig module found, no modifications + # to _common_members are needed. + pass + else: + # Provide the ability to modify the dicts used to build Qt.py + if hasattr(QtSiteConfig, 'update_members'): + QtSiteConfig.update_members(_common_members) + + if hasattr(QtSiteConfig, 'update_misplaced_members'): + QtSiteConfig.update_misplaced_members(members=_misplaced_members) + + if hasattr(QtSiteConfig, 'update_compatibility_members'): + QtSiteConfig.update_compatibility_members( + members=_compatibility_members) + + +def _new_module(name): + return types.ModuleType(__name__ + "." + name) + + +def _import_sub_module(module, name): + """import_sub_module will mimic the function of importlib.import_module""" + module = __import__(module.__name__ + "." + name) + for level in name.split("."): + module = getattr(module, level) + return module + + +def _setup(module, extras): + """Install common submodules""" + + Qt.__binding__ = module.__name__ + + for name in list(_common_members) + extras: + try: + submodule = _import_sub_module( + module, name) + except ImportError: + try: + # For extra modules like sip and shiboken that may not be + # children of the binding. + submodule = __import__(name) + except ImportError: + continue + + setattr(Qt, "_" + name, submodule) + + if name not in extras: + # Store reference to original binding, + # but don't store speciality modules + # such as uic or QtUiTools + setattr(Qt, name, _new_module(name)) + + +def _reassign_misplaced_members(binding): + """Apply misplaced members from `binding` to Qt.py + + Arguments: + binding (dict): Misplaced members + + """ + + for src, dst in list(_misplaced_members[binding].items()): + dst_value = None + + src_parts = src.split(".") + src_module = src_parts[0] + src_member = None + if len(src_parts) > 1: + src_member = src_parts[1:] + + if isinstance(dst, (list, tuple)): + dst, dst_value = dst + + dst_parts = dst.split(".") + dst_module = dst_parts[0] + dst_member = None + if len(dst_parts) > 1: + dst_member = dst_parts[1] + + # Get the member we want to store in the namesapce. + if not dst_value: + try: + _part = getattr(Qt, "_" + src_module) + while src_member: + member = src_member.pop(0) + _part = getattr(_part, member) + dst_value = _part + except AttributeError: + # If the member we want to store in the namespace does not + # exist, there is no need to continue. This can happen if a + # request was made to rename a member that didn't exist, for + # example if QtWidgets isn't available on the target platform. + _log("Misplaced member has no source: {0}".format(src)) + continue + + try: + src_object = getattr(Qt, dst_module) + except AttributeError: + if dst_module not in _common_members: + # Only create the Qt parent module if its listed in + # _common_members. Without this check, if you remove QtCore + # from _common_members, the default _misplaced_members will add + # Qt.QtCore so it can add Signal, Slot, etc. + msg = 'Not creating missing member module "{m}" for "{c}"' + _log(msg.format(m=dst_module, c=dst_member)) + continue + # If the dst is valid but the Qt parent module does not exist + # then go ahead and create a new module to contain the member. + setattr(Qt, dst_module, _new_module(dst_module)) + src_object = getattr(Qt, dst_module) + # Enable direct import of the new module + sys.modules[__name__ + "." + dst_module] = src_object + + if not dst_value: + dst_value = getattr(Qt, "_" + src_module) + if src_member: + dst_value = getattr(dst_value, src_member) + + setattr( + src_object, + dst_member or dst_module, + dst_value + ) + + +def _build_compatibility_members(binding, decorators=None): + """Apply `binding` to QtCompat + + Arguments: + binding (str): Top level binding in _compatibility_members. + decorators (dict, optional): Provides the ability to decorate the + original Qt methods when needed by a binding. This can be used + to change the returned value to a standard value. The key should + be the classname, the value is a dict where the keys are the + target method names, and the values are the decorator functions. + + """ + + decorators = decorators or dict() + + # Allow optional site-level customization of the compatibility members. + # This method does not need to be implemented in QtSiteConfig. + try: + import QtSiteConfig + except ImportError: + pass + else: + if hasattr(QtSiteConfig, 'update_compatibility_decorators'): + QtSiteConfig.update_compatibility_decorators(binding, decorators) + + _QtCompat = type("QtCompat", (object,), {}) + + for classname, bindings in list(_compatibility_members[binding].items()): + attrs = {} + for target, binding in list(bindings.items()): + namespaces = binding.split('.') + try: + src_object = getattr(Qt, "_" + namespaces[0]) + except AttributeError as e: + _log("QtCompat: AttributeError: %s" % e) + # Skip reassignment of non-existing members. + # This can happen if a request was made to + # rename a member that didn't exist, for example + # if QtWidgets isn't available on the target platform. + continue + + # Walk down any remaining namespace getting the object assuming + # that if the first namespace exists the rest will exist. + for namespace in namespaces[1:]: + src_object = getattr(src_object, namespace) + + # decorate the Qt method if a decorator was provided. + if target in decorators.get(classname, []): + # staticmethod must be called on the decorated method to + # prevent a TypeError being raised when the decorated method + # is called. + src_object = staticmethod( + decorators[classname][target](src_object)) + + attrs[target] = src_object + + # Create the QtCompat class and install it into the namespace + compat_class = type(classname, (_QtCompat,), attrs) + setattr(Qt.QtCompat, classname, compat_class) + + +def _pyside2(): + """Initialise PySide2 + + These functions serve to test the existence of a binding + along with set it up in such a way that it aligns with + the final step; adding members from the original binding + to Qt.py + + """ + + import PySide2 as module + extras = ["QtUiTools"] + try: + try: + # Before merge of PySide and shiboken + import shiboken2 + except ImportError: + # After merge of PySide and shiboken, May 2017 + from PySide2 import shiboken2 + extras.append("shiboken2") + except ImportError: + pass + + _setup(module, extras) + Qt.__binding_version__ = module.__version__ + + if hasattr(Qt, "_shiboken2"): + Qt.QtCompat.wrapInstance = _wrapinstance + Qt.QtCompat.getCppPointer = _getcpppointer + Qt.QtCompat.delete = shiboken2.delete + + if hasattr(Qt, "_QtUiTools"): + Qt.QtCompat.loadUi = _loadUi + + if hasattr(Qt, "_QtCore"): + Qt.__qt_version__ = Qt._QtCore.qVersion() + + if hasattr(Qt, "_QtWidgets"): + Qt.QtCompat.setSectionResizeMode = \ + Qt._QtWidgets.QHeaderView.setSectionResizeMode + + _reassign_misplaced_members("PySide2") + _build_compatibility_members("PySide2") + + +def _pyside(): + """Initialise PySide""" + + import PySide as module + extras = ["QtUiTools"] + try: + try: + # Before merge of PySide and shiboken + import shiboken + except ImportError: + # After merge of PySide and shiboken, May 2017 + from PySide import shiboken + extras.append("shiboken") + except ImportError: + pass + + _setup(module, extras) + Qt.__binding_version__ = module.__version__ + + if hasattr(Qt, "_shiboken"): + Qt.QtCompat.wrapInstance = _wrapinstance + Qt.QtCompat.getCppPointer = _getcpppointer + Qt.QtCompat.delete = shiboken.delete + + if hasattr(Qt, "_QtUiTools"): + Qt.QtCompat.loadUi = _loadUi + + if hasattr(Qt, "_QtGui"): + setattr(Qt, "QtWidgets", _new_module("QtWidgets")) + setattr(Qt, "_QtWidgets", Qt._QtGui) + if hasattr(Qt._QtGui, "QX11Info"): + setattr(Qt, "QtX11Extras", _new_module("QtX11Extras")) + Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info + + Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode + + if hasattr(Qt, "_QtCore"): + Qt.__qt_version__ = Qt._QtCore.qVersion() + + _reassign_misplaced_members("PySide") + _build_compatibility_members("PySide") + + +def _pyqt5(): + """Initialise PyQt5""" + + import PyQt5 as module + extras = ["uic"] + try: + import sip + extras.append(sip.__name__) + except ImportError: + sip = None + + _setup(module, extras) + if hasattr(Qt, "_sip"): + Qt.QtCompat.wrapInstance = _wrapinstance + Qt.QtCompat.getCppPointer = _getcpppointer + Qt.QtCompat.delete = sip.delete + + if hasattr(Qt, "_uic"): + Qt.QtCompat.loadUi = _loadUi + + if hasattr(Qt, "_QtCore"): + Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR + Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR + + if hasattr(Qt, "_QtWidgets"): + Qt.QtCompat.setSectionResizeMode = \ + Qt._QtWidgets.QHeaderView.setSectionResizeMode + + _reassign_misplaced_members("PyQt5") + _build_compatibility_members('PyQt5') + + +def _pyqt4(): + """Initialise PyQt4""" + + import sip + + # Validation of envivornment variable. Prevents an error if + # the variable is invalid since it's just a hint. + try: + hint = int(QT_SIP_API_HINT) + except TypeError: + hint = None # Variable was None, i.e. not set. + except ValueError: + raise ImportError("QT_SIP_API_HINT=%s must be a 1 or 2") + + for api in ("QString", + "QVariant", + "QDate", + "QDateTime", + "QTextStream", + "QTime", + "QUrl"): + try: + sip.setapi(api, hint or 2) + except AttributeError: + raise ImportError("PyQt4 < 4.6 isn't supported by Qt.py") + except ValueError: + actual = sip.getapi(api) + if not hint: + raise ImportError("API version already set to %d" % actual) + else: + # Having provided a hint indicates a soft constraint, one + # that doesn't throw an exception. + sys.stderr.write( + "Warning: API '%s' has already been set to %d.\n" + % (api, actual) + ) + + import PyQt4 as module + extras = ["uic"] + try: + import sip + extras.append(sip.__name__) + except ImportError: + sip = None + + _setup(module, extras) + if hasattr(Qt, "_sip"): + Qt.QtCompat.wrapInstance = _wrapinstance + Qt.QtCompat.getCppPointer = _getcpppointer + Qt.QtCompat.delete = sip.delete + + if hasattr(Qt, "_uic"): + Qt.QtCompat.loadUi = _loadUi + + if hasattr(Qt, "_QtGui"): + setattr(Qt, "QtWidgets", _new_module("QtWidgets")) + setattr(Qt, "_QtWidgets", Qt._QtGui) + if hasattr(Qt._QtGui, "QX11Info"): + setattr(Qt, "QtX11Extras", _new_module("QtX11Extras")) + Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info + + Qt.QtCompat.setSectionResizeMode = \ + Qt._QtGui.QHeaderView.setResizeMode + + if hasattr(Qt, "_QtCore"): + Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR + Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR + + _reassign_misplaced_members("PyQt4") + + # QFileDialog QtCompat decorator + def _standardizeQFileDialog(some_function): + """Decorator that makes PyQt4 return conform to other bindings""" + def wrapper(*args, **kwargs): + ret = (some_function(*args, **kwargs)) + + # PyQt4 only returns the selected filename, force it to a + # standard return of the selected filename, and a empty string + # for the selected filter + return ret, '' + + wrapper.__doc__ = some_function.__doc__ + wrapper.__name__ = some_function.__name__ + + return wrapper + + decorators = { + "QFileDialog": { + "getOpenFileName": _standardizeQFileDialog, + "getOpenFileNames": _standardizeQFileDialog, + "getSaveFileName": _standardizeQFileDialog, + } + } + _build_compatibility_members('PyQt4', decorators) + + +def _none(): + """Internal option (used in installer)""" + + Mock = type("Mock", (), {"__getattr__": lambda Qt, attr: None}) + + Qt.__binding__ = "None" + Qt.__qt_version__ = "0.0.0" + Qt.__binding_version__ = "0.0.0" + Qt.QtCompat.loadUi = lambda uifile, baseinstance=None: None + Qt.QtCompat.setSectionResizeMode = lambda *args, **kwargs: None + + for submodule in list(_common_members.keys()): + setattr(Qt, submodule, Mock()) + setattr(Qt, "_" + submodule, Mock()) + + +def _log(text): + if QT_VERBOSE: + sys.stdout.write(text + "\n") + + +def _convert(lines): + """Convert compiled .ui file from PySide2 to Qt.py + + Arguments: + lines (list): Each line of of .ui file + + Usage: + >> with open("myui.py") as f: + .. lines = _convert(f.readlines()) + + """ + + def parse(line): + line = line.replace("from PySide2 import", "from Qt import QtCompat,") + line = line.replace("QtWidgets.QApplication.translate", + "QtCompat.translate") + if "QtCore.SIGNAL" in line: + raise NotImplementedError("QtCore.SIGNAL is missing from PyQt5 " + "and so Qt.py does not support it: you " + "should avoid defining signals inside " + "your ui files.") + return line + + parsed = list() + for line in lines: + line = parse(line) + parsed.append(line) + + return parsed + + +def _cli(args): + """Qt.py command-line interface""" + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument("--convert", + help="Path to compiled Python module, e.g. my_ui.py") + parser.add_argument("--compile", + help="Accept raw .ui file and compile with native " + "PySide2 compiler.") + parser.add_argument("--stdout", + help="Write to stdout instead of file", + action="store_true") + parser.add_argument("--stdin", + help="Read from stdin instead of file", + action="store_true") + + args = parser.parse_args(args) + + if args.stdout: + raise NotImplementedError("--stdout") + + if args.stdin: + raise NotImplementedError("--stdin") + + if args.compile: + raise NotImplementedError("--compile") + + if args.convert: + sys.stdout.write("#\n" + "# WARNING: --convert is an ALPHA feature.\n#\n" + "# See https://github.com/mottosso/Qt.py/pull/132\n" + "# for details.\n" + "#\n") + + # + # ------> Read + # + with open(args.convert) as f: + lines = _convert(f.readlines()) + + backup = "%s_backup%s" % os.path.splitext(args.convert) + sys.stdout.write("Creating \"%s\"..\n" % backup) + shutil.copy(args.convert, backup) + + # + # <------ Write + # + with open(args.convert, "w") as f: + f.write("".join(lines)) + + sys.stdout.write("Successfully converted \"%s\"\n" % args.convert) + + +def _install(): + # Default order (customise order and content via QT_PREFERRED_BINDING) + default_order = ("PySide2", "PyQt5", "PySide", "PyQt4") + preferred_order = list( + b for b in QT_PREFERRED_BINDING.split(os.pathsep) if b + ) + + order = preferred_order or default_order + + available = { + "PySide2": _pyside2, + "PyQt5": _pyqt5, + "PySide": _pyside, + "PyQt4": _pyqt4, + "None": _none + } + + _log("Order: '%s'" % "', '".join(order)) + + # Allow site-level customization of the available modules. + _apply_site_config() + + found_binding = False + for name in order: + _log("Trying %s" % name) + + try: + available[name]() + found_binding = True + break + + except ImportError as e: + _log("ImportError: %s" % e) + + except KeyError: + _log("ImportError: Preferred binding '%s' not found." % name) + + if not found_binding: + # If not binding were found, throw this error + raise ImportError("No Qt binding were found.") + + # Install individual members + for name, members in list(_common_members.items()): + try: + their_submodule = getattr(Qt, "_%s" % name) + except AttributeError: + continue + + our_submodule = getattr(Qt, name) + + # Enable import * + __all__.append(name) + + # Enable direct import of submodule, + # e.g. import Qt.QtCore + sys.modules[__name__ + "." + name] = our_submodule + + for member in members: + # Accept that a submodule may miss certain members. + try: + their_member = getattr(their_submodule, member) + except AttributeError: + _log("'%s.%s' was missing." % (name, member)) + continue + + setattr(our_submodule, member, their_member) + + # Enable direct import of QtCompat + sys.modules['Qt.QtCompat'] = Qt.QtCompat + + # Backwards compatibility + if hasattr(Qt.QtCompat, 'loadUi'): + Qt.QtCompat.load_ui = Qt.QtCompat.loadUi + + +_install() + +# Setup Binding Enum states +Qt.IsPySide2 = Qt.__binding__ == 'PySide2' +Qt.IsPyQt5 = Qt.__binding__ == 'PyQt5' +Qt.IsPySide = Qt.__binding__ == 'PySide' +Qt.IsPyQt4 = Qt.__binding__ == 'PyQt4' + +"""Augment QtCompat + +QtCompat contains wrappers and added functionality +to the original bindings, such as the CLI interface +and otherwise incompatible members between bindings, +such as `QHeaderView.setSectionResizeMode`. + +""" + +Qt.QtCompat._cli = _cli +Qt.QtCompat._convert = _convert + +# Enable command-line interface +if __name__ == "__main__": + _cli(sys.argv[1:]) + + +# The MIT License (MIT) +# +# Copyright (c) 2016-2017 Marcus Ottosson +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# In PySide(2), loadUi does not exist, so we implement it +# +# `_UiLoader` is adapted from the qtpy project, which was further influenced +# by qt-helpers which was released under a 3-clause BSD license which in turn +# is based on a solution at: +# +# - https://gist.github.com/cpbotha/1b42a20c8f3eb9bb7cb8 +# +# The License for this code is as follows: +# +# qt-helpers - a common front-end to various Qt modules +# +# Copyright (c) 2015, Chris Beaumont and Thomas Robitaille +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the +# distribution. +# * Neither the name of the Glue project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Which itself was based on the solution at +# +# https://gist.github.com/cpbotha/1b42a20c8f3eb9bb7cb8 +# +# which was released under the MIT license: +# +# Copyright (c) 2011 Sebastian Wiesner +# Modifications by Charl Botha +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files +# (the "Software"),to deal in the Software without restriction, +# including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Scripts/Modeling/Edit/ModIt/__init__.py b/Scripts/Modeling/Edit/ModIt/__init__.py new file mode 100644 index 0000000..5175b1d --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/__init__.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from . import * diff --git a/Scripts/Modeling/Edit/ModIt/workspace_control.py b/Scripts/Modeling/Edit/ModIt/workspace_control.py new file mode 100644 index 0000000..018578c --- /dev/null +++ b/Scripts/Modeling/Edit/ModIt/workspace_control.py @@ -0,0 +1,129 @@ +import sys + +from PySide2 import QtCore +from PySide2 import QtWidgets +from shiboken2 import getCppPointer + +import maya.OpenMayaUI as omui +import maya.cmds as cmds + + +class WorkspaceControl(object): + + def __init__(self, name): + self.name = name + self.widget = None + + def create(self, label, widget, ui_script=None): + + cmds.workspaceControl(self.name, label=label) + + if ui_script: + cmds.workspaceControl(self.name, e=True, uiScript=ui_script) + + self.add_widget_to_layout(widget) + self.set_visible(True) + + def restore(self, widget): + self.add_widget_to_layout(widget) + + def add_widget_to_layout(self, widget): + if widget: + self.widget = widget + self.widget.setAttribute(QtCore.Qt.WA_DontCreateNativeAncestors) + + if sys.version_info.major >= 3: + workspace_control_ptr = int(omui.MQtUtil.findControl(self.name)) + widget_ptr = int(getCppPointer(self.widget)[0]) + else: + workspace_control_ptr = long(omui.MQtUtil.findControl(self.name)) + widget_ptr = long(getCppPointer(self.widget)[0]) + + omui.MQtUtil.addWidgetToMayaLayout(widget_ptr, workspace_control_ptr) + + def exists(self): + return cmds.workspaceControl(self.name, q=True, exists=True) + + def is_visible(self): + return cmds.workspaceControl(self.name, q=True, visible=True) + + def set_visible(self, visible): + if visible: + cmds.workspaceControl(self.name, e=True, restore=True) + else: + cmds.workspaceControl(self.name, e=True, visible=False) + + def set_label(self, label): + cmds.workspaceControl(self.name, e=True, label=label) + + def is_floating(self): + return cmds.workspaceControl(self.name, q=True, floating=True) + + def is_collapsed(self): + return cmds.workspaceControl(self.name, q=True, collapse=True) + + + +class DockableUI(QtWidgets.QWidget): + + WINDOW_TITLE = "DockableUI" + + ui_instance = None + + + @classmethod + def display(cls): + if cls.ui_instance: + cls.ui_instance.show_workspace_control() + else: + cls.ui_instance = cls() + + @classmethod + def get_workspace_control_name(cls): + return "{0}WorkspaceControl".format(cls.__name__) + + @classmethod + def get_ui_script(cls): + module_name = cls.__module__ + if module_name == "__main__": + module_name = cls.module_name_override + + ui_script = "from {0} import {1}\n{1}.display()".format(module_name, cls.__name__) + return ui_script + + + def __init__(self): + super(DockableUI, self).__init__() + + self.setObjectName(self.__class__.__name__) + + self.create_actions() + self.create_widgets() + self.create_layout() + self.create_connections() + self.create_workspace_control() + + def create_actions(self): + pass + + def create_widgets(self): + pass + + def create_layout(self): + pass + + def create_connections(self): + pass + + def create_workspace_control(self): + self.workspace_control_instance = WorkspaceControl(self.get_workspace_control_name()) + if self.workspace_control_instance.exists(): + self.workspace_control_instance.restore(self) + else: + self.workspace_control_instance.create(self.WINDOW_TITLE, self, ui_script=self.get_ui_script()) + + def show_workspace_control(self): + self.workspace_control_instance.set_visible(True) + + +