2 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 # + This file is part of enGrid. +
6 # + Copyright 2008-2014 enGits GmbH +
8 # + enGrid is free software: you can redistribute it and/or modify +
9 # + it under the terms of the GNU General Public License as published by +
10 # + the Free Software Foundation, either version 3 of the License, or +
11 # + (at your option) any later version. +
13 # + enGrid is distributed in the hope that it will be useful, +
14 # + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 # + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 # + GNU General Public License for more details. +
18 # + You should have received a copy of the GNU General Public License +
19 # + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 Name: 'Engrid (*.begc)'
27 Tooltip: 'Import from Engrid'
34 def readEngrid(filename
):
35 Blender
.Window
.WaitCursor(1)
36 Vector
= Blender
.Mathutils
.Vector
38 in_file
= file(filename
, "r")
39 line
= in_file
.readline()
41 #print "Nobjects=",Nobjects
43 for i
in range(0, Nobjects
):
44 line
= in_file
.readline()
45 object_names
.append(line
.strip())
47 #print "object_names=",object_names
51 for i_object
in range(0, Nobjects
):
52 line
= in_file
.readline()
54 Nverts
= int(words
[0])
55 Nfaces
= int(words
[1])
56 #print "Nverts=",Nverts
57 #print "Nfaces=",Nfaces
60 for i_vert
in range(0, Nverts
):
61 line
= in_file
.readline()
67 local_verts
.append( Vector(x
,y
,z
) )
68 global_verts
.append( Vector(x
,y
,z
) )
71 for i_face
in range(0, Nfaces
):
72 line
= in_file
.readline()
75 Blender
.Draw
.PupMenu('Error%t|File format error 4')
77 Nverts_in_face
= int(words
[0])
78 if len(words
) != 1 + Nverts_in_face
:
79 Blender
.Draw
.PupMenu('Error%t|File format error 5')
82 for i_face_vert
in range(0, Nverts_in_face
):
83 idx
= int(words
[i_face_vert
+ 1]) - offset
84 face_verts
.append(idx
)
85 #print "face_verts=",face_verts
86 faces
.append(face_verts
)
88 #print "Adding object ",object_names[i_object]
89 BPyAddMesh
.add_mesh_simple(object_names
[i_object
], local_verts
, [], faces
)
95 Blender
.Window
.WaitCursor(0)
96 Blender
.Window
.RedrawAll()
98 Blender
.Window
.FileSelector(readEngrid
, "Import", Blender
.sys
.makename(ext
='.begc'))