Origin changes on stl import

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!
jcmirandaccr
Posts: 3
Joined: Mon Feb 10, 2020 8:04 pm

Re: Origin changes on stl import

Post by jcmirandaccr »

Thank you all. Yes, the original was not at 0,0,0. I corrected it now... :)
jpgabald
Posts: 1
Joined: Sat Feb 20, 2021 3:32 pm

Re: Origin changes on stl import

Post by jpgabald »

I had a similar issue where the STL file that I was importing had an origin that was not (0,0,0). This made it very difficult to modify and work within Freecad because sketches would not overlay on the object correctly due to the coordinate miss match. Freecad is an awesome tool, but sometimes not the correct tool. I would suggest importing you STL into a program like Blender that is better setup for modifying STLs. In Blender you can reset the Origin of the STL to the Volume of the STL (Hit "T" -> right click on STL -> Set Origin -> Origin to Geometry -> Then in side window set origin to (0,0,0)). Export this STL from Blender. Then re-import into Freecad and you origin will be (0,0,0) which will allow you to work with it using the correct coordinates. Hope this helps!
Duggle
Posts: 11
Joined: Fri Sep 10, 2021 4:21 am

Re: Origin changes on stl import

Post by Duggle »

Thanks so much for the tip to reset coordinates of stl files in Blender!
It seems that things downloaded off of Thingiverse can be pretty random and that slicers such as Cura automagically translate them usefully, hiding the issue...
And then I tried importing them into FreeCAD for rework and have spent hours working through this issue. Very glad to be making progress!
edwilliams16
Veteran
Posts: 3183
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Origin changes on stl import

Post by edwilliams16 »

You could also make use of this macro. https://wiki.freecadweb.org/Macro_MoveToOrigin
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Origin changes on stl import

Post by TheMarkster »

Here is a macro to move a mesh to the origin. It does't rotate it, but most of the time the meshes are already orthogonal to the origin.

Usage: Select the mesh, run the macro. Undo should work to put the mesh back in its former location if you change your mind.

Code: Select all

doc = FreeCAD.ActiveDocument


def moveMesh(mesh):
    center = mesh.Mesh.BoundBox.Center
    mesh.Placement.Base.x -= center.x
    mesh.Placement.Base.y -= center.y
    mesh.Placement.Base.z -= center.z


sel = Gui.Selection.getSelectionEx()
if len(sel) == 1:
    if sel[0].Object.TypeId == "Mesh::Feature":
        mesh = sel[0].Object
        doc.openTransaction("Move Mesh")
        moveMesh(mesh)
        doc.commitTransaction()
    else:
        FreeCAD.Console.PrintError("Select a mesh object and try again.\n")
Duggle
Posts: 11
Joined: Fri Sep 10, 2021 4:21 am

Re: Origin changes on stl import

Post by Duggle »

The macro works nicely for me.
Much easier than using Blender just for this step.
Thanks for the replies.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Origin changes on stl import

Post by jmaustpc »

edwilliams16 wrote: Fri Sep 10, 2021 5:24 pm You could also make use of this macro
TheMarkster wrote: Fri Sep 10, 2021 8:53 pm Here is a macro to move a mesh to the origin
G'day guys
Just thought I would mention another idea.

A long term FreeCAD developer, Kieth Sloan, has made an add on workbench named "toSketch" which contains various interesting tools that have been asked for over time.

One of those tools is "to Reset Origin". He made that because for a while we were seeing a lot of STEP files exported from other CAD applications that when imported into FreeCAD had unexpected local co-ordinate origin of the solid, so the solid was somewhere way off from Global Origin in FreeCAD.

The tool was originally created to work on a solid, I don't recall of it also works with an imported STL. I made the icons for him. :)

Here is a screen shot showing the "to Reset Origin" tool in "toSketch" workbench.
Screenshot_20210918_223852.png
Screenshot_20210918_223852.png (52.32 KiB) Viewed 2126 times
Jim

edit, here is a link to a topic where he was talking about the toSketch workbench.

https://forum.freecadweb.org/viewtopic. ... ch#p530793
Post Reply