#!/usr/bin/python
# -*- coding:utf-8 -*-
#This programm is used to transfer all xml to stl in a folder
def xml2stl():
#get all the file names in the folder
import os
#os.getcwd() get the current working directory
# the place os.getcwd() can put any directory you want to do
filenames = os.listdir(os.getcwd()) #all the filenames in the current folder
for filename in filenames:
if '.xml' in filename: #only get .stl file
file_output_stl = filename.strip('.xml') + '.stl' #output file name
k = 0
lines = open(filename).readlines() #read all lines
for line in lines: #analysis each line
if '<' not in line:
k += 1 #get only numbers line
header_stl = 'solid ' + filename + '\n' +''' facet normal 1 0 0
outer loop
vertex '''
body_stl = '\n'+ ''' endloop
e
xml2stl.py代码实现xml文件转换为stl文件格式
最新推荐文章于 2023-08-23 08:15:33 发布