Small enhancements in slicer stl input

This commit is contained in:
Mario Voigt 2021-12-19 23:54:42 +01:00
parent e053781ac7
commit c5b169321f
2 changed files with 10 additions and 6 deletions

View File

@ -10,7 +10,7 @@
<param name="inputfile" type="path" gui-text="Input file (OBJ/OFF/PLY/STL)" filetypes="obj,off,ply,stl" mode="file">/your/object/file.stl</param>
<param name="max_num_faces" type="int" min="1" max="99999" gui-text="Maximum allowed faces" gui-description="If the STL file has too much detail it contains a large number of faces. This will make processing extremely slow. So we can limit it.">200</param>
<param name="layer_height" type="float" min="0.001" max="99999.000" precision="3" gui-text="Layer height [mm]">1.000</param>
<param name="layer_number" type="int" min="0" max="99999" gui-text="Specific layer number" gui-description="Set to 0 to import all numbers or set a number 1+ to import a specific layer.">0</param>
<param name="layer_number" type="int" min="-99999" max="99999" gui-text="Specific layer number" gui-description="Set to 0 to import all numbers or set a number + or - to import a specific layer. Negative values will invert (count backwards)">0</param>
<hbox>
<vbox>
<label appearance="header">Transforms</label>

View File

@ -168,7 +168,7 @@ class SlicerSTLInput(inkex.EffectExtension):
'--no-gui',
'--scale', str(scale),
'--rotate-x', str(args.rx),
'--rotate-y', str(args.ry),
'--rotate-y', str(180+args.ry), #we import the style like PrusaSlicer would import on the plate
'--rotate', str(args.rz),
'--first-layer-height', '0.1mm',
'--export-svg', '-o', svgfile, args.inputfile]
@ -338,11 +338,15 @@ class SlicerSTLInput(inkex.EffectExtension):
#inkex.utils.debug("{0}: {1} polygons in {2} layers converted to paths.".format(svgfile, polygoncount, layercount))
if self.options.layer_number != 0:
for element in doc.xpath("//svg:g", namespaces=inkex.NSS):
groups = doc.xpath("//svg:g", namespaces=inkex.NSS)
for element in groups:
#for element in doc.getroot().iter("{http://www.w3.org/2000/svg}g"):
if element.get('id').split('stl-layer')[1] != str(self.options.layer_number):
element.getparent().remove(element) #element.delete() does not work. why?
if self.options.layer_number > 0:
if element.get('id').split('stl-layer')[1] != str(self.options.layer_number):
element.getparent().remove(element) #element.delete() does not work. why?
else:
if element.get('id').split('stl-layer')[1] != str(len(groups) + self.options.layer_number):
element.getparent().remove(element) #element.delete() does not work. why?
if layercount == 0:
inkex.utils.debug("No layers imported. Try to lower your layer height")
exit(1)