Created
August 11, 2015 05:38
-
-
Save hyOzd/0d75fc98cccfae92a641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# | |
# Example of exporting a cadquery object to STEP using FreeCAD | |
# | |
# `FreeCAD` python module doesn't allow working with colors. For this | |
# we need the `FreeCADGui` module and to be able to access to objects | |
# `ViewObject` property. We are going to initialize FreeCADGui like | |
# usual, but instead of actually showing the window we will hide | |
# it. Note that We won't ever start the main loop at all. | |
# | |
import sys | |
sys.path.append("/usr/lib/freecad/lib/") | |
import FreeCAD, FreeCADGui | |
from PyQt4.QtGui import QApplication | |
import cadquery as cq | |
def run(): | |
# init FreeCAD | |
FreeCADGui.showMainWindow() | |
FreeCADGui.getMainWindow().hide() # prevent splash of main window | |
import ImportGui # must be after `showMainWindow` | |
# create cadquery object | |
box = cq.Workplane("XY").box(10,10,10) | |
# export object to STEP | |
shape = box.toFreecad() | |
FreeCAD.newDocument() | |
doc = FreeCAD.activeDocument() | |
doc.addObject("Part::Feature", "Box") | |
doc.Box.Shape = shape | |
doc.Box.ViewObject.ShapeColor= (1.,0.,0.) # color red | |
ImportGui.export([doc.Box], "/home/heyyo/Desktop/test.step") | |
if __name__ == "__main__": | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment