BPY Name Export Bezier Curve Points xyz Blender 246 Group Export Toolt

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
#!BPY
"""
Name: 'Export Bezier Curve Points (.xyz)...'
Blender: 246
Group: 'Export'
Tooltip: 'Only Exports Selected Bezier (open and closed) Curves'
"""
__author__ = "Roy Goodell"
__url__ = ['5xj.com']
__version__ = "1.00"
__bpydoc__ = """\
This script exports 3D bezier curves to a *.xyz bezier curve points file.
Usage:
Select the objects you wish to export and run this script from the
"File->Export" menu.
All individual curves will be exported as separate objects.
NOTE:
Matt Ebb / ProMotion Studios, mke3.net wrote the origional script named:
export_curves_fcollada-1.1.py
The only thing I've done to his script is to remove some of the
formating characters to make it easier to manipulate the data with
my routine: BezierNC.exe.
"""
import Blender, BPySys
from Blender import *
def save_curve_fcollada(filename):
scn = Scene.GetCurrent()
file = open(filename, "w")
geomlist = []
for ob in scn.objects.selected:
if ob.type != 'Curve': continue
curvedata = ob.data
curvedataname = BPySys.cleanName(curvedata.name)
for cni, curnurb in enumerate(curvedata):
cname = "%s-%d" % (curvedataname, cni)
geominfo = {}
if len(curnurb) > 1: geominfo['obname'] = BPySys.cleanName(ob.name) + '-' + cname
else: geominfo['obname'] = BPySys.cleanName(ob.name)
# Store geometry info for each sub-curve, since they will be split
# into individual geometry nodes
geominfo['dataname'] = cname
geominfo['translate'] = '%.5f %.5f %.5f' % (ob.LocX, ob.LocY, ob.LocZ)
geominfo['rotateZ'] = '%.5f' % ob.RotZ
geominfo['rotateY'] = '%.5f' % ob.RotY
geominfo['rotateX'] = '%.5f' % ob.RotX
geominfo['scale'] = '%.5f %.5f %.5f' % (ob.SizeX, ob.SizeY, ob.SizeZ)
geomlist.append(geominfo)
if curnurb.isCyclic(): numpoints = 3*len(curnurb)
else: numpoints = 3*(len(curnurb))-2 # minus start h2 and end h2
file.write('; spline %d pts %d %s\n' % (curnurb.isCyclic(), numpoints, cname))
cvs = ''
for pni, point in enumerate(curnurb):
# only include h1 for first point of closed (cyclic) curves, ignore for open curves
if pni or curnurb.isCyclic():
cvs += '%.5f %.5f %.5f ' % (point.vec[0][0], point.vec[0][1], point.vec[0][2])
cvs += '%.5f %.5f %.5f' % (point.vec[1][0], point.vec[1][1], point.vec[1][2])
# only include h2 for last point of closed (cyclic) curves, ignore for open curves
if pni!=len(curnurb)-1 or curnurb.isCyclic():
cvs += ' %.5f %.5f %.5f' % (point.vec[2][0], point.vec[2][1], point.vec[2][2])
cvs += '\n'
file.write(cvs)
scnname = BPySys.cleanName(scn.name)
# Separate node for each connected curve segment.
for g in geomlist:
file.write('; name %s\n' % g['obname'])
file.write('; translate %s\n' % g['translate'])
file.write('; rotate %s %s %s\n' % (g['rotateX'], g['rotateY'], g['rotateZ']))
file.write('; scale %s\n' % g['scale'])
file.close()
Window.FileSelector(save_curve_fcollada, 'Export Bezier Curve Points')