wmayer wrote: ↑Wed Feb 26, 2020 1:35 pm
I meant why it seemed faster to convert with Mesh.export() compared to Mesh.Mesh().write(), not STL compared to obj. That is really much faster writing STL.
Mesh.export() cannot be faster than Mesh.Mesh().write() because internally it has a much bigger overhead and it uses the same functions to write the STL files. Now I wonder if you used it correctly: what is the file size of the created STL file? If it's only 84 bytes then you can be sure that it contains no mesh data.
Sorry again misunderstanding. I meant Mesh.Mesh().write() is really faster writing STL than obj. But my point was that when comparing Mesh.export() and Mesh.Mesh().write() when writing obj files it seemed to me that Mesh.export() was faster. But that was probably only caused because I used a much smaller test file for that.
Wow, that was fast, nice!
For further testing purposes I first saved the data into a buffer in memory and then wrote the whole content in one go to the file. The measured time doesn't decrease any more, it's even slightly slower.
Alright.
Test results with ~24 MB test file:
FreeCADCmd:
Code: Select all
>>> import Mesh
>>> import time
>>>
>>> start = time.time()
>>>
>>> mesh = Mesh.Mesh()
>>> mesh.read("Y:\\00000188_6c4172e8a17140f89d3b1c0a_step_005.stl") # read STL
>>> mesh.write("Y:\\00000188_6c4172e8a17140f89d3b1c0a_step_005.obj") # write OBJ
saving......
>>>
>>> end = time.time()
>>> print(end - start)
483.34871077537537
FreeCAD GUI in Python console:
Code: Select all
>>> print(end - start)
455.2598876953125
Looks like GUI was actually faster, but that can be a coincidence.
Y:\ is a network drive, so that probably makes the problem of disk i/o much worse.
Testing again writing to a local drive (SSD, so that is probably also beneficial):
CMD:
Code: Select all
>>> print(end - start)
12.861110210418701
GUI:
Code: Select all
>>> print(end - start)
12.569581985473633
So for now I will change the batch script to use the local drive for output.