Page MenuHomeAleph Objects Inc

Uranium STL Writer plugin
Open, NormalPublic

Description

STL writer needs to include normals when generating either binary or ascii .stl files.

Current ascii output:

facet normal 0.0 0.0 0.0

Should be something along the lines of:

facet normal -0.99693852663 -0.0781891718507 0

The problem is in this file: STLWriter.py line 50:

stream.write("facet normal 0.0 0.0 0.0\n")

Code is crippled to skip including normals.

for node in nodes:
    mesh_data = node.getMeshData().getTransformed(node.getWorldTransformation())
    verts = mesh_data.getVertices()

Does mesh_data include normals? If so, is it possible to include a line similar (not sure if .getNormals() is good.)

normals = mesh_data.getNormals()

This would need to be changed to output the values:

stream.write("facet normal 0.0 0.0 0.0\n")

Part of the problem might be in ImageReader.py I'm not sure if the code in mesh = MeshBuilder() is set to calculate normals by setting fast=True

mesh.calculateNormals(fast=True)

scene_node.setMeshData(mesh.build())

return scene_node
  • The previous version 21.08 worked perfectly. Current version creates unusable .stl files (for my purposes). Without normals, it's difficult to compute model volume. Current workaround is to use Cura 21.08 to generate .stl files from .png graphics.

Event Timeline

Seems that the issue is in ImageReader.py & the mesh that it creates. Importing a .stl generated from Cura 21.08 or earlier into the current version of Cura exports fine using STLWriter.py

Opening .png or .jpg files using Cura 21.08 or earlier & exporting (save as...) .stl files worked perfectly.

Is there a way to go back to using the earlier image reader / mesh builder that was in Cura 21.08 or earlier?

karrad triaged this task as Normal priority.
karrad reassigned this task from camerriman to victor_larchenko.
karrad added a subscriber: karrad.

@camerriman Thank you for the report. We are just getting ready to release an alpha version of the 3.2 branch for testing. We will get this one over to the 3.2 board for evaluation.

karrad changed the edit policy from "Custom Policy" to "Cura LulzBot Edition (Project)".Mar 12 2018, 1:10 PM

I've looked a little closer.

Legacy code in imageToMesh.py & from printableObject from Cura.util works perfectly.

def convertImage(filename, height=20.0, width=100.0, blur=0, invert=False, baseHeight=1.0):

....
obj._postProcessAfterLoad()

return obj

In ImageReader.py, it would be nice if _generateSceneNode would return a (scene_node) mesh exactly like the mesh obj created in imageToMesh.py.

Cura 21.08

import image & export to .stl works perfectly. No issues with the .stl file

Cura 2.6.69 mac

Loads .stl files created in Cura 21.08 & exports a duplicate copy (no issues).

Also... in ImagerReaderUI.py

For the blur routine, the default is set to 1. (light smoothing) which is barely perceptible in the user interface dialog box. Easy to miss or not notice that is set to light smoothing.

self.smoothing = 1

Default should be 0

self.smoothing = 0
In ImageReaderUI.py

 self.default_width = 120
 self.default_depth = 120

 self._aspect = 1
 self._width = self.default_width
 self._depth = self.default_depth

largest = max(width, depth)
width = width / largest * self._ui.default_width
depth = depth / largest * self._ui.default_depth

self._ui.setWidthAndDepth(width, depth)

There is a problem with reading the image width & depth & setting the ui with the values. This default size of 120 buggers everything up. The default overrides the image width & depth values & sets the maximum size at 120. This is no good. All the graphics are scaled prior to import to the correct size. Images scaled to 33.333 pixels/cm will import and create a model 1:1. Previous version of imageToMesh.py worked perfectly.

This creates a workflow bottleneck. This requires you to write down the dimensions of the graphic & manually enter the values in the ui. Creates a error zone... If the documentation explained how to prepare images for import, there would not be the need to cripple the interface to handle images that are not scaled correctly prior to import.

karrad removed victor_larchenko as the assignee of this task.Apr 13 2018, 2:30 PM
karrad moved this task from Testing release (v3.2.18) to Backlog on the Cura LulzBot Edition board.
karrad added a subscriber: victor_larchenko.