CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[CAD formats] Blender export script for named ASCII STLbs

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 28, 2008, 00:18
Default Blender export script for named ASCII STLbs
  #1
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
Hi All,

I have written an export script for blender, which exports selected objects (with names) to an ASCII STL file. This should be all you need to get a suitable stl for using in snappyHexMesh.

Improvements/bug fixes (hopefully none) are welcome. Requests for improvements not so much (I don't have time).

To use the script, save it in ~/.blender/scripts. It should then give you a menu item in File->Export->Named ascii STL file...
You can give your blender objects useful names and these will be kept in the exported stl. These can be used for creating patches in snappyHexMesh.

stlasciiexport.py

Regards,
Andrew
romant, Mariusz and ashishmagar600 like this.
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   August 4, 2008, 01:38
Default Bug fix. Original script doesn
  #2
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
Bug fix. Original script doesn't incorrectly exports local coordinates. Revised version attached.

Regards,
Andrew

stlasciiexport.py
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   August 7, 2008, 08:52
Default On a simple object (the cube p
  #3
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
On a simple object (the cube present in the default Blender scene), I got this error message:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/share/blender/scripts/bpymodules/BPyRegistry.py", line 53, in <module>
_CFG_DIR = Blender.sys.join(Blender.Get('datadir'), 'config')
TypeError: expected string argument
Traceback (most recent call last):
File "<string>", line 88, in <module>
File "<string>", line 70, in update_RegistryInfo
NameError: global name 'SKIP_DATA' is not defined

Do you why I got this, or what are the steps involved to export this simple case with your script ?

(if needed, I run Blender 2.45 with Ubuntu 08-04 and Python 2.5.2)
johndeas is offline   Reply With Quote

Old   August 7, 2008, 20:48
Default You are right, new version is
  #4
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
You are right, new version is attached.

stlasciiexport.py

To use it, all you have to do is put each patch in a separately named object. Select all the patches you wish to export and then use the script.

snappyHexMesh will then recognise the names in the regions section of snappyHexMeshDict.

Cheers,
Andrew
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   August 8, 2008, 06:03
Default It works now, thanks !
  #5
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
It works now, thanks !
johndeas is offline   Reply With Quote

Old   August 8, 2008, 18:59
Default Hi, Andrew, I understand th
  #6
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 317
Rep Power: 18
hsieh is on a distinguished road
Hi, Andrew,

I understand that you are busy. But, is it possible to write a quick tutorial? Thanks!

Pei
hsieh is offline   Reply With Quote

Old   November 26, 2008, 17:23
Default Thanks for the script, it almo
  #7
Member
 
Terry Barnaby
Join Date: Mar 2009
Location: Beam Ltd, UK
Posts: 44
Rep Power: 17
terrybarnaby is on a distinguished road
Thanks for the script, it almost does what I need. However, there is a problem using this script when you have a mesh that is modified by a curve. The script outputs the the mesh without the curve modification. Does anyone now how to fix this ?
terrybarnaby is offline   Reply With Quote

Old   November 26, 2008, 22:12
Default Hi Terry, You should be abl
  #8
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
Hi Terry,

You should be able to apply the modifier, and then export the modified object using the script. I'm not sure if its possible to include this step in the script though.

Andrew
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   November 26, 2008, 22:19
Default Pei, I don't know if there'
  #9
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
Pei,

I don't know if there's much to put in the tutorial.
All you need to do is name each object (as in the image below), select the objects you wish to export, and then run the script. The object names are then exported in the STL and can be referred to in snappyHexMesh.



Andrew
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   November 27, 2008, 04:51
Default Hi Andrew, I think Pei ment i
  #10
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hi Andrew,
I think Pei ment if you can show how step by step the procedure of generating a surface, mesh it and then export it in stl format. I know that at least for me it will be very, very, very helpful.
I did only the "person" tutorial in blender until know, and that was quite a long time ago.
...maybe put it on the wiki...

Thanks,
Dragos
dmoroian is offline   Reply With Quote

Old   November 27, 2008, 23:46
Default Hi, Don't usually do requests
  #11
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
Hi,
Don't usually do requests, but here you go. A quick and nasty Blender tutorial. Note that I haven't done a snappyHexMesh part. (Maybe later).
I have an odt of it if anyone wants to add it to the wiki.



Regards,
Andrew
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   November 28, 2008, 00:07
Default Hi, Don't usually do requests
  #12
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
Hi,
Don't usually do requests, but here you go. A quick and nasty Blender tutorial. Note that I haven't done a snappyHexMesh part. (Maybe later).

It turns out it was too big for here, so I've added it to the wiki (It turns out the wiki is surprisingly easy to edit).
It's at http://openfoamwiki.net/index.php/Main_Tutorials

Feel free to move it if its in the wrong place.

Regards,
Andrew
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   November 28, 2008, 00:08
Default Please disregard the double po
  #13
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
Please disregard the double post. I thought the first got cancelled.

Andrew
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   July 26, 2009, 06:08
Default
  #14
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
Hi Andrew,
do you know, if I am able to define some patches in blender based on any angle similar like in Starccm+; e.g. I would like to select an triangle and all its neighbors as long as some feature angle is not exceeded!? Would be nice, if this works :-) In addition, is it possible to cut the geometry triangle with a plane or a region?
Would be nice, if you have a suggestion!
Regards!
Fabian
braennstroem is offline   Reply With Quote

Old   July 29, 2009, 22:51
Default
  #15
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
Hi Fabian,

You can select sharp edges with 'CTRL-ALT-SHIFT S', which allows you to select the angle. Once you've selected the edge of the patch you want to separate, press 'V', which splits it along the edge. If you want to completely separate it (so you can give it a name), you can press 'P'.

Hope that helps.

Cheers,
Andrew
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   September 21, 2009, 12:16
Default
  #16
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
Hi Andrew,

sorry for the late reply ... thanks a lot! It still takes a bit, but quite nice tool ;-)

