iorodeo avatar iorodeo committed 35eabfa

Fixed typing bug in transforms. Updated view_stl.py so that it can import
multilple stl files. Added and example demonstrating how to create stl files
without using the openscad gui.

Comments (0)

Files changed (3)

examples/create_stls.py

+"""
+Create parts, save scad files and then use openscad form the command
+line to convert the scad files to stl files. 
+"""
+import os
+from py2scad import *
+
+c0 = Cylinder(h=1,r1=1,r2=1)
+c0 = Translate(c0,v=[5,0,0])
+
+c1 = Cube(size=[3,3,1])
+c1 = Translate(c1,v=[-5,0,0])
+
+print 'writng scad files'
+
+prog0 = SCAD_Prog()
+prog0.fn = 10
+prog0.add(c0)
+prog0.write('test0.scad')
+
+prog1 = SCAD_Prog()
+prog1.fn = 40
+prog1.add(c1)
+prog1.write('test1.scad')
+
+
+print 'writing stl files'
+
+os.system('openscad -s test0.stl test0.scad')
+os.system('openscad -s test1.stl test1.scad')
+

examples/view_stl.py

 # --------------------------------------------------------------
 import vtk, sys
 
-stlfile = sys.argv[1]
-# Create the reader and read a data file.  
-sr = vtk.vtkSTLReader()
-sr.SetFileName(stlfile)
+stl_files = sys.argv[1:]
 
-# Connect the mapper and actor 
-stlMapper = vtk.vtkPolyDataMapper()
-stlMapper.SetInput(sr.GetOutput())
-stlActor = vtk.vtkLODActor()
-stlActor.SetMapper(stlMapper)
+actor_list = []
+for f in stl_files:
+
+    # Create the reader and read a data file.  
+    sr = vtk.vtkSTLReader()
+    sr.SetFileName(f)
+
+    # Connect the mapper and actor 
+    stlMapper = vtk.vtkPolyDataMapper()
+    stlMapper.SetInput(sr.GetOutput())
+    stlActor = vtk.vtkLODActor()
+    stlActor.SetMapper(stlMapper)
+    actor_list.append(stlActor)
 
 # Create the Renderer, RenderWindow, and RenderWindowInteractor
 ren = vtk.vtkRenderer()
 iren.SetRenderWindow(renWin)
 
 # Add the actors to the render; set the background and size
-ren.AddActor(stlActor)
+for a in actor_list:
+    ren.AddActor(a)
+
 ren.SetBackground(0.1, 0.2, 0.4)
 renWin.SetSize(600, 600)
 

py2scad/transforms.py

-")""
-n 
+"""
 Copyright 2010  IO Rodeo Inc. 
 
 Licensed under the Apache License, Version 2.0 (the "License");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.