CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Mesh Generation & Pre-Processing Software > enGrid

Blender Export to Engrid script for Blender 2.69?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By wyldckat
  • 1 Post By student666

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 24, 2014, 13:37
Default Blender Export to Engrid script for Blender 2.69?
  #1
Member
 
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12
eaglemckenna is on a distinguished road
Hi
Is there an updated export .begc to Engrid script for Blender 2.69 available?
I can only locate ones for 2.6?
kind regards
g
eaglemckenna is offline   Reply With Quote

Old   June 25, 2014, 09:03
Default
  #2
Senior Member
 
Oliver Gloth
Join Date: Mar 2009
Location: Todtnau, Germany
Posts: 121
Rep Power: 17
ogloth is on a distinguished road
Did you try to run the 2.6 scripts with Blender 2.69?
ogloth is offline   Reply With Quote

Old   June 25, 2014, 09:32
Default
  #3
Member
 
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12
eaglemckenna is on a distinguished road
Hi there,
yes I have tried to run the script for 2.6 entitled io_export_engrid.py
see below for terminal error messages:
gowain@gowain-Aspire-V5-122P:/usr/share/blender/scripts$ ./io_export_engrid.py
./io_export_engrid.py: line 19: bl_info: command not found
./io_export_engrid.py: line 20: name:: command not found
./io_export_engrid.py: line 21: author:: command not found
./io_export_engrid.py: line 22: syntax error near unexpected token `0,'
./io_export_engrid.py: line 22: ` "version": (0, 2),'
gowain@gowain-Aspire-V5-122P:/usr/share/blender/scripts$

is there any other modelling software that can be used that is integrated with engrid and openfoam?

hopefully I will get the blender 2.69 export sorted soon.

kind regards
g
eaglemckenna is offline   Reply With Quote

Old   June 25, 2014, 09:35
Default
  #4
Member
 
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12
eaglemckenna is on a distinguished road
the cat io_export_engrid.py command:
Code:
gowain@gowain-Aspire-V5-122P:/usr/share/blender/scripts$ cat io_export_engrid.py 
# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program 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 2
#  of the License, or (at your option) any later version.
#
#  This program 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 this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

bl_info = {
    "name": "Export to enGrid (.begc)",
    "author": "Unknown Author",
    "version": (0, 2),
    "blender": (2, 5, 9),
    "api": 36079,
    "location": "File > Export > enGrid (.begc)",
    "description": "Export objects as boundaries to enGrid's Blender exchange format (*.begc)",
    "warning": "",
    "wiki_url": "http://engits.eu/wiki",
    "tracker_url": "http://sourceforge.net/apps/mantisbt/engrid",
    "category": "Import-Export"}

'''
Usage Notes:
'''

import bpy
from bpy.props import *
import mathutils, math, struct
from os import remove
import time
from bpy_extras.io_utils import ExportHelper


def do_export(context, props, filepath):
    mat_x90 = mathutils.Matrix.Rotation(-math.pi/2, 4, 'X')

    obmnames=""
    obmcount=0
    for obj in bpy.data.objects:
        if obj.type == 'MESH':
            obmcount+=1
            obmnames+=obj.name+'\n'
    
    if obmcount!=0:
        node_offset = 0
        out = open(filepath, "w")
        out.write('%d' % obmcount)
        out.write('\n')
        out.write(obmnames)
        
        for obj in bpy.data.objects:
            if obj.type == 'MESH':
                mesh = obj.to_mesh(context.scene, props.apply_modifiers, 'PREVIEW')
                if props.world_space:
                    mesh.transform(obj.matrix_world)
                if props.rot_x90:
                    mesh.transform(mat_x90)
                faces = mesh.faces
                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:
                    out.write("%d" % len(f.vertices))
                    for v in f.vertices:
                        out.write(' %d' % (v + node_offset))
                    out.write('\n')
                node_offset = node_offset + len(nodes)
        out.flush()
        out.close()
    return True


###### EXPORT OPERATOR #######
class Export_engrid(bpy.types.Operator, ExportHelper):
    bl_idname = "export_shape.engrid"
    bl_label = "Export enGrid (.begc)"
    filepath = "untitled"
    filename_ext = ".begc"


    rot_x90 = BoolProperty(name="Convert to Y-up",
            description="Rotate 90 degrees around X to convert to y-up",
            default=False,
            )
    world_space = BoolProperty(name="Export into Worldspace",
            description="Transform the Vertexcoordinates into Worldspace",
            default=True,
            )
    apply_modifiers = BoolProperty(name="Apply Modifiers",
            description="Applies the Modifiers",
            default=True,
            )

    @classmethod
    def poll(cls, context):
        return context.active_object.type in {'MESH', 'CURVE', 'SURFACE', 'FONT'}

    def execute(self, context):
        start_time = time.time()
        print('\n_____START_____')
        print(self.filepath)
        props = self.properties
        filepath = self.filepath
        filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
        print(self.filepath)
        exported = do_export(context, props, filepath)

        if exported:
            print('finished export in %s seconds' %((time.time() - start_time)))
            print(filepath)

        return {'FINISHED'}

    def invoke(self, context, event):
        wm = context.window_manager

        if True:
            # File selector
            wm.fileselect_add(self) # will run self.execute()
            return {'RUNNING_MODAL'}
        elif True:
            # search the enum
            wm.invoke_search_popup(self)
            return {'RUNNING_MODAL'}
        elif False:
            # Redo popup
            return wm.invoke_props_popup(self, event)
        elif False:
            return self.execute(context)


