I thought that this was a limitation of FreeCAD, but when doing a similar operation from the GUI, the "Export STEP with colors" actually exports to a STEP with colors.
Using the FreeCAD GUI, I can open the following code saved as "cube.scad", select the cube, proceed with export "STEP with colors" to a file I called cube.step and then read that cube.step file in a new FreeCAD session where the cube will show up blue.
Code: Select all
color("blue")cube([10,10,10]);
Reading the cube.scad file using a Python script where the exportStep method is called on the Shape, generates a step file where this blue color is lost.
The python script in a simplified form for this example is like this:
Code: Select all
#!/usr/bin/python
import sys
import FreeCAD
import Part
# This should read any type of file
FreeCAD.loadFile("cube.scad")
outfilename="cube.step"
# iterate through all objects
for o in App.ActiveDocument.Objects:
# find root object and export the shape
if len(o.InList)==0:
o.Shape.exportStep(outfilename)
sys.exit(0)
print("Error: can't find any object")
sys.exit(1)
I suppose that there a better method of exporting the design in order to also export the colors as it is possible to do so from the GUI.
I've tried FreeCAD 0.18 and 0.19, on Windows 10.
Any hint?