X-Ryl669 / freecadWebExport

A example tutorial to export from FreeCAD assembly to a web page
MIT License
10 stars 3 forks source link

Is CAD Assistant necessary just to export gITF files ? #1

Closed luzpaz closed 3 years ago

luzpaz commented 3 years ago

Because there is a way to export via python using cqparts AKA cadquery parts : https://wiki.freecadweb.org/GITF#Exporting

luzpaz commented 3 years ago

Native support of gITF is also being discussed in https://forum.freecadweb.org/viewtopic.php?f=8&t=31680&p=449977#p449977

X-Ryl669 commented 3 years ago

Honestly, I've tried many of the gossip's solution. Obviously, if FreeCAD updated its OCC core to the latest version, it would be a 2 liners patch to export GLTF (replacing STEP by GLTF and it's done). But I've no idea how hard it would be for FreeCAD to update to OCC 7.5. I've tried cqparts, but I don't know what I did wrong, I couldn't get any successful export with it.

CAD Assistant is free (even if not open source), and it works out of the box.

luzpaz commented 3 years ago

@X-Ryl669 AFAIU FreeCAD is compatible with OCC 7.5

X-Ryl669 commented 3 years ago

Then this answer gives the required code to run the conversion. I've tried the 2nd code fragment and it works on OCCT's TCL console.

The interesting change is this:

TColStd_IndexedDataMapOfStringString aMetadata;
RWGltf_CafWriter aGltfWriter ("exported.glb", true);
// STEP reader translates into mm units by default
aGltfWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (0.001);
aGltfWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (RWMesh_CoordinateSystem_Zup);
if (!aGltfWriter.Perform (theXdeDoc, aMetadata, Handle(Message_ProgressIndicator)())) { // export error }

Unfortunately, I don't know how FreeCad's code is written and where to get the current XdeDocument instance, but as you see, it's not very hard to do once we have it.

luzpaz commented 3 years ago

Good news! wmayer implemented gITF support in https://github.com/FreeCAD/FreeCAD/commit/74b866ed3

stillpointx commented 3 years ago

Getting error "gITF support requires OCCT 7.5.0 or later" looks like the Appimages aren't compiled with OCCT 7.5

05:10:04  <Import> ImportOCAF2.cpp(1134): Unnamed#untitled_Hex_Holder_I3Mk3 has null shape
05:10:04  Traceback (most recent call last):
  File "<string>", line 4, in <module>
<class 'RuntimeError'>: gITF support requires OCCT 7.5.0 or later

System Used: OS: Ubuntu 20.04.2 LTS (ubuntu:GNOME/ubuntu) Word size of OS: 64-bit Word size of FreeCAD: 64-bit Version: 0.19.24276 (Git) AppImage Build type: Release Branch: (HEAD detached at 0.19.1) Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438 Python version: 3.8.8 Qt version: 5.12.9 Coin version: 4.0.0 OCC version: 7.4.0 Locale: English/United States (en_US)

X-Ryl669 commented 3 years ago

It's being discussed already. Hopefully, the dependency should be updated.