######################################################## # # Script ph_IndicesVertsV1_4.py # # #### USAGE ################################### # # # # Demmarer le script (ALT P ou File-Run), # # creer 2 nouveaux Group # # nommes "SelectedVerts" et "preSelectedVerts", # # en appuyant sur le bouton "CreateSelGroup", # # apres avoir bien-sur selectionne votre objet. # # # # Ensuite selectionnez vos vertex en mode edit # # et assignez les au Group "SelectedVerts", # # puis repassez en mode Object. # # # # Vous pouvez maintenant connaitre l'indice # # de votre selection en cliquant # # sur le bouton "Print indices". # # # # PS: # # Le Group "SelectedVerts" est purge a chaque appui # # sur le bouton, d'ou le Group "preSelectedVerts" # # pour recuperer la selection precedente au cas ou... # # # ########################## # # Ce script n'est pas a premiere vue d'une grande utilite, # mais il me permettra je l'espere une fois developpe, # de resoudre le probleme de perte de "WeightGroup" # qui intervient avec les outils "Knife" et "Loop cut" # quand on modifie un Mesh deja "skinne". # # J'espere 'aussi' (et peut-etre meme 'surtout') # qu'il donnera quelques idees aux "scripteurs" # plus averti que moi. # # N'hesitez pas a m'envoyer vos commentaires si le coeur # vous en dit. # # coolphil@worldonline.fr # #################################### import Blender from Blender import * from Blender.Draw import * from Blender.BGL import * ###################### SelectVertices = [] preSelectVertices = [] def draw(): glClearColor(0.69, 0.5, 0.5, 1) glClear(GL_COLOR_BUFFER_BIT) glColor3f(0.0, 1.0, 0.0) glRasterPos2f(10, 120) Text("Script ph_IndicesVertsV1_4.py") glColor3f(0.0, 0.0, 1.0) glRasterPos2f(10, 97) Text("Ecris les indices des vertex selectionnes.") glColor3f(0.0, 0.0, 0.0) glRasterPos2f(10, 80) Text("Print Selected Vertices indices on console window.") Button("Exit", 1, 150, 10, 40, 25) Button("Print indices", 2, 10, 10, 95, 25) Button("CreateSelGroup", 3, 10, 45, 95, 25) ############ ###################### def event(evt, val): if (evt== QKEY and not val): Exit() ############ ###################### def bevent(evt): if (evt== 1): Exit() elif (evt== 2): PrintSelectVerts() elif (evt== 3): CreateSelGroup() # Blender.Window.Redraw() ############ ###################### def CreateSelGroup(): checkSel = 0 checkPre = 0 object = Object.GetSelected()[0] meshname = object.getData().name mesh = object.getData() ListGroup = mesh.getVertGroupNames() LenGroups = len(ListGroup) for f in range(0,len(ListGroup)): if ListGroup[f] == "SelectedVerts": checkSel = 1 elif ListGroup[f] == "preSelectedVerts": checkPre = 1 if checkPre == 0: mesh.addVertGroup("preSelectedVerts") if checkSel == 0: mesh.addVertGroup("SelectedVerts") ############ def PrintSelectVerts(): try: object = Object.GetSelected()[0] meshname = object.getData().name mesh = object.getData() SelectVertices = mesh.getVertsFromGroup('SelectedVerts',0) preSelectVertices = mesh.getVertsFromGroup('preSelectedVerts',0) if SelectVertices != []: preSelectVertices = mesh.removeVertsFromGroup('preSelectedVerts',preSelectVertices) preSelectVertices = mesh.assignVertsToGroup('preSelectedVerts',SelectVertices,0,"replace") print print "Indices of selected vertices are :" print SelectVertices if SelectVertices == []: print "ATTENTION vous n'avez pas assigne votre selection au Group 'SelectedVerts'!" SelectVertices = mesh.removeVertsFromGroup('SelectedVerts',SelectVertices) except: pass ############ Register(draw, event, bevent)