Skip to main content
added 140 characters in body; edited title
Source Link
Harry McKenzie
  • 14.5k
  • 11
  • 34
  • 74

Blender Python Script issues, can someone explain the script?

I'm trying to model hypoid gearsHypoid Gears for a model that I'm making. I'm doing the model in AutoCAD/InventorAutoCAD/Inventor, but the only decent free tutorial that I've found for modeling hypoid gearsHypoid Gears is meant for blenderBlender. Most of the steps from the tutorial can be done in AutoCAD, but there's this one part where they use a pythonPython script to transform a flat gear pattern into a cone shape for the gear, and i'm. I'm having difficulty understanding how the script works since I don't know pythonPython. Would someone be able to explain how the script is transforming the gear sketch so I can try and recreate it in CAD. Thanks.

TheThis calculator made the following script:

import bpy
from math import *

obj=bpy.context.object
mesh=obj.data
for i in range(0, len(mesh.vertices)):
 vert=mesh.vertices[i]
 x=vert.co[0]
 y=vert.co[1]
 z=vert.co[2]
 R=3.970
 alpha=14.031*pi/180
 r=sqrt(x*x+y*y)
 teta=atan2(y, x)
 rnew=R+(r-R)*cos(alpha)
 xnew=rnew*cos(teta)
 ynew=rnew*sin(teta)
 znew=(r-R)*sin(alpha)
 vert.co[0]=xnew
 vert.co[1]=ynew
 vert.co[2]=znew

The calculator that made the script: http://www.otvinta.com/hypoid.html

The tutorial I'm using: https://www.youtube.com/watch?v=wWn9gYwnONk&ab_channel=O.T.VintaThis is the YouTube Tutorial I'm using.

Blender Python Script issues

I'm trying to model hypoid gears for a model that I'm making. I'm doing the model in AutoCAD/Inventor, but the only decent free tutorial that I've found for modeling hypoid gears is meant for blender. Most of the steps from the tutorial can be done in AutoCAD, but there's this one part where they use a python script to transform a flat gear pattern into a cone shape for the gear, and i'm having difficulty understanding how the script works since I don't know python. Would someone be able to explain how the script is transforming the gear sketch so I can try and recreate it in CAD. Thanks.

The script:

import bpy
from math import *

obj=bpy.context.object
mesh=obj.data
for i in range(0, len(mesh.vertices)):
 vert=mesh.vertices[i]
 x=vert.co[0]
 y=vert.co[1]
 z=vert.co[2]
 R=3.970
 alpha=14.031*pi/180
 r=sqrt(x*x+y*y)
 teta=atan2(y, x)
 rnew=R+(r-R)*cos(alpha)
 xnew=rnew*cos(teta)
 ynew=rnew*sin(teta)
 znew=(r-R)*sin(alpha)
 vert.co[0]=xnew
 vert.co[1]=ynew
 vert.co[2]=znew

The calculator that made the script: http://www.otvinta.com/hypoid.html

The tutorial I'm using: https://www.youtube.com/watch?v=wWn9gYwnONk&ab_channel=O.T.Vinta

Blender Python Script issues, can someone explain the script?

I'm trying to model Hypoid Gears for a model that I'm making. I'm doing the model in AutoCAD/Inventor, but the only decent free tutorial that I've found for modeling Hypoid Gears is meant for Blender. Most of the steps from the tutorial can be done in AutoCAD, but there's this one part where they use a Python script to transform a flat gear pattern into a cone shape for the gear. I'm having difficulty understanding how the script works since I don't know Python. Would someone be able to explain how the script is transforming the gear sketch so I can try and recreate it in CAD.

This calculator made the following script:

import bpy
from math import *

obj=bpy.context.object
mesh=obj.data
for i in range(0, len(mesh.vertices)):
 vert=mesh.vertices[i]
 x=vert.co[0]
 y=vert.co[1]
 z=vert.co[2]
 R=3.970
 alpha=14.031*pi/180
 r=sqrt(x*x+y*y)
 teta=atan2(y, x)
 rnew=R+(r-R)*cos(alpha)
 xnew=rnew*cos(teta)
 ynew=rnew*sin(teta)
 znew=(r-R)*sin(alpha)
 vert.co[0]=xnew
 vert.co[1]=ynew
 vert.co[2]=znew

This is the YouTube Tutorial I'm using.

Source Link

Blender Python Script issues

I'm trying to model hypoid gears for a model that I'm making. I'm doing the model in AutoCAD/Inventor, but the only decent free tutorial that I've found for modeling hypoid gears is meant for blender. Most of the steps from the tutorial can be done in AutoCAD, but there's this one part where they use a python script to transform a flat gear pattern into a cone shape for the gear, and i'm having difficulty understanding how the script works since I don't know python. Would someone be able to explain how the script is transforming the gear sketch so I can try and recreate it in CAD. Thanks.

The script:

import bpy
from math import *

obj=bpy.context.object
mesh=obj.data
for i in range(0, len(mesh.vertices)):
 vert=mesh.vertices[i]
 x=vert.co[0]
 y=vert.co[1]
 z=vert.co[2]
 R=3.970
 alpha=14.031*pi/180
 r=sqrt(x*x+y*y)
 teta=atan2(y, x)
 rnew=R+(r-R)*cos(alpha)
 xnew=rnew*cos(teta)
 ynew=rnew*sin(teta)
 znew=(r-R)*sin(alpha)
 vert.co[0]=xnew
 vert.co[1]=ynew
 vert.co[2]=znew

The calculator that made the script: http://www.otvinta.com/hypoid.html

The tutorial I'm using: https://www.youtube.com/watch?v=wWn9gYwnONk&ab_channel=O.T.Vinta