properly changing internal modules such Arch

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

properly changing internal modules such Arch

Post by teobo »

Hello,
(do not know if I am right, though.)
I am interested in analysing maybe modifying some modules. Already managed it to import some external modules by copying the files to ~/.FreeCAD/Mod/.

Now I am interest lets say the Arch module. How should I handle this properly?
Should I move the folder /git/freecad/src/Mod/Arch/ to ~/.FreeCAD/Mod/ and restart after modifying the sources
- or should I modify the /git/freecad/src/Mod/Arch/ directly and then recompile and restart freecad? Do I need to change something in the make settings for it?
Tia
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such as Arch

Post by teobo »

Hi,
after some trying I got something solved:
I moved the Arch folder
mv src/Mod/Arch/ /home/user/.FreeCAD/Mod/

and then after each change restarted Freecad. Would be fine if Freecad reread the sources, though.
Would it be better to test the code firstly as macros? :?
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: properly changing internal modules such Arch

Post by yorik »

Note that you don't need to move the folder, you can simply copy it. If there is a folder with the same name in .FreeCAD/Mod and /installed/path/to/FreeCAD/Mod, the first one is used and overrides the installed one.

If you plan to just play, you can do like you say (you can always compare your changes with the original one with tools liek diff), but if you plan to make more permanent changes, then you should consider using a tool like git, which helps you much to keep track of the changes you do...
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such Arch

Post by teobo »

thanks.
What would be the way to reload the code for testing let us say changes with the survey command. I did it that way,
.

Code: Select all

>>> import sys
>>> sys.path.append('~/.FreeCAD/Mod/Arch')
>>> reload(ArchCommands)
>>> Arch.survey()
proper?
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such Arch

Post by teobo »

yorik wrote:Note that you don't need to move the folder, you can simply copy it. If there is a folder with the same name in .FreeCAD/Mod and /installed/path/to/FreeCAD/Mod, the first one is used and overrides the installed one.

If you plan to just play, you can do like you say (you can always compare your changes with the original one with tools liek diff), but if you plan to make more permanent changes, then you should consider using a tool like git, which helps you much to keep track of the changes you do...
Where should I preferably put this git directory?

at .FreeCAD/Mod/
at .FreeCAD/
at .FreeCAD/Mod/Arch/
at the source tree?
at a ../Dir/Arch sym-linked to .FreeCAD/Mod/

tia
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: properly changing internal modules such Arch

Post by yorik »

It depends. If you are mainly planning things for yourself, start the git repo anywhere you like. If you are planning to do changes that you will propose for inclusion in FreeCAD (remember that there is no guarantee that you changes get accepted out of the box, okay?) then it's better to use the freecad source folder itself, so your changes are easy to merge later. You can then create a new branch, do all your work there, and keep the master branch intact so you can sync with the official freecad repo, then push your branch on a public repo like github.
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such Arch

Post by teobo »

yorik wrote: so you can sync with the official freecad repo, then push your branch on a public repo like github.
you mean a personal separate github repo? Just for interest: How gets it then "accepted" and into the official tree?
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: properly changing internal modules such Arch

Post by yorik »

Basically you put your work in a separate branch (so it can be compared with the master code), you upload that branch somewhere (github or any other), and, when you are ready, you post the link to that branch here in the "pull requests" section of the forum. Someone (Jürgen, Werner or me) will review it. If you do something small, that is easy to review, and that clearly benefits freecad, for example you fix a bug, it will be easy for us to review and we'll probably be able to merge it quickly.

If you do something bigger, and especially if you are going to modify some existing functionality, causing current users to need to change their behaviour, then it is safer to discuss your work before submitting a feature request, and let other people test your code. If people like what you have done, then there will be no problems merging it.
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such Arch

Post by teobo »

yorik wrote: and let other people test your code. If people like what you have done, then there will be no problems merging it.
How the testing is organized? Should I send a testing request of let us say a certain module to a forum? Together with installing or/and compiling instructions?
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: properly changing internal modules such Arch

Post by yorik »

Just open a new thread in the "open discussion" section, and explain what your changes do, give the link to your branch, and tell people you want feedback!
Post Reply