CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (http://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   Blender export script for named ASCII STLbs (http://www.cfd-online.com/Forums/openfoam-meshing/61601-blender-export-script-named-ascii-stlbs.html)

andersking July 28, 2008 00:18

Hi All, I have written an
 
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.

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif stlasciiexport.py

Regards,
Andrew

andersking August 4, 2008 01:38

Bug fix. Original script doesn
 
Bug fix. Original script doesn't incorrectly exports local coordinates. Revised version attached.

Regards,
Andrew

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif stlasciiexport.py

johndeas August 7, 2008 08:52

On a simple object (the cube p
 
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)

andersking August 7, 2008 20:48

You are right, new version is
 
You are right, new version is attached.

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif 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

johndeas August 8, 2008 06:03

It works now, thanks !
 
It works now, thanks !

hsieh August 8, 2008 18:59

Hi, Andrew, I understand th
 
Hi, Andrew,

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

Pei

terrybarnaby November 26, 2008 17:23

Thanks for the script, it almo
 
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 ?

andersking November 26, 2008 22:12

Hi Terry, You should be abl
 
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

andersking November 26, 2008 22:19

Pei, I don't know if there'
 
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.

http://www.cfd-online.com/OpenFOAM_D...es/1/10142.jpg

Andrew

dmoroian November 27, 2008 04:51

Hi Andrew, I think Pei ment i
 
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

andersking November 27, 2008 23:46

Hi, Don't usually do requests
 
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

andersking November 28, 2008 00:07

Hi, Don't usually do requests
 
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

andersking November 28, 2008 00:08

Please disregard the double po
 
Please disregard the double post. I thought the first got cancelled.

Andrew

braennstroem July 26, 2009 06:08

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

andersking July 29, 2009 22:51

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 September 21, 2009 12:16

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 (Post 224644)
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


jkatrib January 25, 2011 15:39

Hi andrew,
could you please repost the link as is not working anymore,
Regards,

Juliano

andersking February 23, 2011 21:55

Repost.
 
1 Attachment(s)
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

wikstrom March 19, 2012 05:19

Similar export, for blender 2.5
 
1 Attachment(s)
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

wyldckat April 14, 2012 11:02

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


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