STL conversion

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
sp9rqa
Posts: 38
Joined: Wed Jan 10, 2018 10:38 am
Location: Gorlice
Contact:

STL conversion

Postby sp9rqa » Mon Feb 05, 2018 12:26 pm

I have tiny problem with "stl" conversion.
FC create meshes but not create "Solid from shell".

Example file: left_mainv3.stl in https://www.thingiverse.com/thing:2043600/#files project.

shell=App.ActiveDocument.left_mainv3001.Shape
>>> if shell.ShapeType != 'Shell': raise RuntimeError('Part object is not a shell')
>>> _=Part.Solid(shell)
>>> if _.isNull(): raise RuntimeError('Failed to create solid')
>>> App.ActiveDocument.addObject('Part::Feature','Solid').Shape=_.removeSplitter()
>>> del _

Why?

Krzysztof
User avatar
Kunda1
Posts: 8739
Joined: Thu Jan 05, 2017 9:03 pm

Re: STL conversion

Postby Kunda1 » Mon Feb 05, 2018 3:47 pm

sp9rqa wrote:
Mon Feb 05, 2018 12:26 pm
please always post you Help > About FreeCAD > Copy to clipboard info
and please put code in

Code: Select all

code brackets
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
sp9rqa
Posts: 38
Joined: Wed Jan 10, 2018 10:38 am
Location: Gorlice
Contact:

Re: STL conversion

Postby sp9rqa » Mon Feb 05, 2018 5:26 pm

I have tested some last versions, there is always the same result.



OS: Debian GNU/Linux testing (buster)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13205 (Git)
Build type: None
Branch: master
Hash: 4ef00d7be4658a1fdc905699ede2860e002d9996
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: Polish/Poland (pl_PL)
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: STL conversion

Postby NormandC » Tue Feb 06, 2018 3:40 am

sp9rqa wrote:
Mon Feb 05, 2018 12:26 pm
Why?
I'm asking myself the same thing: why did you post in Open discussion, when this is clearly a help request?

Help requests should be posted in the "Help on using FreeCAD" forum. If your question is about python scripting, then use the python scripting forum.

sp9rqa wrote:
Mon Feb 05, 2018 12:26 pm
I have tiny problem with "stl" conversion.
FC create meshes but not create "Solid from shell".
The problem is that you assume that you have a valid manifold mesh. But the fact is, you cannot be sure of it. An outstanding proportion of stl files on Thingiverse are simply badly made.

The first problem is that your mesh is actually composed of multiple meshes. Each raised letter is a separate mesh. Check your shape with Part CheckGeometry. You can separate them with Arch --> Utilities --> Split mesh.

But then you'll see that the first mesh for the body, when converted to a shape, forms an invalid shell. If you check the mesh with "Meshes --> Analyse --> Evaluate & Repair Mesh...", it will tell you there are 15 degenerated faces.

But you are lucky: here, the repair function works. Usually, it destroys the mesh further, by deleting the broken faces and leaving a mesh with missing faces.

Attached is a FCStd file with the main body converted to shape, refined then converted to solid. You'll have to repeat the process with the letters.
Attachments
left_mainv3.fcstd
(328.73 KiB) Downloaded 15 times