FreeCAD exporter

(Yorivanhavre) #1

Hi all,

I think it would be nice to have a sketchfab exporter for FreeCAD! I had a quick look at the development guidelines and the blender exporter, it seems not very hard to adapt the blender script. FreeCAD can export its contents to a number of mesh formats, I think the exporter could propose some of them to the user to choose. I'll do some tests to see what works best (BTW, openinventor (.iv) format doesn't seem to work?).

So if I got it well, the exporter would need to do this:

  • offer a link for the user to click, to obtain an API token, then save that token for further use
  • allow the user to set a title, description and tags
  • allow to set/unset private mode (is there any kind of verification needed here?)
  • (freecad-specific): allow the user to choose objects to export, and the file format to save
  • save the selected objects to the specified format (obj + mtl, iv...will test what works well)
  • zip and upload the saved file, insert source tags (freecad)
  • display the url of the uploaded model

Anything else?



Hi Yorik,

Every user already has an API Token and you can provide a link: (you could also use OAuth2 login: )

Otherwise, yep, that's exactly right.

(Yorivanhavre) #3

Great! I have a first prototype working!

I uploaded a model with it, here:

The code is here: more specifically in this file:

Basically the idea is to bundle it within FreeCAD once it is fully working.

I still have minor issues:

1) the tags is a string that contains comma-separated tags. However it appears on sketchfab as one big tag (with the commas removed). Do I have to provide them in another way? Couldn't find out.

2) I used a https request with attribute verify=False, like it is done on the blender exporter. But then I get this error: /usr/lib/python2.7/dist-packages/urllib3/ InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See:
InsecureRequestWarning) . The solution seems rather complicated, the user has to install extra python packages, etc. It seems I could just disable that message too. Any insight on this?

3) .iv (openinventor) files don't seem to work on sketchfab? Small test here

And finally, a feature request... Any chance to get Sketchfab to support freecad files directly some day? That would be kind of cool :sunglasses: If the .iv format works, it is pretty easy to get a faithful mesh representation of a FreeCAD file from a script...

Please tell me what you think!


That's awesome, nice work!

0) I HIGHLY, insistently, recommend moving to API V3. This will be the publicly documented and maintained version moving forward. V1 and V2 are deprecated, but we have to maintain limited endpoints for legacy exporters.


1) Assuming V3, I believe it's an array of strings: ['bob', 'character', 'video-games']

2) I really don't know about this, can you try with V3?

3) Thanks for reporting this, we'll need to check on the .IV format ( cc @mrchlblng )

4) Looks like you have an Up-Axis mismatch? Is that something you can update on your end while exporting the file? If not, it should possible to pass an options object during the upload that includes orientation, but I don't have a code sample right now ( cc @tribble42 ). It should be similar to the /models/{UID} PATCH, but included in data payload of your POST

5) FreeCAD file support: That would definitely be cool, but I don't know much about the format (or .IV). Do you have some data on FreeCAD usage/audience?

(Yorivanhavre) #5

Great, thanks a lot for the analysis! I'll try to use the v3 (wasn't aware, I just copied the blender addon), at first sight it looks like there won't be much to change...

About the x/z orientation, OBJ format has indeed conventionally the Maya orientation (Z points to the person watching the screen instead of pointing towards the sky), we could of course produce an obj file with X rotated,but if there was an option to pass which would allow us to keep the model that way, that would be even better :grin:

In any case it's easy to do in the sketchfab interface too.

About support for freecad files, no hurry/worry, I was merely starting the discussion. We'll see how the matter evolves...

(Mrchlblng) #6

@yorivanhavre @james, the issue we typically have with CAD models is that they use surfaces and not meshes and we do not have a tessellator as we mainly target real-time "meshed" models.
The model fails because we do not parse its primitives so likely the surface vs mesh issue (I'm not familiar at all with the format so that's a quick analysis attempt also reading the iv content and seeing BRep primitives).

That being said, if you have a script that we could look at to improve things, that would really help!

(Yorivanhavre) #7

Thanks guys, the exporter is now using API v3 and patches OBJ models to have the Z axis pointing upwards. Everything seems to be working fine now!

So I think this is ready for inclusion in the FreeCAD source code...

About the .iv format, you are right @mrchlblng , looking at it now, it contains FreeCAD-specific nodes... I'll see if I can convert that to standard .iv.

EDIT got it working

(Yorivanhavre) #8

.iv exports actually gives very cool technical result!

(Mrchlblng) #9

@yorivanhavre this looks great indeed! Happy to know that our inventor support is not too bad. I don't expect it to be perfect either so if you have a bunch of "test samples", that would probably not hurt that we test processing those!

Two other things that come to mind:

  • do you know any way to add a metadata in iv that would tell the "authoring tool" (i.e. just a way to encode in the file the source)?
  • do you export correct units? if so we could probably see to use them as the VR unit


@yorivanhavre Nice work.

It would also be great if you could add a 'source': 'freecad' parameter to your POST.

(Yorivanhavre) #11

Thanks for the feedback @mrchlblng! I don't really have samples for now, because the iv format is rarely used by us outside FreeCAD. Internally in FreeCAD, it works like this: All the geometry is solid Brep geometry. The FreeCAD 3D view itself is an OpenInventor viewer (built with Coin3D). So in order to show the brep geometry on screen, each object outputs an openinventor mesh representation of itself. It is that representation that the sketchfab exporter uses to build the exported iv file.

So what comes to sketchfab is actually a pretty faithful representation of the FreeCAD 3D view, that's really interesting. I think actually the way sketchfab handles it is pretty good, even the lines are rendered, I'll test some more tech stuff later on, like dimensions, etc.

We need to test more, but if the freecad community embraces and starts using the exporter, we should get more soon. I'll tell everyone to report when an iv file gives problems.

About metadata & indicating the source, how does that work now? In API v1 there was a "source" keyword that you could provide. This doesn't seem to exist anymore in v3? The thing is, FreeCAD will allow to upload in several formats (obj, iv, dae, etc) depending on what the user prefers (obj will give better control over materials, while iv will give a more faithful representation of the freecad 3d view, etc). So what would be the best way to notify you guys that this was exported from FreeCAD?

(Yorivanhavre) #12

Oh allright... Just saw @james 's reply now. I'll reintroduce the source:freecad parameter. Thanks!

(Yorivanhavre) #13

About the units, In FreeCAD, everything internally is always in millimeters. So "unitless" formats (obj and iv) are always in millimeters. Formats that provide a unit (dae basically) will have the unit correctly set (IIRC our dae files are in meters, but this is indicated inside the dae file)

If there would be an API parameter to pass the unit, I could do that easily.

(Mrchlblng) #14

Thanks for the detailed feedback @yorivanhavre.

We actually separate the notion of exporter and the notion of authoring tool. The exporter metadata when the model is uploaded. However, if e.g. a user enables download for one of his FreeCAD model, if a user directly reupload the data, we will not know that it comes from FreeCAD. That's why we like to have some metadata embedded in the model file itself.
For OBJ exports, we parse the commented lines and look for the freecad token. DAE has a "native" getAuthoring_tool method that we call.
For iv, I'm not so sure. I did not find any specified metadata or if it's possible to add custom properties.

This would be nice to have but not mandatory (it's convenient especially if we tweak the processing pipeline at some point, to make sure users always have a consistent experience, even when not uploading from the exporter).

(Yorivanhavre) #15

We could do the same as obj, iv allows comments ( ) I could easily add a comment line like:

# Exported by FreeCAD v0.17.10473

Would that be ok?


Thanks for the source param. If you have a sample upload I'll double check it worked on our end.

This will allow us to add "Uploaded with FreeCAD" to the model pages and helps for internal tracking.

Are you adding the "freecad" tag (not source) also by default? We can do a customized tag page, see

(Yorivanhavre) #17

Hi guys,
the exporter now adds this line:
# Exported by FreeCAD v0.17 build10490 (Git)


Also yes, every model uploaded from freecad will have both the source:freecad attribute and a "freecad" tag (this cannot be changed by the user).

Yeah, would be great to have a customized freecad tag! If needed, the FreeCAD logo is at feel free to modify the colors if needed, to match your requirements. We don't have a version of the logo with the "FreeCAD" text next to it, if needed tell me and I'll make one.

Will the exporter also be listed on ? The exporter is now part of FreeCAD v0.17 (not yet released). I already wrote a documentation page:

I'll also write a modified version of the exporter for people running an older version of FreeCAD

If I can help any further with this, don't hesitate.



I will add:

Thanks for the link to the logo, that's perfect. Is this good for the tagline?

An open-source parametric 3D CAD modeler."

(Yorivanhavre) #20



Do you know when v0.17 is scheduled to be released?