Fabian

Quote:
Originally Posted by andersking View Post
Hi Fabian,

You can select sharp edges with 'CTRL-ALT-SHIFT S', which allows you to select the angle. Once you've selected the edge of the patch you want to separate, press 'V', which splits it along the edge. If you want to completely separate it (so you can give it a name), you can press 'P'.

Hope that helps.

Cheers,
Andrew
braennstroem is offline   Reply With Quote

Old   January 25, 2011, 15:39
Default
  #17
New Member
 
Juliano
Join Date: Jan 2011
Posts: 1
Rep Power: 0
jkatrib is on a distinguished road
Hi andrew,
could you please repost the link as is not working anymore,
Regards,

Juliano
jkatrib is offline   Reply With Quote

Old   February 23, 2011, 21:55
Default Repost.
  #18
Member
 
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17
andersking is on a distinguished road
Hi

I've had a number of requests, so here is a repost of the script.

Note that this does not work in the newest versions of blender (2.5x). We are in the process of updating it for this version, but it's not quite ready yet.

Install instructions etc. are as before. (but you'll have to gunzip the file, as a .py extension is not allowed on the forums).

Regards,
Andrew
Attached Files
File Type: gz stlasciiexport.py.gz (2.5 KB, 144 views)
__________________
Dr Andrew King
Fluid Dynamics Research Group
Curtin University
andersking is offline   Reply With Quote

Old   March 19, 2012, 04:19
Default Similar export, for blender 2.5
  #19
Member
 
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17
wikstrom is on a distinguished road
Hi,

I have extended the "default" STL import/export addon to include the option to export multi-solid ascii STL, similar to the above script. Still crude and I hope to extend the import functionality similarly, but have not don so yet.

I have tested this with blender 2.5.8. To activate this addon unpack the tgz in ~/.blender/<version>/
Code:
 ~/.blender/2.58/scripts
niklasw > tree
.
└── addons
    └── export_named_stl
        ├── blender_utils.py
        ├── __init__.py
        └── stl_utils.py
Then activate the addon in the blender user preferences.

/Niklas
Attached Files
File Type: gz export_named_stl.tar.gz (4.9 KB, 153 views)
romant and MatejP like this.
wikstrom is offline   Reply With Quote

Old   April 14, 2012, 11:02
Default
  #20
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
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!

I stumbled on this thread a few days ago and when I saw the wiki page + old scripts, I thought to myself "this is a good one for passing PDF to wiki". And that's what I've done: http://openfoamwiki.net/index.php/Tut_andrew_blender

I hope the original author Andrew King doesn't mind that his document was converted/transcribed to wiki format, because my objective was for enabling inspired people to complement this very good article!

I've also put the what I believe is the latest script for Blender <=2.49b on the wiki page and only a reference to the script by Niklas Wikstrom. So Niklas, if you feel like it, feel free to upload to and/or edit the wiki page as well

Best regards,
Bruno
lovecraft22 likes this.
__________________

Last edited by wyldckat; April 14, 2012 at 14:36. Reason: "transcribed", not quite exactly converted...
wyldckat 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
Automatic Data Export (ascii format) A Kourm FLUENT 4 March 7, 2021 15:08
[ANSYS Meshing] Export mesh as fluent msh by using script erkut ANSYS Meshing & Geometry 0 July 13, 2018 16:41
export ascii file with fluent Clementine FLUENT 3 August 2, 2012 10:52
WSS ASCII export problem Birkov FLUENT 1 July 27, 2009 15:09
Is there any way to quickly export ascii file? HVAC FLUENT 0 December 29, 2005 21:24


All times are GMT -4. The time now is 01:17.