I made this Python script, which is based on this tutorial:
Code: Select all
import sys
sys.path.append('/usr/lib/freecad/lib/')
from pathlib import Path
import FreeCAD
import FreeCADGui as Gui
import Part
# Loading test part
out_dir = Path('/tmp')
# Gui.showMainWindow()
Part.open('.../3d/SOT-25-5.step')
# Creating images with different Views, Cameras and sizes
for p in ['PerspectiveCamera','OrthographicCamera']:
Gui.SendMsgToActiveView(p)
for f in ['ViewAxo','ViewFront','ViewTop']:
Gui.SendMsgToActiveView(f)
for x,y in [[500,500],[1000,3000],[3000,1000],[3000,3000],[8000,8000]]:
Gui.ActiveDocument.ActiveView.saveImage(str(out_dir / f'Blade_{p}_{f}_{x}_{y}.jpg'), x, y, 'White')
Gui.ActiveDocument.ActiveView.saveImage(str(out_dir / f'Blade_{p}_{f}_{x}_{y}.png'), x, y, 'Transparent')
# Close active document
FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name)
Thank you!