SketchUp / sketchup-stl

A SketchUp Ruby Extension that adds STL (STereoLithography) file format import and export.
http://extensions.sketchup.com/content/sketchup-stl
MIT License
248 stars 68 forks source link

STL Import Hangs During "Repairing Geometry" #75

Closed cray54 closed 11 years ago

cray54 commented 11 years ago

I have an STL file created with FreeCAD 0.13 that imports almost immediately using an old version ("jf_stl_importer.rb"). The updated STL importer takes the same file, states "Repairing Geometry", works for several minutes, and displays a part with a lot of incorrect additional geometry.

Is this a common issue? [edit: or is there a way to disable geometry repair?]

Thanks, Chris

thomthom commented 11 years ago

Not observed that myself, nor heard any reports until now.

Can you share the model?

cray54 commented 11 years ago

The file is a mesh created in FreeCAD 0.13 of a STEP file from McMaster.

www.grayred.com/images/s/MMC_91251A349_Socket_Head_Cap_Screw_10-32x1.25in.stl

thomthom commented 11 years ago

I had a look at the file and here is my observations:

When importing with mm as units I see what you describe. However, I also immediately see the cause of that - when imported in mm you have many edges that that tiny - less than 1mm. I measured many to be 0.09~mm.

SketchUp's internal tolerance is 1/1000 of an inch - that is 0,0254mm. This model is right up at the limits.

The reason this importer doesn't work as Jim's original is because this STL importer makes an assumption that imported geometry should be an solid. When it detects that the imported geometry isn't solid it will run a repair-pass on the model - trying to force edges and faces to merge properly. Since this model has so tiny edges this repair-pass cause SketchUp to lose some geometry.

When I disabled the repair-pass in the source code the import was speedy as you described Jim's importer to be. But the imported geometry has lots of tiny holes - which is what the importer tried to repair.

When I import as centimeters or meters the file imports quickly and without errors - it comes in as a solid.

So I'm afraid that this isn't something we can fix in this STL plugin - as you're running into limitations of SketchUp when importing geometry with so small details.

One workaround you can use if import in a larger scale, then scale down the imported instance. Don't scale the definition (as in, don't open up the group and scale). That might allow you to use it in SketchUp without losing geometry.

cray54 commented 11 years ago

Ahh, I verified the file represented a solid but did not realize edges [that were too small] would be discarded. Also, I did not realize the old import method was also discarding edges, just doing so quietly.

I often work with very small parts. In order to use SketchUp I have to work on a large scale in SketchUp before scaling them down. I did not realize scaling a group (or presumably a component) was actually better than scaling the contents of the entity. Thank you for the help and guidance.

thomthom commented 11 years ago

It might be a difference - because the definition of the group/component will be 100 times larger - but the instance of the definition is scaled down to fit. That might help. But I wouldn't put it up as a safe thing.