Take pictures from python without using GUI

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Take pictures from python without using GIU

Post by wmayer »

Thanks for the description. The point is not related to Python but to the fact that you run it inside a batch file. To close the terminal you have to add "exit" at the end of the .bat file.
ignacio
Posts: 17
Joined: Fri Mar 11, 2016 9:36 am

Re: Take pictures from python without using GIU

Post by ignacio »

Hello wmayer,
thanks.
but it does not work.
Sometihg like this in the bat file
"C:\Progra~1\FreeCAD_0_16\bin\python two_holes_part_with_photo.py
echo "ok"
exit"
does not even return the echo display.
Regards,
Ignacio.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Take pictures from python without using GIU

Post by wmayer »

Can you post your .py file and your .bat, please? If it contains some secret information then replace them with some standard stuff.
ignacio
Posts: 17
Joined: Fri Mar 11, 2016 9:36 am

Re: Take pictures from python without using GIU

Post by ignacio »

Hello wmayer,
thanks for your reply.

Even with the first code you posted I have the same problem
I Have uploaded the two files. I have changed the extension to txt because I can't upload files with extension .py or bat.

wmayer.txt rename to --> wmayer.py contains the first code you posted.
freecad_wmayer.txt rename to -->freecad_wmayer.bat is the .bat I use to execute. Although executing inside pycharm (no .bat needed) it happens the same.
freecad_wmayer.txt
rename extension to .bat
(89 Bytes) Downloaded 90 times
wmayer.txt
rename extension to .py
(662 Bytes) Downloaded 93 times
Thanks.
Regards,
Ignacio.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Take pictures from python without using GIU

Post by wmayer »

No, idea why it doesn't work for you.

When I open a terminal (cmd.exe) and add the "exit" statement at the end of freecad_wmayer.bat then the terminal will be closed.
When I double-click on the freecad_wmayer.bat then I don't need the "exit" because the appearing terminal closes itself.

So maybe adding this at the end of the .py file solves it:

Code: Select all

import os
os.system("tskill python.exe")
ignacio
Posts: 17
Joined: Fri Mar 11, 2016 9:36 am

Re: Take pictures from python without using GIU

Post by ignacio »

Hello wmayer,
ok, I will test on monday at work ( at home I only have ubuntu)
By the way, where is the python interpreter located at ubuntu? Using PyCharm for developing python code I have to select a python interpreter and I want to use the freeCAD one. I also want to test the parameters modification from ubuntu.

Thanks for your interest in this issue. I really appreciate it.
Regards,
Ignacio.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Take pictures from python without using GIU

Post by wmayer »

By the way, where is the python interpreter located at ubuntu?
/usr/bin/python
ignacio
Posts: 17
Joined: Fri Mar 11, 2016 9:36 am

Re: Take pictures from python without using GIU

Post by ignacio »

Hello,
I have tested it in another machine and in a laptop (both also with windows 7) and it works!!...so its something related to the configuration of my machine.
Anyway, the first time I executed in the laptop I got a python .exe error. Then a window appeared saying something like "windows has detected that a program has not worked properly. Some settings were applied in order to solve the problem". I don't know what type of settings were applied, but now there is no error in the executions in the laptop...

All three computers has the same corporative configuration, although in my machine I have many more things installed (including several python versions...)

If I comment the line mw.hide() of wmeyer.py In my machine the python get stuck in the freecad window, while in the laptop and in the other machine the freecad window opens and close. I have try to close it in my machine with mw.close(), mw.deleteLater() but still the python get sutck (it seems that FreeCAD.closeDocument(doc.Name) does not close the document)
Do you know if is there any setting that I can modify or somehting that could be changing the behavieur of freecad ?
thanks.
Regards,
Ignacio.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Take pictures from python without using GIU

Post by wmayer »

Do you know if is there any setting that I can modify or somehting that could be changing the behavieur of freecad ?
Sorry, but I don't know what else you could look for.
ignacio
Posts: 17
Joined: Fri Mar 11, 2016 9:36 am

Re: Take pictures from python without using GIU

Post by ignacio »

ok. Anyway thanks a lot for your support and for FreeCAD :D
Post Reply