Skip to content

Instantly share code, notes, and snippets.

@Farfarer
Created July 15, 2016 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Farfarer/6a6de0c6c3cb5018127d270bfc670ad9 to your computer and use it in GitHub Desktop.
Save Farfarer/6a6de0c6c3cb5018127d270bfc670ad9 to your computer and use it in GitHub Desktop.
Install to "lxserv" directory in your script directory. Restart MODO. Use it by calling the command "ffr.deleteNamelessVMaps".
#!/usr/bin/env python
import lx
import lxifc
import lxu.command
class DeleteMaps (lxifc.Visitor):
def __init__ (self, meshmap):
self.meshmap = meshmap
def vis_Evaluate (self):
try:
name = self.meshmap.Name ()
except:
name = None
if name is None or len(name) == 0:
try:
self.meshmap.Remove ()
except:
pass
class DeleteNamelessVMaps_Cmd(lxu.command.BasicCommand):
def __init__(self):
lxu.command.BasicCommand.__init__ (self)
def basic_ButtonName(self):
return "Delete Nameless Vertex Maps"
def cmd_Tooltip(self):
return "Delete all nameless vertex maps"
def cmd_UserName(self):
return "Delete Nameless Vertex Maps"
def cmd_Flags(self):
return lx.symbol.fCMD_UNDO | lx.symbol.fCMD_MODEL
def basic_Execute(self, msg, flags):
layer_svc = lx.service.Layer ()
layer_scan = lx.object.LayerScan (layer_svc.ScanAllocate (lx.symbol.f_LAYERSCAN_EDIT))
if not layer_scan.test ():
return
layer_scan_count = layer_scan.Count ()
for l in xrange (layer_scan_count):
mesh = lx.object.Mesh (layer_scan.MeshEdit (l))
if not mesh.test ():
continue
meshmap = lx.object.MeshMap (mesh.MeshMapAccessor ())
if not meshmap.test ():
continue
visitor = DeleteMaps (meshmap)
meshmap.Enumerate (lx.symbol.iMARK_ANY, visitor, 0)
layer_scan.SetMeshChange (l, lx.symbol.f_MESHEDIT_MAP_OTHER | lx.symbol.f_MESHEDIT_MAP_UV | lx.symbol.f_MESHEDIT_MAP_MORPH | lx.symbol.f_MESHEDIT_MAP_CONTINUITY)
layer_scan.Apply ()
lx.bless (DeleteNamelessVMaps_Cmd, "ffr.deleteNamelessVMaps")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment