.stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
James2406
Posts: 2
Joined: Sat Feb 02, 2019 7:11 am

.stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby James2406 » Sat Feb 02, 2019 7:28 am

I've searched a bit in the past few days after work on this issue but have not seen a solution. If I've missed over one sorry feel free to yell at me.

I've been doing some modeling as a hobby in blender for years and recently decided to attempt a Cummins 5.9L inline 6 Turbo Diesel Engine for a larger project.

This means searching for reference images and even Cummins Draftings for correct dimensions etc. I stumbled across an Engnerinering CAD model and for us hobbyist, this is the holy grail of reference. It can provide a full 3D model for me to reference and even help with correct poly flow etc. The game I create assets for really likes low poly counts so obviously using the CAD model is a no go among other things like a standing morality code we have in our community to create our own models and not steal etc.

Anyway, I was referred to FreeCad in an attempt to import the .stp since Blender doesn't currently have a plugin. So doing so I loaded the model in.
Image

What a beauty she is. So just doing some quick research I figured out how to export (or so I thought) and gave the .stl and .obj exporters a shot.

Upon importing to blender I am left with what I would refer to in blender terms as, misaligned or corrupt origins.
Image

I attempted to import these files back into freecad and am given the same, misoriented parts.

A side issue as well is the whole object seems to be joined together as one mesh. Which would be a slight issue if the origins per say where correct, but I can work with that. However, trying to re-position the meshes at such a large poly count is a bit too for much my system. Even at 5ghz 7700k and a gtx 1070. Really puts into perspective what the pros have at their disposal as far as hardware is concerned. Was a pretty cool realization. Anyway. Here is my version.


OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13541 (Git)
Build type: Release
Branch: releases/FreeCAD-0-17
Hash: 9948ee4f1570df9216862a79705afb367b2c6ffb
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)


Sorry if anything is incorrect and much appreciated on the read and or help. I'm sure this is either a quick settings change or just how it is with the export plugins. Thanks!

-James.
Syres
Posts: 219
Joined: Thu Aug 09, 2018 11:14 am

Re: .stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby Syres » Sat Feb 02, 2019 6:54 pm

Welcome to the forum, I can confirm using version 0.17.13541 and the standard File > Export > STL produces incorrect locations for the STL files. I have got the sump, block and cylinder number 1 rocker cover to export correctly using the Mesh Design workbench, Create Mesh from Shape using the settings in the below screenshot and then use the Export Mesh button within the workbench not from the File menu.

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15697 (Git)
Build type: Release
Branch: master
Hash: dedaa807629ab25cf32977d30bf7610f1346aff7
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)

But I have to say that you're pushing the boundaries with that size of file and quantity of objects, my PC hasn't crashed yet but it's properly go slow.
If you have a look in the Python Scripting and Macros section I'm sure there's been requests for this kind of conversion in the past which might help with such a large quantity of objects or just export the extremities manually if you just need a guide along with reference 2D drawings/photos in Blender.
Attachments
STLSettings.jpg
STLSettings.jpg (54.3 KiB) Viewed 416 times
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: .stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby NormandC » Sat Feb 02, 2019 7:50 pm

Hello James,

Welcome.

James2406 wrote:
Sat Feb 02, 2019 7:28 am
I was referred to FreeCad in an attempt to import the .stp since Blender doesn't currently have a plugin.
And I very much doubt it ever will. Blender is a polygon mesh modeller; .stp or STEP (ISO 10303) is a CAD exchange format for B-rep models. Only a CAD program with a CAD kernel can import and display a CAD model, I'd think that a STEP plug-in for Blender would need to rely on a third-party library that would convert the STEP file into a mesh format.

James2406 wrote:
Sat Feb 02, 2019 7:28 am
Upon importing to blender I am left with what I would refer to in blender terms as, misaligned or corrupt origins.

I attempted to import these files back into freecad and am given the same, misoriented parts.
I believe this is a bug that was introduced in FreeCAD 0.17 with the new Image Std Part container, and the STEP import utility updated to use it to structure imported STEP assemblies. Part containers are used to group sub-assemblies of components; each Part container has its own coordinates, but the export utility does not recognize them properly. AFAIK this was fixed in v0.18, which while still in development, is approaching release (no date is set though). Development builds are available, and they've been quite stable for a long time.

James2406 wrote:
Sat Feb 02, 2019 7:28 am
A side issue as well is the whole object seems to be joined together as one mesh.
That's typically what STL export does. STL is a rapid prototyping format developed originally for stereolithography, now widely used for 3D printing. It is not well suited for your purpose; you should rather export to Wavefront OBJ (not Alias Mesh). If you did choose OBJ and the whole object seems to be a fused mesh, then this may be a different issue; difficult to troubleshoot without the original STEP file.

Is the STEP openly available online?
Syres
Posts: 219
Joined: Thu Aug 09, 2018 11:14 am

Re: .stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby Syres » Sat Feb 02, 2019 8:38 pm

NormandC wrote:
Sat Feb 02, 2019 7:50 pm
James2406 wrote:
Sat Feb 02, 2019 7:28 am
I was referred to FreeCad in an attempt to import the .stp since Blender doesn't currently have a plugin.
And I very much doubt it ever will.
There's plenty of enthusiasm to get a STEP addon up and running, someone called Jaume Bellet has got a test bed running but it's apparently being converted to be 2.80 compatible, see https://www.youtube.com/watch?v=qCy0zZ0r3nA

While by default Blender uses it's own units, there is a proper Metric and Imperial units facility. I ended up creating a specific Metric importing Blender file with a script that I run against a shared folder to bring in all STL files that I've exported from FreeCAD. I believe Yorik has a full Blender mesh creating script that interacts with FreeCAD files but the Python version in both pieces of software have to match exactly and I'm not into all this making specific builds hence having to do my own thing.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: .stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby NormandC » Sat Feb 02, 2019 9:05 pm

I'm very curious to know how the STEP to mesh process is done... They haven't published anything though.
James2406
Posts: 2
Joined: Sat Feb 02, 2019 7:11 am

Re: .stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby James2406 » Sat Feb 02, 2019 11:53 pm

Thanks for the replies gentlemen, I'm currently at work and unable to really do much from here. I will be busy for the next few days but In time when I get some time off, I will re-join this conversation.

The file is openly available as I found it in a buried Cummins related forum thread from about a year ago. Here is said link.

https://www.dropbox.com/s/8i3mw5lrjef58 ... d_gUzxspy0

Thanks a lot.

-James
User avatar
mark1791
Posts: 24
Joined: Fri Aug 03, 2018 1:41 am

Re: .stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby mark1791 » Sun Feb 03, 2019 4:20 am

Looking at a similar model before you sent the link from GrabCAD, looks like a exported step file from ProE, engine department people generally design in ProE and the other departments use CATIA....

Opening the step file in FreeCAD via File import, imports the model as a single solid, where as if you import via Part workbench import, imports it as 194 sepearte solids, as picture below. Why the difference, i don't know someone else may be able to explain the differences in FreeCAD import. This is easier to handle in FreeCAD or any CAD package in FreeCAD uses 3Gig of memory to display. This would normally this would be an assembly of componets which would be easier to handle in CAD, separting out as seperate solids and using an assembly via A2plus maybe an idea?.
Engine.jpg
Engine.jpg (445.45 KiB) Viewed 375 times
Syres
Posts: 219
Joined: Thu Aug 09, 2018 11:14 am

Re: .stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby Syres » Sun Feb 03, 2019 1:14 pm

Well I managed to get the complete engine in as one mesh (but can be done as separate items it materials dictates that) and even after running this script in Blender it was still just over 10 million faces down from 18 million:

Code: Select all

import bpy

C = bpy.context
scene = C.scene

C.tool_settings.mesh_select_mode = (True, False, False)

for ob in C.selected_objects:
    if ob.type == 'MESH':
        scene.objects.active = ob #set active object
        bpy.ops.object.mode_set(mode='EDIT') #switch to edit mode
        bpy.ops.mesh.select_all(action='SELECT')
        bpy.ops.mesh.remove_doubles() #remove doubles
        bpy.ops.mesh.tris_convert_to_quads() #tris to quads
        bpy.ops.mesh.customdata_custom_splitnormals_clear() #remove custom normals
        bpy.ops.object.mode_set(mode='OBJECT') #switch to object mode
I'll put together the procedure I followed which I'm sure someone can make far slicker and post it tomorrow as it's not urgent. I assume @James2406 will be constructing a low poly mesh and baking the difference between the two into a Normal Map in order to give the appearance of detail while making his game still responsive.
Attachments
Cummins59.jpg
Cummins59.jpg (152.05 KiB) Viewed 335 times
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: .stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby NormandC » Sun Feb 03, 2019 3:29 pm

@James

Thanks for the link. That is one insane model. :shock:
BTW, you could have zipped the STEP file before uploading, STEP is actually a plain text file, it can compress a lot.

Using FreeCAD v0.18, I wasn't able to export to Wavefront OBJ, the exported file is empty. Exporting to COLLADA (*.dae) works, and the components are properly positioned. The DAE file is even heavier than the STEP file, at 241MB. And the components can be separated.

OS: Ubuntu 18.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15780 (Git)
Build type: Release
Branch: master
Hash: f94e76c1116ec3b818961ff65131b3d86fa5b95e
Python version: 2.7.15rc1
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/Canada (fr_CA)
Attachments
Blender_imported_step_motor_01.png
Blender_imported_step_motor_01.png (71.68 KiB) Viewed 320 times
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: .stp imports to FeeCad fine. Exporting to .stl or .obj gives issues upon import to Blender.

Postby NormandC » Sun Feb 03, 2019 3:51 pm

mark1791 wrote:
Sun Feb 03, 2019 4:20 am
Opening the step file in FreeCAD via File import, imports the model as a single solid, where as if you import via Part workbench import, imports it as 194 sepearte solids, as picture below. Why the difference, i don't know someone else may be able to explain the differences in FreeCAD import.
If it imports as a single solid, it's possible that you have "Enable STEP Compound merge" checked in Preferences/Import-Export/STEP.

When I use File --> Open, I get a well structured assembly, where the top assembly and sub-assemblies are Std Part containers. I haven't tried File --> Import, presumably it should be the same.
Attachments
FC_import_step_motor_tree_01.png
FC_import_step_motor_tree_01.png (32.63 KiB) Viewed 316 times