### REGISTER ###

def menu_func(self, context):
    self.layout.operator(Export_engrid.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()

Last edited by wyldckat; July 1, 2014 at 15:58. Reason: Added [CODE][/CODE]
eaglemckenna is offline   Reply With Quote

Old   June 27, 2014, 09:16
Default
  #5
Member
 
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12
eaglemckenna is on a distinguished road
Hi
I installed the blender 2.63a version and ran the script for blender 2.63a for engrid export within the following scripts directory and received the following error.
I am sure it is something simple I am not doing right and would be most grateful for your help. thanks
Code:
gowain@gowain-Aspire-V5-122P:~/Blender 2.63a/blender-2.63a-linux-glibc27-x86_64/2.63/scripts$ ./io_export_engrid.py 
./io_export_engrid.py: line 19: bl_info: command not found
./io_export_engrid.py: line 20: name:: command not found
./io_export_engrid.py: line 21: author:: command not found
./io_export_engrid.py: line 22: syntax error near unexpected token `1,'
./io_export_engrid.py: line 22: `    "version": (1, 1),'
then i tried python command and it states there is no bpy module:

Code:
gowain@gowain-Aspire-V5-122P:~/Blender 2.63a/blender-2.63a-linux-glibc27-x86_64/2.63/scripts$ python io_export_engrid.py 
Traceback (most recent call last):
  File "io_export_engrid.py", line 35, in <module>
    import bpy
ImportError: No module named bpy
gowain@gowain-Aspire-V5-122P:~/Blender 2.63a/blender-2.63a-linux-glibc27-x86_64/2.63/scripts$
apologies once again
g

Last edited by wyldckat; July 1, 2014 at 16:00. Reason: Added [CODE][/CODE]
eaglemckenna is offline   Reply With Quote

Old   July 1, 2014, 16:05
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

@Gowain: Uhm... you're not meant to run the scripts from the command line. You're meant to install them in Blender and then use them in Blender:
Best regards,
Bruno
elvis likes this.
wyldckat is offline   Reply With Quote

Old   July 3, 2014, 05:51
Default
  #7
Senior Member
 
Oliver Gloth
Join Date: Mar 2009
Location: Todtnau, Germany
Posts: 121
Rep Power: 17
ogloth is on a distinguished road
Hello,

I just tried the scripts with Blender 2.7 and it worked without problem, so I assume that 2.69 will be fine too.

Regards,
Oliver
ogloth is offline   Reply With Quote

Old   July 4, 2014, 08:40
Default
  #8
Member
 
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12
eaglemckenna is on a distinguished road
Thanks so much guys
It's sorted now.
eaglemckenna is offline   Reply With Quote

Old   August 29, 2014, 20:15
Default
  #9
Senior Member
 
M. C.
Join Date: May 2013
Location: Italy
Posts: 286
Blog Entries: 6
Rep Power: 17
student666 is on a distinguished road
I changed the blender export script as the one posted above gives me following errors:

Code:
mesh object has no attribute faces
I changed ti according to http://blenderartists.org/forum/show...ute-Faces-quot

Code:
# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program 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 2
#  of the License, or (at your option) any later version.
#
#  This program 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 this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

bl_info = {
    "name": "Export to enGrid (.begc)",
    "author": "Unknown Author",
    "version": (0, 2),
    "blender": (2, 5, 9),
    "api": 36079,
    "location": "File > Export > enGrid (.begc)",
    "description": "Export objects as boundaries to enGrid's Blender exchange format (*.begc)",
    "warning": "",
    "wiki_url": "http://engits.eu/wiki",
    "tracker_url": "http://sourceforge.net/apps/mantisbt/engrid",
    "category": "Import-Export"}

'''
Usage Notes:
'''

import bpy
from bpy.props import *
import mathutils, math, struct
from os import remove
import time
from bpy_extras.io_utils import ExportHelper


def do_export(context, props, filepath):
    mat_x90 = mathutils.Matrix.Rotation(-math.pi/2, 4, 'X')

    obmnames=""
    obmcount=0
    for obj in bpy.data.objects:
        if obj.type == 'MESH':
            obmcount+=1
            obmnames+=obj.name+'\n'
    
    if obmcount!=0:
        node_offset = 0
        out = open(filepath, "w")
        out.write('%d' % obmcount)
        out.write('\n')
        out.write(obmnames)
        
        for obj in bpy.data.objects:
            if obj.type == 'MESH':
                mesh = obj.to_mesh(context.scene, props.apply_modifiers, 'PREVIEW')
                if props.world_space:
                    mesh.transform(obj.matrix_world)
                if props.rot_x90:
                    mesh.transform(mat_x90)
                polygons = mesh.polygons
                nodes = mesh.vertices
                out.write('%d' % len(nodes))
                out.write(' %d\n' % len(polygons))
                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 polygons:
                    out.write("%d" % len(f.vertices))
                    for v in f.vertices:
                        out.write(' %d' % (v + node_offset))
                    out.write('\n')
                node_offset = node_offset + len(nodes)
        out.flush()
        out.close()
    return True


###### EXPORT OPERATOR #######
class Export_engrid(bpy.types.Operator, ExportHelper):
    bl_idname = "export_shape.engrid"
    bl_label = "Export enGrid (.begc)"
    filepath = "untitled"
    filename_ext = ".begc"


    rot_x90 = BoolProperty(name="Convert to Y-up",
            description="Rotate 90 degrees around X to convert to y-up",
            default=False,
            )
    world_space = BoolProperty(name="Export into Worldspace",
            description="Transform the Vertexcoordinates into Worldspace",
            default=True,
            )
    apply_modifiers = BoolProperty(name="Apply Modifiers",
            description="Applies the Modifiers",
            default=True,
            )

    @classmethod
    def poll(cls, context):
        return context.active_object.type in {'MESH', 'CURVE', 'SURFACE', 'FONT'}

    def execute(self, context):
        start_time = time.time()
        print('\n_____START_____')
        print(self.filepath)
        props = self.properties
        filepath = self.filepath
        filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
        print(self.filepath)
        exported = do_export(context, props, filepath)

        if exported:
            print('finished export in %s seconds' %((time.time() - start_time)))
            print(filepath)

        return {'FINISHED'}

    def invoke(self, context, event):
        wm = context.window_manager

        if True:
            # File selector
            wm.fileselect_add(self) # will run self.execute()
            return {'RUNNING_MODAL'}
        elif True:
            # search the enum
            wm.invoke_search_popup(self)
            return {'RUNNING_MODAL'}
        elif False:
            # Redo popup
            return wm.invoke_props_popup(self, event)
        elif False:
            return self.execute(context)


### REGISTER ###

def menu_func(self, context):
    self.layout.operator(Export_engrid.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()
hope this can help
wyldckat likes this.
student666 is offline   Reply With Quote

Old   April 21, 2015, 05:54
Default
  #10
Senior Member
 
Join Date: Mar 2015
Posts: 250
Rep Power: 12
KateEisenhower is on a distinguished road
Hello,

I try to use the export script 2.63a io_export_engrid.py version from sourceforge with Blender 2.74 on OS X. As intended I put the script in the Contents/Resources/2.74/scripts folder. However in the File/export menu I can't see any export to enGrid option.
Has anyone experienced the same. Is it generally just supposed to work with the Linux version of Blender?
KateEisenhower is offline   Reply With Quote

Old   April 21, 2015, 08:45
Default
  #11
Senior Member
 
Join Date: Mar 2015
Posts: 250
Rep Power: 12
KateEisenhower is on a distinguished road
Okay, I got it. You have to put the the import and export script inside the Contents/Resources/2.74/scripts/addons folder. After that go to File/User Preferences in blender, search for the scripta and activate them.
KateEisenhower is offline   Reply With Quote

Old   July 29, 2019, 14:52
Default Blender Export to Engrid script for Blender 2 69
  #12
New Member
 
Davidkep
Join Date: Jul 2019
Location: Burkina Faso
Posts: 2
Rep Power: 0
Davidkep is on a distinguished road
Send a message via ICQ to Davidkep Send a message via AIM to Davidkep Send a message via Yahoo to Davidkep Send a message via Skype™ to Davidkep
Hi guys

i dont have much info about scripting, I have this script for zbrush import/export, its for windows and Im using Mac osx, i tried to use it on Mac but apparently only "Obj out"export works fine but the "Obj in"import Dosent work, can anyone help me to rewrite this script for Mac ? i tried it on windows and it worked fine.btw i tried to fix it by changing the location of the folder to match Mac path

Copy the 2 files into your Zplusg64, and the two button will show on your right button on you zbrush screen.

Thanks in advance
Davidkep is offline   Reply With Quote

Old   April 23, 2020, 05:37
Default
  #13
Member
 
SimonStar's Avatar
 
Simon
Join Date: Sep 2019
Location: Germany
Posts: 51
Rep Power: 7
SimonStar is on a distinguished road
Hello,

is there somewhere a guide how to put a script into blender? Or how did you do that exactly?

I'm still in the beginning with trying to understad OpenFoam and the meshinge, so I guess I need mone help.

Tanks for any help.
SimonStar is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[CAD formats] Blender export script for named ASCII STLbs andersking OpenFOAM Meshing & Mesh Conversion 26 April 22, 2023 17:46
Unable to install OpenFOAM 1.6-ext Maimouna OpenFOAM Installation 23 May 8, 2014 06:47
FYI: SwiftSnap now can also export on Blender to enGrid wyldckat enGrid 0 October 6, 2013 11:35
enGrid to OpenFOAM full export issues coanda enGrid 1 May 4, 2013 10:31
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08


All times are GMT -4. The time now is 18:55.