Added toFreecad function and modified the examples to use it. Also cleaned up minor PEP non-conformances.

This commit is contained in:
Jeremy Wright
2014-11-04 17:13:21 -05:00
parent 83e61efbe4
commit 528e4e3a46
26 changed files with 207 additions and 270 deletions

View File

@ -11,14 +11,16 @@
#If you need to reload the part after making a change, you can use the following lines within the FreeCAD console.
#reload(Ex024_Using_FreeCAD_Solids_as_CQ_Objects)
#You'll need to delete the original shape that was created, and the new shape should be named sequentially (Shape001, etc).
#You'll need to delete the original shape that was created, and the new shape should be named sequentially
# (Shape001, etc).
#You can also tie these blocks of code to macros, buttons, and keybindings in FreeCAD for quicker access.
#You can get a more information on this example at http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
#You can get a more information on this example at
# http://parametricparts.com/docs/examples.html#an-extruded-prismatic-solid
import cadquery, FreeCAD, Part
#Create a new document that we can draw our modle on
#Create a new document that we can draw our model on
newDoc = FreeCAD.newDocument()
#shows a 1x1x1 FreeCAD cube in the display
@ -32,10 +34,8 @@ cqBox = cadquery.CQ(cadquery.Solid(initialBox.Shape))
newThing = cqBox.faces(">Z").workplane().circle(0.5).extrude(0.25)
#Add a FreeCAD object to the tree and then store a CQ object in it
nextShape = newDoc.addObject("Part::Feature","nextShape")
nextShape = newDoc.addObject("Part::Feature", "nextShape")
nextShape.Shape = newThing.val().wrapped
#Rerender the doc to see what the new solid looks like
newDoc.recompute()
#Would like to zoom to fit the part here, but FreeCAD doesn't seem to have that scripting functionality