Use a script to export as DAE

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
JorgeFernandes
Posts: 74
Joined: Sun May 07, 2023 12:18 pm

Use a script to export as DAE

Post by JorgeFernandes »

Hi everyone.

How can I export a loaded step as a .dae file?

Code: Select all

 path = 'bim.step'
 s = Part.Shape()
 s.read(path)
To stl I can do:

Code: Select all

s.exportStl(out_path)
Is there something similar to date?


My system:

Code: Select all

OS: Ubuntu 22.04.2 LTS (ubuntu:GNOME/ubuntu-xorg)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Python version: 3.10.2
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/United States (en_US)
Thanks in advance.
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Use a script to export as DAE

Post by Roy_043 »

If you do the export manually, you will see usable Python code in the Python console.
JorgeFernandes
Posts: 74
Joined: Sun May 07, 2023 12:18 pm

Re: Use a script to export as DAE

Post by JorgeFernandes »

Roy_043 wrote: Wed May 24, 2023 7:59 pm If you do the export manually, you will see usable Python code in the Python console.
Thanks for the reply.

I already try that but I can't figure out the proper way to make it work.
User avatar
Roy_043
Veteran
Posts: 8552
Joined: Thu Dec 27, 2018 12:28 pm

Re: Use a script to export as DAE

Post by Roy_043 »

Code: Select all

import Part
import importDAE

path = "C:/Downloads/Test.step"
s = Part.Shape()
s.read(path)

obj = Part.show(s) # Create a document object.
importDAE.export([obj], "C:/Downloads/Test.dae")
JorgeFernandes
Posts: 74
Joined: Sun May 07, 2023 12:18 pm

Re: Use a script to export as DAE

Post by JorgeFernandes »

Roy_043 wrote: Wed May 24, 2023 8:15 pm

Code: Select all

import Part
import importDAE

path = "C:/Downloads/Test.step"
s = Part.Shape()
s.read(path)

obj = Part.show(s) # Create a document object.
importDAE.export([obj], "C:/Downloads/Test.dae")
Thanks a lot. I'll try it and see if it works.
JorgeFernandes
Posts: 74
Joined: Sun May 07, 2023 12:18 pm

Re: Use a script to export as DAE

Post by JorgeFernandes »

Roy_043 wrote: Wed May 24, 2023 8:15 pm

Code: Select all

import Part
import importDAE

path = "C:/Downloads/Test.step"
s = Part.Shape()
s.read(path)

obj = Part.show(s) # Create a document object.
importDAE.export([obj], "C:/Downloads/Test.dae")
This works perfectly. Thanks again for the help.

I have another question:

I can change the resolution, how can I do that with code?
Post Reply