Skip to content

Instantly share code, notes, and snippets.

@CarstenHoyer
Created October 19, 2020 05:10
Show Gist options
  • Select an option

  • Save CarstenHoyer/9a0a2a438d672679182f327540972a58 to your computer and use it in GitHub Desktop.

Select an option

Save CarstenHoyer/9a0a2a438d672679182f327540972a58 to your computer and use it in GitHub Desktop.
# from http://baronwatts.com/exporting-a-curve-from-blender-to-three-js/
import bpy
obj = bpy.context.active_object
if obj.type == 'CURVE':
for subcurve in obj.data.splines:
curvetype = subcurve.type
print('curve type:', curvetype)
#Display nurbs curve coordinate points in an array
if curvetype == 'NURBS':
print("curve is closed:", subcurve.use_cyclic_u)
for nurbspoint in subcurve.points:
print( [nurbspoint.co[0], nurbspoint.co[1], nurbspoint.co[2]],',')
#Display bezier curve coordinate points in an array
if curvetype == 'BEZIER':
print("curve is closed:", subcurve.use_cyclic_u)
for bezpoint in subcurve.bezier_points:
print( [bezpoint.co[0], bezpoint.co[1], bezpoint.co[2]],',')
if curvetype == 'POLY':
for point in subcurve.points:
print( [point.co[0], point.co[1], point.co[2]],',')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment