Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Ex_Clear_Vert_Weights.py
# python
#
# Author: Jeff LeRoy (extol) www.leroyfx.com
#
# Ex_Clear_Vert_Weights.py v1.1
#
#------------------------------------------------------------------------------------------------
#--TO_DO-----------------------------------------------------------------------------------------
#
#------------------------------------------------------------------------------------------------
#--VAR-------------------------------------------------------------------------------------------
sel_MeshID = lx.eval('query layerservice layer.index ? main')
num_Layers = lx.eval ('query layerservice layer.N ? all')#get number of mesh layers
L_Layers = lx.eval ('query layerservice layers ?')#get a list of all mesh layers in scene
num_SelLayers = lx.eval('query layerservice layer.N ? fg')#get number of selected mesh layers
L_SelLayers = lx.eval ('query layerservice layers ? fg')#get a list of selected mesh layers
selMode = lx.eval ('query layerservice selmode ?')#get selection mode
#------------------------------------------------------------------------------------------------
#--CODE------------------------------------------------------------------------------------------
#select all mesh layers
if num_Layers > 1:
for i in L_Layers:
lx.eval ('select.layer %s add' % i)
elif num_Layers == 1:
lx.eval ('select.layer 1')
#select verts in subdivision weight map and set value to 0.0
lx.eval ('select.vertex add 3 0 Subdivision') #select verts in the Subdivision weight map
lx.eval ('select.vertexMap Subdivision subd replace')
lx.eval ('tool.set vertMap.setWeight on')
lx.eval ('tool.setAttr vertMap.setWeight weight 0.0')
lx.eval ('tool.noChange')
lx.eval ('tool.doApply')
lx.eval ('tool.drop')
lx.eval ('select.drop vertex')
#drop selection so script can select only layers that were originally selected
lx.eval ('select.drop item')
#restore selected mesh layers
if num_SelLayers > 1:
for i in L_SelLayers:
lx.eval ('select.layer %s add' % i)
elif num_SelLayers == 1:
lx.eval ('select.layer %s add' % L_SelLayers)
#restore selection mode
lx.eval ('select.typeFrom %s' % selMode)
#------------------------------------------------------------------------------------------------
#--UPDATES---------------------------------------------------------------------------------------
# V1.1
# -Restores selected layers and selection mode
# -Works with one or more mesh layers
#------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment