|
[Sponsors] |
Blender Export to Engrid script for Blender 2.69? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 24, 2014, 13:37 |
Blender Export to Engrid script for Blender 2.69?
|
#1 |
Member
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12 |
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 |
|
June 25, 2014, 09:03 |
|
#2 |
Senior Member
Oliver Gloth
Join Date: Mar 2009
Location: Todtnau, Germany
Posts: 121
Rep Power: 17 |
Did you try to run the 2.6 scripts with Blender 2.69?
|
|
June 25, 2014, 09:32 |
|
#3 |
Member
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12 |
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 |
|
June 25, 2014, 09:35 |
|
#4 |
Member
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12 |
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] |
|
June 27, 2014, 09:16 |
|
#5 |
Member
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12 |
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),' 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$ g Last edited by wyldckat; July 1, 2014 at 16:00. Reason: Added [CODE][/CODE] |
|
July 1, 2014, 16:05 |
|
#6 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
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:
Bruno |
|
July 3, 2014, 05:51 |
|
#7 |
Senior Member
Oliver Gloth
Join Date: Mar 2009
Location: Todtnau, Germany
Posts: 121
Rep Power: 17 |
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 |
|
July 4, 2014, 08:40 |
|
#8 |
Member
Gowain
Join Date: May 2014
Location: Ireland
Posts: 86
Rep Power: 12 |
Thanks so much guys
It's sorted now. |
|
August 29, 2014, 20:15 |
|
#9 |
Senior Member
|
I changed the blender export script as the one posted above gives me following errors:
Code:
mesh object has no attribute faces 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() |
|
April 21, 2015, 05:54 |
|
#10 |
Senior Member
Join Date: Mar 2015
Posts: 250
Rep Power: 12 |
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? |
|
April 21, 2015, 08:45 |
|
#11 |
Senior Member
Join Date: Mar 2015
Posts: 250
Rep Power: 12 |
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.
|
|
July 29, 2019, 14:52 |
Blender Export to Engrid script for Blender 2 69
|
#12 |
New Member
|
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 |
|
April 23, 2020, 05:37 |
|
#13 |
Member
Simon
Join Date: Sep 2019
Location: Germany
Posts: 51
Rep Power: 7 |
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. |
|
|
|
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 |