Hello,
I would like to generate Parts dynamically on an Ubuntu server per script, therefore I can not use the GUI.
Is it somehow possible to export these Parts to svg, png without using the gui components?
Thanks in advance.
Yours
Marco
Run Freecad headless and save as svg, png
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Run Freecad headless and save as svg, png
I think you could use the Drawing module to produce a svg projection of a shape... Check the Drawing Module documentation, there should be what you need there...
-
- Posts: 395
- Joined: Fri Oct 07, 2011 8:58 pm
- Location: Beaverton,Oregon, USA
- Contact:
Re: Run Freecad headless and save as svg, png
I am doing this exact thing here:
https://github.com/danielfalck/freecadw ... les/upload
You upload a FreeCAD file and -usually- (I need to work out an error with some files) it will give you back a page on the web browser with an SVG loaded.
https://github.com/danielfalck/freecadw ... les/upload
You upload a FreeCAD file and -usually- (I need to work out an error with some files) it will give you back a page on the web browser with an SVG loaded.
Re: Run Freecad headless and save as svg, png
I've tried the server solution but got the following error:
/usr/bin/python /home/marco/python/mechpy/output/freecad/server.py
FreeCAD 0.13, Libs: 0.13R1830 (Git)
ERROR:root:Uncaught exception POST /upload (127.0.0.1)
...
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado-1.2.1-py2.7.egg/tornado/web.py", line 861, in _execute
getattr(self, self.request.method.lower())(*args, **kwargs)
File "/home/marco/python/mechpy/output/freecad/server.py", line 43, in post
self.finish(drawit.makedrawing(fh))
File "/home/marco/python/mechpy/output/freecad/drawit.py", line 133, in makedrawing
doc.addObject("Part::Compound","Compound")
Exception: No document object found of type 'Part::Compound'
ERROR:root:500 POST /upload (127.0.0.1) 1.18ms
I am not familiar with Tornado. Sorry, if this is a stupid question.
Anyway your hints and the code got me some steps further. Thanks a lot.
/usr/bin/python /home/marco/python/mechpy/output/freecad/server.py
FreeCAD 0.13, Libs: 0.13R1830 (Git)
ERROR:root:Uncaught exception POST /upload (127.0.0.1)
...
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado-1.2.1-py2.7.egg/tornado/web.py", line 861, in _execute
getattr(self, self.request.method.lower())(*args, **kwargs)
File "/home/marco/python/mechpy/output/freecad/server.py", line 43, in post
self.finish(drawit.makedrawing(fh))
File "/home/marco/python/mechpy/output/freecad/drawit.py", line 133, in makedrawing
doc.addObject("Part::Compound","Compound")
Exception: No document object found of type 'Part::Compound'
ERROR:root:500 POST /upload (127.0.0.1) 1.18ms
I am not familiar with Tornado. Sorry, if this is a stupid question.
Anyway your hints and the code got me some steps further. Thanks a lot.
-
- Posts: 395
- Joined: Fri Oct 07, 2011 8:58 pm
- Location: Beaverton,Oregon, USA
- Contact:
Re: Run Freecad headless and save as svg, png
Sorry, my implementation is rather fragile. Would you mind posting a FreeCAD file that is causing that error? I could learn something from it. Sliptonic sent me one that causes a crash too.
Thanks.
Thanks.
Re: Run Freecad headless and save as svg, png
The FreeCAD file I used with the github project is attached.
My goal is to automatically generate a 3d model using python and derive views including dimensioning
as graphic files that I can use for pdf-report generation. All this should work on a hosted Ubuntu server
which has naturally no x-server runnig. Therefore I can not use gui related stuff.
As yorik proposed I played arround with the drawing module as well as the draft module. So far I tried to
get the svg string with Drawing.projectToSVG(...) and put it in an existing svg-file which is kind of a hack.
I tried further to use Part.export(...) but that gave me an unhandled FreeCAD exception.
Maybe you can give me a hint what's the right direction or how to achieve that. Your help is really appreciated.
My goal is to automatically generate a 3d model using python and derive views including dimensioning
as graphic files that I can use for pdf-report generation. All this should work on a hosted Ubuntu server
which has naturally no x-server runnig. Therefore I can not use gui related stuff.
As yorik proposed I played arround with the drawing module as well as the draft module. So far I tried to
get the svg string with Drawing.projectToSVG(...) and put it in an existing svg-file which is kind of a hack.
I tried further to use Part.export(...) but that gave me an unhandled FreeCAD exception.
Maybe you can give me a hint what's the right direction or how to achieve that. Your help is really appreciated.
- Attachments
-
- daechle.fcstd
- (7.68 KiB) Downloaded 73 times
Re: Run Freecad headless and save as svg, png
Is it possible to use Coin3d and pivy on the server? If yes, you can have a look at this: https://github.com/FreeCAD/FreeCAD_sf_m ... omation.py
-
- Posts: 395
- Joined: Fri Oct 07, 2011 8:58 pm
- Location: Beaverton,Oregon, USA
- Contact:
Re: Run Freecad headless and save as svg, png
Ok, try my branch again https://github.com/danielfalck/freecadw ... les/upload. I finally implemented a simple change that The-Fonz suggested here viewtopic.php?f=22&t=6253#p50593 related to guitree.getiterator() .
I uploaded your file to my server and it works here. I have run into errors that kill things when the FreeCAD file has objects/geometry in it that I haven't accounted for. In a few weeks, I am hoping to get some time to set up some error catching for that. Sliptonic gave me a file that kills my server that has some non- 3D objects in it.
I think that I am working towards some of the same goals as you. I will try and keep you posted on my progress.
Thanks.
I uploaded your file to my server and it works here. I have run into errors that kill things when the FreeCAD file has objects/geometry in it that I haven't accounted for. In a few weeks, I am hoping to get some time to set up some error catching for that. Sliptonic gave me a file that kills my server that has some non- 3D objects in it.
I think that I am working towards some of the same goals as you. I will try and keep you posted on my progress.
Thanks.