Import.export function not generating file

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
KDuhme
Posts: 1
Joined: Tue Aug 09, 2022 5:02 am

Import.export function not generating file

Post by KDuhme »

Hello,

I am trying to change the color of a step file using FreeCAD in Console Mode, before exporting it again using the Import.export function. I also tried exporting the file I imported directly, but it still does not generate a file. I am using FreeCAD Version 0.20.

Code: Select all

import Import
importTest = Import.open(r"C:\Dir\Testfile.stp")
Import.export(importTest, r"C:\Dir\Testexport.stp")
Is there a known problem when trying to use this function with version 0.20? I have used the exportStep() Function before to export Compounds and it worked like a charm. But using this function I cannot change the color beforehand.

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: German/Germany (de_DE)
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: Import.export function not generating file

Post by Syres »

KDuhme wrote: Tue Aug 09, 2022 5:18 am Is there a known problem when trying to use this function with version 0.20? I have used the exportStep() Function before to export Compounds and it worked like a charm. But using this function I cannot change the color beforehand.
Welcome to the forum, I'm not aware of a problem with the function but I think you maybe have been caught out by the folder separators, have a look at my successfully tested version with a fairly large Step assembly:

Code: Select all

import Import
importTest = Import.open(r"E:/Data/FreeCAD/Steps/R3-4109PL-TT10-Main frame  assembly.STEP")
objs = FreeCAD.ActiveDocument.Objects
Import.export(objs,r"E:/Data/FreeCAD/Parts/ForumExamples/StepWithRandomColours_Test.step")
I believe if you use Windows '\' (backslash) then they have to be escaped out which basically means you have to use double backslashes so it's easier IMHO just to use forward slashes as shown in the Python Console when you do the Gui equivalent.

Code: Select all

OS: Windows 7 Version 6.1 (Build 7601: SP 1)
Word size of FreeCAD: 64-bit
Version: 0.20.1.29396 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: b2fe784efdcbf062b32e2832b4f42743d2d15edb
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * A2plus 0.4.56a
  * Assembly3 0.11.3
  * CfdOF 1.17.7
  * Curves 0.5.4
  * fasteners 0.3.51
  * fcgear 1.0.0
  * freecad.xray 2022.4.17
  * Manipulator 1.4.9
  * Plot 2022.4.17
  * sheetmetal 0.2.56
  * Silk 1.0.0
Post Reply