Exporting STEP without GUI module?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
danidr
Posts: 40
Joined: Thu Aug 25, 2016 10:46 am

Exporting STEP without GUI module?

Post by danidr »

Hello everyone,

I found some discrepancies between Import and ImportGui relative to file structure.
I am calling FreeCAD from a Python script to generate drawings in a server environment, without GUI, and I'd rather keep it so, without resorting to xvfb (because startup time and resources usage would increase exponentially).
Now, I want to export whatever drawing I am generating with a wrapping App::Part. I do this programmatically, with the following lines, where __objs__ is the list of Bodies I want to export:

Code: Select all

root = FreeCAD.ActiveDocument.addObject('App::Part', 'Root')
root.Label = 'RootLabel'
root.addObjects(__objs__)
Then, I do the following to export such "root" object as STEP:

Code: Select all

import Import
Import.export([root], "<path>.step"))
From which I get:
'RootLabel' is not a shape, export will be ignored.

Of course, the same exact command through ImportGui works perfectly:

Code: Select all

import ImportGui
ImportGui.export([root], "<path>.step"))
Anyone have an idea about how to resolve this?
Thank you,

Daniel
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Exporting STEP without GUI module?

Post by openBrain »

What is your version ? Both Import & ImportGui work fine for me (but I tested only in the Gui environment).
Do you perform a recompute before exporting ?
Normally a Part doesn't have a real shape but a virtual one composed by its top child objects. Maybe this is why it fails. You could try to use a Part/Compound rather than a Part container. ;)
danidr
Posts: 40
Joined: Thu Aug 25, 2016 10:46 am

Re: Exporting STEP without GUI module?

Post by danidr »

Sorry for the veeeeery late reply to my own thread...
I use FreeCAD 0.18.4. Yes, I do perform a recompute before exporting, to update all the parameters in the different features.
The idea of using a Part (with all children objects) is to keep the hierarchy of the file in the exported STEP... unless there's an easier method, this is the only way I found.
Thanks for the answer in the meanwhile!
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Exporting STEP without GUI module?

Post by openBrain »

Could you try with latest FreeCAD 0.19, and eventually post a sample file for testing purpose if you still don't succeed ?
danidr
Posts: 40
Joined: Thu Aug 25, 2016 10:46 am

Re: Exporting STEP without GUI module?

Post by danidr »

openBrain wrote: Mon Dec 07, 2020 2:56 pm Could you try with latest FreeCAD 0.19, and eventually post a sample file for testing purpose if you still don't succeed ?
Sure, thank you; I will try ASAP. Keep in mind I do this from a PY script, not from the GUI, that may be why.
demonlibra
Posts: 79
Joined: Tue Jan 21, 2020 1:11 pm

Re: Exporting STEP without GUI module?

Post by demonlibra »

remove the character <)> at the end

Code: Select all

import ImportGui
ImportGui.export([root], "<path>.step"))

Code: Select all

import ImportGui
ImportGui.export([root], "<path>.step")
User avatar
onekk
Veteran
Posts: 6222
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Exporting STEP without GUI module?

Post by onekk »

demonlibra wrote: Fri Jul 29, 2022 5:12 pm ...
Hello, You answering a two years old post, are you aware of this?

Probably something is different from 2020 as FC is evolving, and maybe the original poster has found a solution or gave up some time ago.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply