# 3D model skp to fbd exporter

**URL:** <https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746>\
**Category:** Uncategorized\
**Created:** [August 2, 2023, 12:05am UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746 "2023-08-02T00:05:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 2, 2023, 12:05am UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/1 "2023-08-02T00:05:24Z")

</div>

hi all,

currently i’m in starting makes a script for [SketchUp](https://en.wikipedia.org/wiki/SketchUp) 3D model to be capable exporting CalculiX CGX fbd format. it’s a modified version taken form another codes, Google SketchUp 8 is intiutive and known working welll in Linux trough Wine.

an interesting to know and implemented or improvement (maybe) are:

- preset for automeshing of tetrahedral element
- translate arc and circle object
- color indek to define surface boundary condition and contact
- material indek for a part
- partition (surface inside a body) to generates structured hexahedral element
- etc

i’ll post the codes at GitHub after minor fix and try to continue as possible, please comment or p.m if someone interest to contrributed also

best regards,

below screenshot of progress:

 ![2023-08-02 06_17_50-3 - SketchUp](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/1/164240967fdab63ec8df53d77e0dc54fe178ee5c.png)

 ![2023-08-02 06_24_34-skp2fbd_rev.rb - SciTE](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/e/ecc46b457ab00823465505fdc932d1de2692aece.png)

 ![2023-08-02 06_24_45-3exp.fbd - SciTE](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/a/aa435b3eaaba64148eba316b90221962b8df731b.png)

 ![2023-08-02 06_16_34-CalculiX GraphiX](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/f/fc26ec839aee996b16b1b80c7b268976df6e280c.png)

 ![2023-08-02 06_16_07-CalculiX GraphiX](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/2/284811684a2b317ee13b73cfb06daeeb7b36eab1.png)

 ![2023-08-02 06_17_09-CalculiX GraphiX](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/7/7817648fd2b077222620cb5f60bd9f8466174081.png)

 ![2023-08-02 06_55_14-CalculiX GraphiX](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/f/f047eea4e0e31deb0ff097789933f6f9092b77d5.png)

---

<div class="post-metadata">

**Author:** ![rsmith](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/rsmith/32/1684_2.png) [@rsmith](https://calculix.discourse.group/u/rsmith)\
**Post date:** [August 3, 2023, 3:29pm UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/3 "2023-08-03T15:29:52Z")

</div>

It is interesting to see. I’ve also been thinking about a way to e.g. translate STEP files to FBD. _Preferably in a way that would generate a halfway decent hex mesh!_

But that seems far from a trivial problem. As I understand it, it is much easier to fill an arbitrary geometry with tet element than with hex elements.  
I’ve tried creating hex meshes in arbitrary geometry in FreeCAD (which uses `gmsh`) but more often than not I run into problems even for simple geometry.

Would the geometry that you show work with `cgx`’s hex mesher as-is?  
I would probably divide it up in parts that can be handled with the built-in hex mesher. Something like this:

 ![points](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/1/1252315707ef2e19c65d13078701b252b098cfc3.png)  
So it can be meshed with `he20r`.  
 ![elements](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/4/4b5f1f254d941749cf57ce483b45afa342135b72.png)  
So far so good.

But what would happen if for example the geometry had a hole drilled trough it? Or if the parts had more than five edges? That would make the conversion much more tricky.  
The geometry would have to be divided into meshable bodies. There will probably more than one way to do that and it might not be obvious if one way is “better”.

For practically all of the analysis that I’ve done, I have created (defeatured) geometry in `cgx` because I want a good quality paramatric mesh.

---

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 3, 2023, 4:33pm UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/4 "2023-08-03T16:33:51Z")

</div>

thank you for interesting.

> [@rsmith](#):
>
> I’ve also been thinking about a way to e.g. translate STEP files to FBD.

actually it was available as cgxCadTools, but my experiences shown not run out of the box. it’s dependency [problem](https://calculix.discourse.group/t/cgxcadtools-windows-executable/171) on Windows. so, i can not testing is the tool deal with partition properly.

> [@rsmith](#):
>
> I’ve tried creating hex meshes in arbitrary geometry in FreeCAD (which uses `gmsh`) but more often than not I run into problems even for simple geometry.

it seems to be better when partition and meshing are done inside GMSH, also hex-dominant meshing algorithm can be use as alternative.

 ![2023-03-05 04_18_17-Gmsh - C__Users_user_Documents_hexdom.geo](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/d/d9a5bcb9d199a1b1e827e40178bf2eb8bdb43d4a.png)

> [@rsmith](#):
>
> Would the geometry that you show work with `cgx`’s hex mesher as-is?  
> I would probably divide it up in parts that can be handled with the built-in hex mesher. Something like this:

SketchUp is intituitive 3D modeler, any partiotion as you shown can be easely drawn.

 ![2023-08-04 00_10_53-3rx - SketchUp](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/0/0064db5501e3ae5919247dc01149b605a08e475b.png)

> [@rsmith](#):
>
> But what would happen if for example the geometry had a hole drilled trough it? Or if the parts had more than five edges? That would make the conversion much more tricky.

even five edges definition for structured quad/hex is capable in CGX, still prefer to keep using four edges only. this make result mesh less distorted.

the exporter seems capable for these case, user still need to trace if the problem occurs. but the CGX is a pre-processor itself, many command can be costumized or modified by the user.

the reason why, i starting makes this exporter. the capabilities and feature of CGX can be use further.

---

<div class="post-metadata">

**Author:** ![klaus.wittig](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@klaus.wittig](https://calculix.discourse.group/u/klaus.wittig)\
**Post date:** [August 4, 2023, 3:42pm UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/5 "2023-08-04T15:42:21Z")

</div>

To me it seems the tool could be a good choice if the creation of geometry (and partitioning) is easier and faster than in cgx itself (be aware of the automatic calculation of line divisions in cgx). I personally create models based on parameters and additional software or I get my geometry in step format from a designer. If it is a general arrangement in 2D I do the same as rsmith and defeature it and subdivide it in a way that i get 3-5 sided surfaces. Then I sweep it in 3D. Sometimes in several successive circumferential sections were I can delete some bodies to realize for example a bore in a disk or a rib in a shroud etc. Very often I combine this hex meshes with pure tet meshes which I also generate in cgx based on a step file. The converters work very well on linux for the models I have received so far (and probably on windows since Rafal provided them for the audience). Unfortunately the necessary libraries to use them have to be installed by the user to avoid potential licensing problems with them. This is probably one of the reasons why seemingly only few people have ever used cgx to create tet meshes (actually in cgx only the shell elements for the tetgen or netgen program are created, cgx sends the shells to the filesystem, starts the tetmesher and reads the tets). The next obstacle is of course that the user needs to know quite well cgx before he can successful manipulate the geometry (please regard the qmsh command). On the other hand working with the netgen gui allows just few manipulations. I fixed some bugs and added functioallity in cgx\_2.21, so please if you would give it a try please use this latest version.

---

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 4, 2023, 6:34pm UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/6 "2023-08-04T18:34:33Z")

</div>

indeed, using CAD as the base geometry and CGX dedicated pre-processor of CalculiX is good interactions. each part can be exported separately to modify if required then assembling of large parts.

regarding to modeling of 3D part in SketchUp is more like crafting and it;s not as advanced SpaceClaim but extension to export, partition and previously distributed by Google freely.

below an example of partition using model intersections, as can be seen line are generates in face of a part. separating them to makes of two bodies, later it can be merge the surfaces by CGX commands.

![2023-08-05 01_05_31-Untitled - SketchUp](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/d/dd4f770e5ee7c01a8ca9dd19bcc53f6e09c2e73f.png)

 ![2023-08-05 01_06_24-Untitled - SketchUp](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/2/26b8c12afcca3da80e29fdbfb4aa3df40373f804.png)

 ![2023-08-05 01_08_15-Untitled - SketchUp](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/e/efe043a049e2387dfef0749638fd775487283b94.png)

![2023-08-05 01_08_49-Untitled - SketchUp](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/6/6fb9046bcaf214a6775fb7e55da1f49c5b44d67a.png)

 ![2023-08-05 02_52_29-CalculiX GraphiX](https://global.discourse-cdn.com/free1/uploads/calculix/original/2X/7/7fc217c1d29d268e88cb0a826cc9531f816a42fd.png)

---

<div class="post-metadata">

**Author:** ![rsmith](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/rsmith/32/1684_2.png) [@rsmith](https://calculix.discourse.group/u/rsmith)\
**Post date:** [August 4, 2023, 10:30pm UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/7 "2023-08-04T22:30:31Z")

</div>

Klaus,

First I want to say “thank you” for writing `cgx`. It’s an amazing tool. There is a steep learning curve, but I guess that is unavoidable with FEA.  
The fact that it’s completely scriptable comes in very handy.

Yes, creating geometry takes longer than in say FreeCAD, but I get a model that I _know_ will mesh properly and I can make the model as fully parametric as I want. Given that I often use CalculiX to optimize fiber reinforced composites parts, making e.g. a laminate thickness a parameter is easily worth the effort. The first model takes longer, but after than making a variant can be as simple as making a copy and then a one-line edit in the preprocessor file.

> [@klaus.wittig](#):
>
> be aware of the automatic calculation of line divisions in cgx

Up to recently I alway set the line division manually to ensure a nice even mesh. 🙂 But now I’ve been playing with auto divisions, and I have to say it’s not too bad. But even in expensive FEA software like Abaqus you sometimes have to basically set line divisions yourself.

> [@klaus.wittig](#):
>
> seemingly only few people have ever used cgx to create tet meshes

Why would you create a tet mesh in the first place? Given that a hex mesh generally gives better results with fewer elements. That has been my experience, at least. With a tet-mesh I tend to see a “shadow” of the mesh in the stress results.

> [@klaus.wittig](#):
>
> The converters work very well on linux for the models I have received so far (and probably on windows since Rafal provided them for the audience). Unfortunately the necessary libraries to use them have to be installed by the user to avoid potential licensing problems with them.

Getting `cad2fbd` to compile on a UNIX-like system was not _that_ difficult. It basically needs OpenCascade and `libstdc++`. A lot of Linux distributions and BSD systems have those libraries available in their native package managers. If your platform doesn’t have a decent package manager (like ms-windows) then I suspect it will indeed be a PITA.

I used the following `Makefile` to build `cad2fbd` on FreeBSD. It should probably work on Linux as well, although you might have to update CFLAGS and LFLAGS with the actual directories on your system.

```auto
.PHONY: clean

CFLAGS= -I../inc -I/usr/local/include/OpenCASCADE -std=c++11
CXXFLAGS= $(CFLAGS)
LFLAGS= -L/usr/local/lib
LIBS = \
    -lTKBinL -lTKBin -lTKBinTObj -lTKBinXCAF -lTKBool -lTKBO -lTKBRep -lTKCAF \
    -lTKCDF -lTKDCAF -lTKDraw -lTKernel -lTKFeat -lTKFillet -lTKG2d -lTKG3d \
    -lTKGeomAlgo -lTKGeomBase -lTKHLR -lTKIGES -lTKLCAF -lTKMath -lTKMesh \
    -lTKMeshVS -lTKOffset -lTKOpenGl -lTKPrim -lTKQADraw -lTKService -lTKShHealing \
    -lTKStdL -lTKStd -lTKSTEP209 -lTKSTEPAttr -lTKSTEPBase -lTKSTEP \
    -lTKSTL -lTKTObjDRAW -lTKTObj -lTKTopAlgo -lTKTopTest -lTKV3d -lTKVCAF \
    -lTKViewerTest -lTKVRML -lTKXCAF -lTKXDEDRAW -lTKXDEIGES -lTKXDESTEP \
    -lTKXMesh -lTKXmlL -lTKXml -lTKXmlTObj -lTKXmlXCAF -lTKXSBase -lTKXSDRAW \
    -lstdc++ -lm

SRCS!= ls *.cpp
OBJS= $(SRCS:.cpp=.o)

cad2fbd: $(OBJS)
    $(CXX) -o cad2fbd $(OBJS) $(LFLAGS) $(LIBS)
    strip cad2fbd

clean::
    rm -f *.o cad2fbd

```

(For those of you not familiar with `make`, the empty space at the beginning of a line should be a `<tab>` character, not spaces.)  
This was written for BSD make but worked with GNU make as well.

Place this `Makefile` in `cgxCadTools/CadReader/src` and invoke `make`.

---

<div class="post-metadata">

**Author:** ![klaus.wittig](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@klaus.wittig](https://calculix.discourse.group/u/klaus.wittig)\
**Post date:** [August 5, 2023, 10:25am UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/8 "2023-08-05T10:25:56Z")

</div>

Roland,  
actually it did not come to my mind to look into the package manager (yast) to seach for open-cascade. You are right, it’s there! Regarding the tet meshes your statement that you see a shadow of the mesh describes the problem of localized accuracy very well but on the other hand they allow to keep all the details in the model which helps to avoid lengthly discussions and makes life easier (if you have the patience for the longer calculation and evaluation times). Critical regions can be meshed with hex and glued to the rest.

---

<div class="post-metadata">

**Author:** ![rsmith](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/rsmith/32/1684_2.png) [@rsmith](https://calculix.discourse.group/u/rsmith)\
**Post date:** [August 5, 2023, 9:15pm UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/9 "2023-08-05T21:15:54Z")

</div>

> [@klaus.wittig](#):
>
> actually it did not come to my mind to look into the package manager (yast) to seach for open-cascade. You are right, it’s there!

That makes things a lot simpler. On my system, OpenCascade depends on 50-odd other packages. Building that by hand without the build files provided by your distribution would be quite an adventure.

> [@klaus.wittig](#):
>
> other hand they allow to keep all the details in the model which helps to avoid lengthly discussions and makes life easier

Let’s just say that I’m not always wise enough to avoid those discussions. 😊

What I would like to know is, if you get e.g. geometry in STEP format, how do you partition it so that `cgx` can mesh the parts?

---

<div class="post-metadata">

**Author:** ![klaus.wittig](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@klaus.wittig](https://calculix.discourse.group/u/klaus.wittig)\
**Post date:** [August 6, 2023, 4:31pm UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/10 "2023-08-06T16:31:31Z")

</div>

Either I use the ‘split’ or the ‘qspl’ or just the ‘qdel’ command to reduce the step based geometry to the one I want to mesh with tets. Usually I use cgx based additional software to generate parameter controlled geometry (an fbd file) which is already configured to be meshed by hex or, if no parametric model is available and to create one would be uneconomical, I try to generate a hex meshable geometry in the painful way of subdividing the rest manually (using split or/and creating new lines and surfaces etc). Often it is possible to just use a 2D part of the geometry and sweep it in 3D. To be fair I also have to admit that I first judge if the geometry is suited for cgx. I do not use cgx in cases were a lot of very small surfaces might exist like in a cooled turbine blade with lots of bleed holes. In this cases I use commercial software or ask my younger colleagues for a helping hand 🙂

---

<div class="post-metadata">

**Author:** ![klaus.wittig](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@klaus.wittig](https://calculix.discourse.group/u/klaus.wittig)\
**Post date:** [August 6, 2023, 4:41pm UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/11 "2023-08-06T16:41:28Z")

</div>

I want to add that with cgx\_2.21 you can delete holes by placing all the related points or lines or surfaces of that hole in a set and ‘zap’ it. The surfaces through which the hole goes are redefined without them. Be aware that if not all parts of that hole in the surface are deleted in one step the surface can not be kept. And a hole must be inside a surface and not part of the outer lines.

---

<div class="post-metadata">

**Author:** ![xyont](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/xyont/32/3553_2.png) [@xyont](https://calculix.discourse.group/u/xyont)\
**Post date:** [August 6, 2023, 6:31pm UTC](https://calculix.discourse.group/t/3d-model-skp-to-fbd-exporter/1746/12 "2023-08-06T18:31:02Z")

</div>

i have been posted the modify version of codes at [GitHub](https://github.com/xyont/skp2fbd), however it’s only base of geometry. an arc or circle object in SketchUp still puzzling me.

to use the exporter, place the script at folder below and access through Plugins menu.

`C:\Program Files\Google\Google SketchUp 8\Plugins`

an example usage of solid and surface modeling is not yet documented, i’ll add later.
