import FreeCAD disables output globally?

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: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: import FreeCAD disables output globally?

Post by wmayer »

I have tested it with the current developer version, not with 0.19. I will have a look...
I can confirm that in 0.19 it doesn't work because the "Console" observer is not instantiated when loading FreeCAD as Python module. This once was fixed with git commit 377b01b4b4ab. So, the minimum version you need is 0.20
0xCoto
Posts: 26
Joined: Wed Aug 10, 2022 3:56 pm

Re: import FreeCAD disables output globally?

Post by 0xCoto »

wmayer wrote: Fri Dec 09, 2022 10:47 am
I have tested it with the current developer version, not with 0.19. I will have a look...
I can confirm that in 0.19 it doesn't work because the "Console" observer is not instantiated when loading FreeCAD as Python module. This once was fixed with git commit 377b01b4b4ab. So, the minimum version you need is 0.20
That fixed it, thanks a lot! The only thing that doesn't appear to be reset is the text color. This isn't a dealbreaker, but if you have an idea to reset that to Python's default, that would be fantastic! :D
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: import FreeCAD disables output globally?

Post by wmayer »

0xCoto wrote: Fri Dec 09, 2022 1:11 pm This isn't a dealbreaker, but if you have an idea to reset that to Python's default, that would be fantastic!
Look here: https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L811
whenever printing a log message, warning or error message a special escape sequence is sent before and after the message. So, all what you have to do is disabling them in line 811, 821, 832, 842, 853 and 863.
0xCoto
Posts: 26
Joined: Wed Aug 10, 2022 3:56 pm

Re: import FreeCAD disables output globally?

Post by 0xCoto »

wmayer wrote: Fri Dec 09, 2022 4:04 pm So, all what you have to do is disabling them in line 811, 821, 832, 842, 853 and 863.
Would that mean that I'd have to intervene and make changes to the source code, or can I configure this "separately" in Python?
wmayer
Founder
Posts: 20302
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: import FreeCAD disables output globally?

Post by wmayer »

0xCoto wrote: Sat Dec 10, 2022 4:53 am Would that mean that I'd have to intervene and make changes to the source code, or can I configure this "separately" in Python?
You have to change the C++ code and rebuild the binaries.
Post Reply