How to Apply Size/Rotation using python

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

truenoeks
Posts: 8
Joined: Wed Oct 16, 2002 8:47 pm

How to Apply Size/Rotation using python

Postby truenoeks » Wed May 14, 2003 9:29 pm

How can one perform the Apply Size/Rotation function using Python?

Thanx

Truenoeks

:?: :!: :!: :?:

Anthony
Posts: 16
Joined: Fri Oct 25, 2002 5:14 am

Re: How to Apply Size/Rotation using python

Postby Anthony » Sat Jun 28, 2003 10:36 pm

I've done this for my LightWave IO script. Here's a function that should be called for each vertex with the object's matrix:

Code: Select all

# =======================
# === Apply Transform ===
# =======================
def apply_transform(verts, matrix):
   x, y, z = verts
   xloc, yloc, zloc = matrix[3][0], matrix[3][1], matrix[3][2]
   xcomponent = x*matrix[0][0] + y*matrix[1][0] + z*matrix[2][0] + xloc
   ycomponent = x*matrix[0][1] + y*matrix[1][1] + z*matrix[2][1] + yloc
   zcomponent = x*matrix[0][2] + y*matrix[1][2] + z*matrix[2][2] + zloc
   verts = [xcomponent, ycomponent, zcomponent]
   return verts


Call it like so:

Code: Select all

for i in range(len(mesh.verts)):
   x, y, z = apply_transform(mesh.verts[i].co, matrix)

truenoeks
Posts: 8
Joined: Wed Oct 16, 2002 8:47 pm

Postby truenoeks » Tue Jul 01, 2003 9:21 pm

Thanks. I really appreciate it!

:lol:


Return to “Python”

Who is online

Users browsing this forum: No registered users and 2 guests