Skip to content

Commit

Permalink
Added Separator Script
Browse files Browse the repository at this point in the history
  • Loading branch information
AnDCGI committed Apr 20, 2023
1 parent d0d71f9 commit 16de9d7
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 0 deletions.
Binary file added icons/separator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/alizarin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/amethyst.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/carrot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/clouds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/concrete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/emerald.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/peterriver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/sunflower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/turquoise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/separatorIcons/wetasphalt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions prefs/shelf/shelf_AnDCGI.mel
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,40 @@ global proc shelf_AnDCGI () {
-style "shelf"
-horizontal 0
;
shelfButton
-enableCommandRepeat 1
-flexibleWidthType 3
-flexibleWidthValue 32
-enable 1
-width 35
-height 34
-manage 1
-visible 1
-preventOverride 0
-annotation "Fancy Separator"
-enableBackground 0
-backgroundColor 0 0 0
-highlightColor 0.321569 0.521569 0.65098
-align "center"
-label "Fancy Separator"
-labelOffset 0
-rotation 0
-flipX 0
-flipY 0
-useAlpha 1
-font "plainLabelFont"
-overlayLabelColor 0.8 0.8 0.8
-overlayLabelBackColor 0 0 0 0.5
-image "separator.png"
-image1 "separator.png"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "import imp\nimport fancySeparator\nimp.reload(fancySeparator)"
-sourceType "python"
-commandRepeatable 1
-flat 1
;
shelfButton
-enableCommandRepeat 1
-flexibleWidthType 3
Expand Down
109 changes: 109 additions & 0 deletions scripts/py-scripts/fancySeparator/fancySeparator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# © 2019 AnD CGI This work is licensed under a Creative Commons
# Attribution-ShareAlike 4.0 International License.
"""
Fancy Separator. This script is intended to function as a shelf button within Maya, opening a pop-up window with all of
the predefined shelf icons. The user can use the icons given or choose own icons as well. The separator has very little
width, therefore depending on the custom image, custom icon separator may appear distorted.
Original MEL script by Giuseppe Russo, thanks sharing it with the community. Modified to work on Python 3.
"""

import maya.cmds as cmds # Importing The Main Maya Python Module
import maya.mel as mel # Importing The Mel Python Wrapper Module

version = 1.0
windowNameSeparator = 'separatorUI' # Declaring Window ID

if cmds.window(windowNameSeparator, ex=1):
cmds.deleteUI(windowNameSeparator)
cmds.windowPref(windowNameSeparator, remove=1)


def addSeparator(color, custom):
mel.eval('global string $gShelfTopLevel')
# Get the Current Active Shelf
ActiveShelf = str(cmds.tabLayout(mel.eval('$temp=$gShelfTopLevel'), q=1, selectTab=1))
# For Custom Icon
icon = ''
if custom == 0:
icon = 'separatoricons/' + color + '.png'
elif color == '':
cmds.error('Please select an icon')
else:
icon = color
cmds.shelfButton(style='iconOnly',
enable=1,
parent=ActiveShelf,
visible=1,
image=icon,
manage=1,
height=32,
width=10,
command=lambda *args: mel.eval('separatorUI'),
label='customSeparator',
annotation='Separator',
doubleClickCommand=lambda *args: mel.eval('separatorUI()'))
print('\nSeparator Added!')


cmds.window(windowNameSeparator,
maximizeButton=False,
sizeable=False,
resizeToFitChildren=True,
title='Create Separator',
tlb=True)

# For Custom Image
cmds.rowColumnLayout()
cmds.button(c=lambda *args: cmds.evalDeferred(lambda: addSeparator(
cmds.fileDialog2(fileFilter='*.png')[0] if cmds.fileDialog2(ff='PNG files (*.png)', fm=1) else None, 1)),
l='Custom Icon')
cmds.setParent('..')
# Grid Layout
cmds.gridLayout(numberOfColumns=5, ag=True, cellWidthHeight=(65, 60))
# Line 1 Images
cmds.iconTextButton(c=lambda *args: addSeparator('turquoise', 0),
style='iconAndTextVertical',
image='separatoricons/turquoise.png',
label='Turquoise')
cmds.iconTextButton(c=lambda *args: addSeparator('emerald', 0),
style='iconAndTextVertical',
image='separatoricons/emerald.png',
label='Emerald')
cmds.iconTextButton(c=lambda *args: addSeparator('peterriver', 0),
style='iconAndTextVertical',
image='separatoricons/peterriver.png',
label='Peter River')
cmds.iconTextButton(c=lambda *args: addSeparator('amethyst', 0),
style='iconAndTextVertical',
image='separatoricons/amethyst.png',
label='Amethyst')
cmds.iconTextButton(c=lambda *args: addSeparator('wetasphalt', 0),
style='iconAndTextVertical',
image='separatoricons/wetasphalt.png',
label='Wet Asphalt')
# Line 2 Images
cmds.iconTextButton(c=lambda *args: addSeparator('sunflower', 0),
style='iconAndTextVertical',
image='separatoricons/sunflower.png',
label='Sunflower')
cmds.iconTextButton(c=lambda *args: addSeparator('carrot', 0),
style='iconAndTextVertical',
image='separatoricons/carrot.png',
label='Carrot')
cmds.iconTextButton(c=lambda *args: addSeparator('alizarin', 0),
style='iconAndTextVertical',
image='separatoricons/alizarin.png',
label='Alizarin')
cmds.iconTextButton(c=lambda *args: addSeparator('clouds', 0),
style='iconAndTextVertical',
image='separatoricons/clouds.png',
label='Clouds')
cmds.iconTextButton(c=lambda *args: addSeparator('concrete', 0),
style='iconAndTextVertical',
image='separatoricons/concrete.png',
label='Concrete')
cmds.setParent('..')
cmds.showWindow()

0 comments on commit 16de9d7

Please sign in to comment.