Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

New Blender Exporter
  • Andid September 2012
    Hello, due to the fact that the Script I found did not work I rewrote it for Blender 2.6 with Addon registration.

    Here it is(unfortunately I dont know how to attach files):
    #
    # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    # + +
    # + This file is part of enGrid. +
    # + +
    # + Copyright 2008-2010 enGits GmbH +
    # + +
    # + enGrid is free software: you can redistribute it and/or modify +
    # + it under the terms of the GNU General Public License as published by +
    # + the Free Software Foundation, either version 3 of the License, or +
    # + (at your option) any later version. +
    # + +
    # + enGrid is distributed in the hope that it will be useful, +
    # + but WITHOUT ANY WARRANTY; without even the implied warranty of +
    # + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
    # + GNU General Public License for more details. +
    # + +
    # + You should have received a copy of the GNU General Public License +
    # + along with enGrid. If not, see <<a href="http://www.gnu.org/licenses/" target="_blank" rel="nofollow">http://www.gnu.org/licenses/>. +
    # + +
    # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #


    bl_info = {
    "name": "Engrid (*.begc)",
    "description": "Export to Engrid",
    "author": "Engit",
    "version": (1, 2),
    "blender": (2, 60, 0),
    "location": "File > Export > Engrid (*.begc) ",
    "warning": "", # used for warning icon and text in addons panel
    "wiki_url": "",
    "tracker_url": "",
    "category": "Import-Export"}


    import bpy
    from bpy.props import StringProperty

    def do_export(filename):
    if not filename.lower().endswith('.begc'):
    filename += '.begc'
    out = open(filename, "w")
    objects = bpy.context.selected_objects

    num_objects = 0
    for object in objects:
    if object.type == 'MESH':
    num_objects = num_objects + 1

    out.write('%d\n' % num_objects)
    node_offset = 0
    for object in objects:
    if object.type == 'MESH':
    out.write(object.name)
    out.write('\n')
    for object in objects:
    if object.type == 'MESH':
    mesh = object.data
    faces = mesh.polygons
    nodes = mesh.vertices
    out.write('%d' % len(nodes))
    out.write(' %d\n' % len(faces))
    for n in nodes:
    out.write("%e " % n.co[0])
    out.write("%e " % n.co[1])
    out.write("%e\n" % n.co[2])
    for f in faces:
    N = len(f.vertices)
    if N < 3 and N > 4:
    print('Error%t|Only triangles and quads allowed')
    return
    out.write("%d" % N)
    for v in f.vertices:
    out.write(' %d' % (v + node_offset))
    out.write('\n')
    node_offset = node_offset + len(nodes)

    class EngridExporter(bpy.types.Operator):
    """Export the selected Objects to Engrid"""
    bl_idname = "export.engrid"
    bl_label = "Export Engrid"

    filepath = StringProperty(subtype='FILE_PATH')


    def execute(self, context):
    #Append .x
    FilePath = bpy.path.ensure_ext(self.filepath, ".begc")

    do_export(FilePath)

    return {"FINISHED"}

    def invoke(self, context, event):
    if not self.filepath:
    self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".begc")
    WindowManager = context.window_manager
    WindowManager.fileselect_add(self)
    return {"RUNNING_MODAL"}

    ### REGISTER ###

    def menu_func(self, context):
    self.layout.operator(EngridExporter.bl_idname, text="Engrid (.begc)")


    def register():
    bpy.utils.register_module(__name__)

    bpy.types.INFO_MT_file_export.append(menu_func)


    def unregister():
    bpy.utils.unregister_module(__name__)

    bpy.types.INFO_MT_file_export.remove(menu_func)


    if __name__ == "__main__":
    register()

    Moritz
  • Oliver September 2012
    Hi,

    thanks for your effort. Did you encounter a problem with the scripts in the current master branch (see link below)?

    https://github.com/enGits/engrid/tree/master/src/blender_scripts/2.63a

    Cheers,
    Oliver
  • Andid September 2012
    Hi,
    Could you link this in the forum here
    http://engits.eu/vanilla/index.php?p=/discussion/96/installing-the-importexport-scripts-for-blender/p1
    or in the tutorial (my search did not bring up the src)
    http://engits.eu/wiki/index.php/Tutorials/Version1.2/Unstructured_Grids_for_OpenFOAM_With_Blender_and_enGrid
    Maybe the tutorial can be enhanced with a more general link.

    Anyway - thanks for your help. Could have asked before.

    Regards, Andid