import subprocess print("counting meshes") #induce a bash task , count number of meshes inside task = subprocess.Popen("ls -1 ../Mesh/| wc -l", shell=True, stdout=subprocess.PIPE) Mesh_No = task.stdout.read() Mesh_No = int(Mesh_No) mesh_arr = [] print("started moving all data to blender space coords representation") for i in range(1, Mesh_No): #Load a model from a file. model = pySTL.STLmodel('../Mesh/%d.stl' % i) #print model properties print("Volume " + str(model.get_volume())) c = model.get_centroid() print("Centroid " + "X: " + str(c[0]) + " Y:" + str(c[1]) + " Z:" + str(c[2])) #Translate the model so that the centroid is at the origin. model.translate(-c) model.write_text_stl('../Mesh/centered/%d.stl' % i) print("finished successfully")
import pySTL from numpy import array #Load a model from a file. model = pySTL.STLmodel('model_dla_bartka_bez_skali.stl') scale = 0.00035 model.scale(scale) model.write_text_stl('Bartek_skala_2857.stl')
import pySTL from numpy import array #Load a model from a file. model = pySTL.STLmodel('text.stl') #print model properties print "Volume " + str(model.get_volume()) c = model.get_centroid() print "Centroid " + "X: " + str(c[0]) + " Y:" + str(c[1]) + " Z:" + str(c[2]) #Translate the model so that the centroid is at the origin. model.translate(-c) model.write_text_stl("torsoAtCentroid.stl") #Rotate the model 90 degrees about the Y-axis R2 = pySTL.rotationAboutY(-3.14159 / 2) model.rotate(R2) c = model.get_centroid() print "Centroid " + "X: " + str(c[0]) + " Y:" + str(c[1]) + " Z:" + str(c[2]) model.write_text_stl('torsoRAtCentroid.stl') #Scale the model down by 100% scale = 0.001 model.scale(scale) model.write_text_stl('torsoRandSatCentroid.stl')
default=False) args = parser.parse_args() if args.verbose: def verboseprint(*args): # Print each argument separately so caller doesn't need to # stuff everything to be printed into a single string for arg in args: print arg, print else: verboseprint = lambda *a: None # do-nothing function model = pySTL.STLmodel(args.infile) if args.scale != 1: verboseprint("Scaling model by factor: ", args.scale) model.scale(args.scale) translation = args.translate if len(translation) == 3: verboseprint("Performing translation: deltaX = ", str(translation[0]), ", deltaY = ", str(translation[1]), ", deltaZ = ", str(translation[2])) model.translate(translation) eulerAngles = args.rotate if len(eulerAngles) == 3: verboseprint('Performing Rotation')