Commits

iorodeo committed 064eabd

Added projection transformation plus and example demostrating it in use. Projection enables the
creation of 2D projections from 3D parts which can then be saved as dxf files an imported into
2D drafting programs such as qcad to make draws with dimensions on them etc.

Comments (0)

Files changed (3)

 *.swp
 *.scad
 *.stl
+*.dxf

examples/smorgasbord.py

     prog.write('test.scad')
     print prog
 
-if 1:
+if 0:
 
     c1 = Cylinder(h=0.5, r1=3.5, r2=3.5) 
     c3 = Cylinder(h=1.0, r1=2.6, r2=2.6)
     prog.add(p)
     prog.write('test.scad')
 
+if 1:
+    prog = SCAD_Prog()
+    prog.fn = 40
+    base = Cube(size=[2,3,0.1])
+    cyl = Cylinder(h=3,r1=0.5, r2=0.5)
+    part = Difference([base,cyl])
+    part = Projection(part)
+    prog.add(part)
+    prog.write('test.scad')
 

py2scad/transforms.py

-"""
+")""
+n 
 Copyright 2010  IO Rodeo Inc. 
 
 Licensed under the Apache License, Version 2.0 (the "License");
         rtn_str = 'rotate_extrude(convexity=%d)'%(self.convexity,)
         return rtn_str
 
+
+# 3D to 2D projection ---------------------------------------------------------
+
+class Projection(base.SCAD_CMP_Object):
+
+    def __init__(self,obj,cut=True,mod=''):
+        base.SCAD_CMP_Object.__init__(self,obj,mod=mod)
+        self.cut = cut
+
+    def cmd_str(self,tab_level=0):
+        cut_str = '%s'%(self.cut,)
+        cut_str = cut_str.lower()
+        return 'projection(cut=%s)'%(cut_str,)