Obsolete code

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Obsolete code

Post by jfc4120 »

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: English/United States (en_US)
Installed mods: 
  * Help 1.0.3
One of the things I have noticed is some of the older macros you can install does not work in the latest version of freecad

I really wish there was a lot more backwards compatibility built in.

For example an old CAD program called design CAD that I started using in 1995 and it had a language called basic CAD to write code and draw, that same code I wrote in 1995 still works in the latest version it's now taken over by a different company and called design CAD 3D Max.

I haven't purchased it but I tried the trial version.

The same with some of my old Java code. I tested some old code that I had written over a decade ago and once the Imports were changed it ran on the latest jakarta ee 9, because naturally imports needed updated, but the code worked.

So please pass on to the maintainers to put in backwards compatibility as much as possible.

There are a few macros that I would love to use but not compatible.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Obsolete code

Post by TheMarkster »

Much of the incompatibility is related to python 2 versus python 3 and qt4 versus qt5, which FreeCAD can't control.
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Obsolete code

Post by heda »

jfc4120 wrote: Sat Jul 23, 2022 5:47 pm So please pass on to the maintainers to put in backwards compatibility as much as possible.
you do realize that the whole of fc is made by individuals in their spare time (for no monetary gain)?
the so called maintainers are just people that for themselves decide to spend some time to try to put fc in a better place (and let other use this for free)
without some of the core dependencies (as in libraries that fc just uses and needs to keep up to date with), like occ-kernel, qt and others - there would not be any fc at all... making a parametric cad from ground up is just too many manhours.

so...
you can fairly easily become one the maintainers and become self-sufficient enough to scratch your own itches
(which is btw part of the reason you get help in the forum, so that maybe you decide to stick around and hopefully at some point in time pitch into the quest of making fc better).

to fix some py-code here and there is not the hardest thing, preferably those fixes are made permanent (by the one fixing them), so that others can benefit from it as well...

if you for example search the web for the transition from py2 to py3, there is a plethora of write-ups on it - it almost killed python as a language, but in the end it did not. one can only speculate in why, that it is an easy language to handle, and is versatile in where and how it can be used probably has something to do with it (i.e. people want to use it even if it is throwing some curved balls at times, simply because when all comes around, it is often easier to make something happen in python compared to most other languages out there).

final note, one has to break some eggs to make an omelette - so keeping bad choices around for decades just because of backward compat, well - it kind of hampers progress, does it not? sure, one should make transitions as easy as possible - but a strict backward compat is not a good thing (imho).
galou_breizh
Posts: 436
Joined: Wed Sep 15, 2010 9:38 am

Re: Obsolete code

Post by galou_breizh »

In addition to what heda wisely wrote and as a maintainer of the macro repository I invite you to write issues on Github to report about this, so that we can be aware of the compatibility problems.

Moreover, you can normally always comeback to an older version of FreeCAD (with probably a lot of efforts though) and this is not something that a proprietary software will ever offer to you.

So jfc4120, please report and be more precise than "some of the older macros you can install does not work".

Gaël
User avatar
chennes
Veteran
Posts: 3881
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Obsolete code

Post by chennes »

Also, FreeCAD does provide some important backwards compatibility code for things like importing PySide (macros can use “import PySide” instead of “import PySide2” for example and FreeCAD will load the right one for how it was compiled), but authors have to actually use those compatibility layers. If you just use “import PySide2” then when we compile against Qt6, there is nothing FreeCAD can do to make it work.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Obsolete code

Post by Roy_043 »

I know about PySide -> PySide2, but was unaware that PySide2 should not be used. Are you saying that FreeCAD will handle the PySide -> PySide6 'conversion', but not the PySide2 -> PySide6 'conversion'?

PySide2 is used in the FreeCAD source code though (including the AddonManager code ;) ).
User avatar
chennes
Veteran
Posts: 3881
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Obsolete code

Post by chennes »

Roy_043 wrote: Thu Nov 10, 2022 2:43 pm (including the AddonManager code ;) ).
Not anymore :D git commit b40733247

And yes, right now if you do something like

Code: Select all

from PySide import QtCore
That will work in both Qt5 and Qt6 because we are providing a compatibility layer (I believe that layer dates back to the last PySide transition, actually -- I added to it in the Qt6 support code, but the QtCore, QtGui, and QtWidgets imports already existed). We have not added a direct compatibility layer from PySide2->PySide6, but really I don't think there is any reason why we couldn't use the same technique to do that as well.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Obsolete code

Post by Roy_043 »

chennes wrote: Thu Nov 10, 2022 3:21 pmNot anymore
You've missed a couple:

Code: Select all

AddonManager/AddonManagerTest/gui/test_workers_installation.py
AddonManager/AddonManagerTest/gui/test_workers_startup.py
AddonManager/AddonManagerTest/gui/test_workers_utility.py
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Obsolete code

Post by onekk »

chennes wrote: Thu Nov 10, 2022 3:21 pm ...
We have not added a direct compatibility layer from PySide2->PySide6, but really I don't think there is any reason why we couldn't use the same technique to do that as well.
PySide2 (Qt5) and PySide6 (Qt6) have so much differences?

Damn I use most of my code using directly PySide2 calls as it is more easy to follow code that you find around. :oops:
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
chennes
Veteran
Posts: 3881
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Obsolete code

Post by chennes »

onekk wrote: Thu Nov 10, 2022 4:42 pm PySide2 (Qt5) and PySide6 (Qt6) have so much differences?
No: the opposite. They are so similar that in many cases the only change that would be needed is to change

Code: Select all

from PySide2 import Whatever
to

Code: Select all

from PySide6 import Whatever
So FreeCAD provides the ability to just use “PySide” and the correct version will be used depending on how FreeCAD was compiled.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply