I have written my first blender script!
It’s nothing fancy. I needed to be able to measure the area of all selected faces in a mesh and macouno’s measure mesh script has some issues with the latest version. I didn’t get into the trouble of modyfying his script for it looked a bit scary for my newbie skills :eyebrowlift:
It can be found in the misc section and:
- if you are in edit mode, hitting the area button will give you the total area of all faces selected.
- if you are in object mode, hitting the area button will give you the total area of all faces on the selected mesh.That’s all for now. I hope this proves usefull to someone other than me :). If you have any suggestions please tell me. Since i cannot post attachements (?) here is the script:
#!BPY
"""
Name: 'Face Area'
Blender: 245
Group: 'Misc'
Tooltip: 'Measure the area of the selected faces'
"""
import Blender as B
global total_area
total_area = 0.0
def calcArea():
in_edit = B.Window.EditMode()
if in_edit: B.Window.EditMode(0)
objects = B.Object.GetSelected();
obj = objects[0]
me = obj.getData(mesh=True)
faces = me.faces
global total_area
total_area = 0.0
for f in faces:
if in_edit:
if f.sel:
total_area += f.area
else:
total_area +=f.area
if in_edit: B.Window.EditMode(1)
def gui():
B.Draw.Button("AREA", 1, 10, 10, 60, 20, "Measure your currently selected object")
B.BGL.glRasterPos2d(80, 15)
B.Draw.Text(str(total_area))
def bevent(evt):
if evt == 1 :
calcArea()
B.Draw.Redraw(1)
print total_area
B.Draw.Register(gui,None,bevent)