Last active
September 5, 2018 18:23
-
-
Save Eterea/e2f6ed9fac703fb0d95e to your computer and use it in GitHub Desktop.
etr_slipUValert.py - Modo script. This is a dirty hack to help with Slip UVs detection.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python | |
# ------------------------------------------------------------------------------------------------------ | |
# NAME: etr_slipUValert.py | |
# VERS: 1.0 | |
# DATE: May 27, 2014 | |
# | |
# MADE: Cristobal Vila, etereaestudios.com | |
# | |
# USES: This is a dirty hack to help with Slip UVs detection. | |
# What this script does is to toggle Slips UVs and, at the same time, toggle a yellow border | |
# (using 'anim.setup on / off') to indicate when that option is enabled or not. | |
# It works even when Transform tools are not enabled. | |
# IMPORTANT NOTE: change Slip UV Startup State Pref to "Last Selected" in MODO 801. | |
# | |
# TODO: Change automatically to 3D viewport (if any is available) if a non-3DVP is selected. | |
# Change automatically to a comp sel mode if a non-comp mode is in use. Return to original at end. | |
# ------------------------------------------------------------------------------------------------------ | |
# Query Selection Mode | |
def selmode(*types): | |
if not types: | |
types = ('vertex', 'edge', 'polygon', 'item', 'pivot', 'center', 'ptag') | |
for t in types: | |
if lx.eval('select.typeFrom %s;vertex;edge;polygon;item;pivot;center;ptag ?' %t): | |
return t | |
mySelMode = selmode() | |
components = ['vertex', 'edge', 'polygon'] | |
# Querying Latest Active Viewport Type and Geometry Presence in active layer (vertsN) | |
viewTy = lx.eval('query view3dservice view.type ? first') | |
lx.eval('query layerservice layer.index ? main') | |
vertsN = lx.eval('query layerservice vert.N ? all') | |
# Dialog to alert that you should be in Component Mode and with a 3DVP active and with some geometry in your active layer | |
if viewTy != 'MO3D' or mySelMode not in components or vertsN == 0: | |
lx.eval('dialog.setup info') | |
lx.eval('dialog.title {To enable Slip UVs Alert...}') | |
lx.eval('dialog.msg {- Your active item mesh should not be empty.\n\ | |
- Be sure to work in Vertex, Edge or Poly mode.\n\ | |
- Your last active viewport should be a 3DVP.}') | |
lx.eval('dialog.open') | |
sys.exit() | |
# Querying Transform tools | |
movSta = lx.eval('tool.set TransformMove ?') | |
rotSta = lx.eval('tool.set TransformRotate ?') | |
scaSta = lx.eval('tool.set TransformScale ?') | |
traSta = lx.eval('tool.set Transform ?') | |
eleSta = lx.eval('tool.set ElementMove ?') | |
uscSta = lx.eval('tool.set TransformUScale ?') | |
# Function to toggle SlipUVs and Yellow Border (using 'anim.setup on / off') | |
def slipStaToggle(): | |
slipSta = lx.eval('tool.attr xfrm.transform lockUV ?') | |
if slipSta == 0: | |
lx.eval('tool.attr xfrm.transform lockUV on') | |
lx.eval('anim.setup on') | |
else: | |
lx.eval('tool.attr xfrm.transform lockUV off') | |
lx.eval('anim.setup off') | |
# For when any transform tool is enabled... | |
if movSta == 'on': | |
slipStaToggle() | |
lx.eval('tool.set TransformMove on') | |
elif rotSta == 'on': | |
slipStaToggle() | |
lx.eval('tool.set TransformRotate on') | |
elif scaSta == 'on': | |
slipStaToggle() | |
lx.eval('tool.set TransformScale on') | |
elif traSta == 'on': | |
slipStaToggle() | |
lx.eval('tool.set Transform on') | |
elif eleSta == 'on': | |
slipStaToggle() | |
lx.eval('tool.set ElementMove on') | |
elif uscSta == 'on': | |
slipStaToggle() | |
lx.eval('tool.set TransformUScale on') | |
# For when all transform tools are disabled... | |
else: | |
lx.eval('tool.set TransformMove on') | |
slipStaToggle() | |
lx.eval('tool.set TransformMove off') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment