Jump to content

Get vertex index in blender


Alecu

Recommended Posts

It does have one,but it just displays the number of selected vertices. But it turn out you can get the index by writing a very simple python script that iterates through the vertex list and displays their indexes. I'll try to write one later and post it here. I won't have more than 60 lines or so. I'm currently trying to figure out how to add a textbox and some simple buttons in blender using the script.

 

;** Comment Line **
obj_blend = Blender.Object.Get("Cube")
obj_blend.RotX = obj_blend.RotX + 90
print (obj_blend.Name)
If Len(obj_blend.Name <= 0) : print("This is an example code box")
Blender.Redraw()
Return 0

Edited by LHammonds
Added codebox BBCode as an example
Link to comment
Share on other sites

Thank you very much for the reply. I still learned a bit of python and made the script that writes all the selected vertices from all the objects in a text file.

Here's the script:

 

#!BPY

"""
Name: 'Export Selected Vertices'
Blender: 249
Group: 'Export'
Tooltip: 'Selected Vertices Exporter'
"""
import Blender
import bpy

def exportVertices(filename):
out = file(filename, "w")
sce = bpy.data.scenes.active
for ob in sce.objects:
	try:
		mesh = ob.getData(mesh=1)
		out.write(ob.name + "\n")
		for vert in mesh.verts:
			if vert.sel == 1:
				out.write( ' v %s \n' % (vert.index) )
	except:
		print( "Object %s probably doesn't have any vertices" % ( ob.name ))
out.close()

Blender.Window.FileSelector(exportVertices,"export")

 

I was busy figuring out how to add some buttons with some options,like only exporting the vertices from a certain object. And some objects don't have the verts attribute,so I added an exception handler for that,but maybe if refers to the fact that the reference is null or something like that and accessing a null reference is illegal. I'll look into it a bit more.

 

I really like the fact that you can write your own script for blender in a very nice language.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...