4
Name: 'DEC Object File Format (.off)...'
7
Tooltip: 'Import Object File Format (*.off)'
7
Tooltip: 'Import DEC Object File Format (*.off)'
10
__author__ = "Anthony D'Agostino (Scorpius)"
11
__url__ = ("blender", "elysiun",
12
"Author's homepage, http://www.redrival.com/scorpius")
13
__version__ = "Part of IOSuite 0.5"
16
This script imports DEC Object File Format files to Blender.
18
The DEC (Digital Equipment Corporation) OFF format is very old and
19
almost identical to Wavefront's OBJ. I wrote this so I could get my huge
20
meshes into Moonlight Atelier. (DXF can also be used but the file size
21
is five times larger than OFF!) Blender/Moonlight users might find this
22
script to be very useful.
25
Execute this script from the "File->Import" menu and choose an OFF file to
29
UV Coordinate support has been added.
10
33
# +---------------------------------------------------------+
11
34
# | Copyright (c) 2002 Anthony D'Agostino |
12
# | http://ourworld.compuserve.com/homepages/scorpius |
13
# | scorpius@compuserve.com |
35
# | http://www.redrival.com/scorpius |
36
# | scorpius@netzero.com |
14
37
# | February 3, 2001 |
15
38
# | Released under the Blender Artistic Licence (BAL) |
16
39
# | Import Export Suite v0.5 |
18
41
# | Read and write Object File Format (*.off) |
19
42
# +---------------------------------------------------------+
44
import Blender, meshtools
23
import mod_flags, mod_meshtools
25
47
# =============================
26
48
# ====== Read OFF Format ======
35
58
# === OFF Header ===
36
59
offheader = file.readline()
37
60
numverts, numfaces, null = file.readline().split()
38
61
numverts = int(numverts)
39
62
numfaces = int(numfaces)
63
if offheader.find('ST') >= 0:
41
68
# === Vertex List ===
42
69
for i in range(numverts):
43
if not i%100 and mod_flags.show_progress:
70
if not i%100 and meshtools.show_progress:
44
71
Blender.Window.DrawProgressBar(float(i)/numverts, "Reading Verts")
45
x, y, z = file.readline().split()
46
x, y, z = float(x), float(y), float(z)
73
x, y, z, u, v = map(float, file.readline().split())
76
x, y, z = map(float, file.readline().split())
47
77
verts.append((x, y, z))
49
79
# === Face List ===
50
80
for i in range(numfaces):
51
if not i%100 and mod_flags.show_progress:
81
if not i%100 and meshtools.show_progress:
52
82
Blender.Window.DrawProgressBar(float(i)/numfaces, "Reading Faces")
53
83
line = file.readline().split()
54
84
numfaceverts = len(line)-1
62
92
objname = Blender.sys.splitext(Blender.sys.basename(filename))[0]
64
mod_meshtools.create_mesh(verts, faces, objname)
94
meshtools.create_mesh(verts, faces, objname, faces, uv)
65
95
Blender.Window.DrawProgressBar(1.0, '') # clear progressbar
67
97
#end = time.clock()
68
98
#seconds = " in %.2f %s" % (end-start, "seconds")
69
99
message = "Successfully imported " + Blender.sys.basename(filename)# + seconds
70
mod_meshtools.print_boxed(message)
100
meshtools.print_boxed(message)
72
102
def fs_callback(filename):
75
Blender.Window.FileSelector(fs_callback, "OFF Import")
105
Blender.Window.FileSelector(fs_callback, "Import OFF")