Skip to content

Instantly share code, notes, and snippets.

@Jeff-LeRoy
Last active August 29, 2015 14:02
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 Jeff-LeRoy/2e032b56732c9451ceab to your computer and use it in GitHub Desktop.
Save Jeff-LeRoy/2e032b56732c9451ceab to your computer and use it in GitHub Desktop.
# python
#
# Author: Jeff LeRoy (extol) www.leroyfx.com
#
# Ex_Turbo_Split.py v1.2
#
#------------------------------------------------------------------------------------------------
#--TO_USE-----------------------------------------------------------------------------------------
#
# This will connect a selection of verticies to a target vert. It will run throught the list of
# vertices and run poly split between the current vert in the list and the Target Vert. The last vertex selected
# will be the target vert. For a visual representation you can visit the modo_scripts section of my website.
#
#------------------------------------------------------------------------------------------------
#-TO_DO------------------------------------------------------------------------------------------
#
# -Symm
#
#------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------
#
sel_meshes = lx.eval ('query sceneservice selection ? mesh') #how many mesh items selected
L_startingVerts = []
#
#------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------
sel_meshType = type(sel_meshes)#check for the type of sel_meshes
def TurboSplit ():
num_vertCount = lx.eval('query layerservice vert.N ?') #how many TOTAL verts are selected
sel_verts = lx.evalN('query layerservice verts ? selected') #get a list of the INDIVIDUAL verts selected
if num_vertCount > 1: #make sure there are verts selected
if num_vertCount == 2:#if only two just run poly.split
lx.eval ('poly.split')
lx.eval ('select.drop vertex')
else:
for v in sel_verts:
L_startingVerts.append(v) #add selected verts to list
lx.eval ('select.drop vertex')
targetVert = L_startingVerts[-1]
del L_startingVerts[-1]#remove this so it wont try to connect to itself
for i in L_startingVerts: #Run through list and connect verts to targetvert
lx.eval ('select.element layer:%s type:vertex mode:add index:%s' % (sel_MeshID, i))#select vert from list
lx.eval ('select.element layer:%s type:vertex mode:add index:%s' % (sel_MeshID, targetVert))#select target vert
lx.eval ('poly.split')
lx.eval ('select.drop vertex')
lx.eval ('select.drop vertex')
if sel_meshType is str:#string so one mesh item selected
sel_MeshID = lx.eval('query layerservice layer.index ? main')
TurboSplit ()
elif sel_meshType is tuple:#tuple so multiple mesh items selected
for currentMesh in sel_meshes:#run through each mesh item
#this will query to see what layer index the current mesh is on (1/2/3 etc..) used when selecting verts
sel_MeshID = lx.eval ('query layerservice layer.index ? %s' % currentMesh)
TurboSplit()
#------------------------------------------------------------------------------------------------
#-UPDATES----------------------------------------------------------------------------------------
#
# --v1.2
# --Script now works if you have multiple mesh items/layers selected
# --Drops selection after just running poly.split if just two verts selected
# --v1.1
# --If only 2 verts just run poly split
# --Cleaned code
#------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment