[SOLVED] export step without GUI

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
vad
Posts: 11
Joined: Sat Dec 08, 2018 5:15 pm

[SOLVED] export step without GUI

Post by vad »

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: German/Germany (de_DE)


Hello,

I'm trying to export my part as step without GUI. For this purpose I want to use Part.export().
Unfortunately I get the following error:

Code: Select all

>>> sono=App.ActiveDocument.getObject("Pad001")
>>> Part.export([sono],"test.step")
      Traceback (most recent call last):
      File "<input>", line 1, in <module>
      RuntimeError: FreeCAD exception thrown (Writing of STEP failed)
Am I doing something wrong or is there a different way to export?

Thanks,
vad
Last edited by vad on Tue Dec 11, 2018 5:46 pm, edited 2 times in total.
chrisb
Veteran
Posts: 54293
Joined: Tue Mar 17, 2015 9:14 am

Re: export step without GUI

Post by chrisb »

Hi vad, welcome.
There are several topics like https://forum.freecadweb.org/viewtopic.php?t=16295 about this. Forum search may help.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: export step without GUI

Post by PrzemoF »

Try:

Code: Select all

sono=App.ActiveDocument.getObject("Pad001")
sono.Shape.exportStep("test.step")
vad
Posts: 11
Joined: Sat Dec 08, 2018 5:15 pm

Re: export step without GUI

Post by vad »

@ chrisb: thank you for your welcome ;). I searched through several topics but couldn't find the solution for my problem.

@ PrzemoF: thank you for your suggestion. I tried it, but I also get an error:

Code: Select all

sono.Shape.exportStep("test.step")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
Part.OCCError: Writing of STEP failed
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: export step without GUI

Post by PrzemoF »

Can you upload the file and/or test export on a simple box? It works for me, but I have newer Freecad, but older OCC/Coin

OS: "Fedora release 28 (Twenty Eight)"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15340 (Git)
Build type: Unknown
Python version: 2.7.15
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.9.1.oce-0.18
Locale: Polish/Poland (pl_PL)
vad
Posts: 11
Joined: Sat Dec 08, 2018 5:15 pm

Re: export step without GUI

Post by vad »

simplebox.png
simplebox.png (157.84 KiB) Viewed 3541 times
I tried to export via Shape.export() a simple box, but I still get the error.
The export via GUI works fine!?
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: export step without GUI

Post by PrzemoF »

Maybe try to record macro and see how FreeCAD does the export? But it will be GUI export..
Do you use this?

Code: Select all

import Import
vad
Posts: 11
Joined: Sat Dec 08, 2018 5:15 pm

Re: export step without GUI

Post by vad »

Now it works ;) .
I have to write the whole directory of the desired step file.
I tried the three following commands:

Code: Select all

Part.export([testbox],"C:/Users/vad/Desktop/testbox/box.step")

testbox.Shape.exportStep("C:/Users/vad/Desktop/testbox/box.step")

import Import
Import.export([testbox],"C:/Users/vad/Desktop/testbox/box.step")
all of them worked.


Thanks
Last edited by vad on Mon Dec 10, 2018 10:27 pm, edited 1 time in total.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: export step without GUI

Post by PrzemoF »

Import.export, but I can't make it work...
vad
Posts: 11
Joined: Sat Dec 08, 2018 5:15 pm

Re: export step without GUI

Post by vad »

Thank you PrzemoF. I tried it and it works now.
Post Reply