Improved object library with preview

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
ABeton
Posts: 150
Joined: Tue Sep 03, 2019 6:39 pm

Re: Improved object library with preview

Post by ABeton »

Maybe you guys would be interested to try this out:
paullee wrote: ping
bitacovir wrote: ping
carlopav wrote: ping
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Improved object library with preview

Post by carlopav »

ABeton wrote: Wed Jun 02, 2021 8:30 am Maybe you guys would be interested to try this out
carlopav wrote: ping
Sure! Id like to try It, May I Ask you to use GIT ti create a branch or a pull request so it's easier to review your work also for yorik?
If you feel unconfortable with Git i can offer some help. I'm also an amateur and i can understand It can be unfriendly at the beginning ;-)
follow my experiments on BIM modelling for architecture design
ABeton
Posts: 150
Joined: Tue Sep 03, 2019 6:39 pm

Re: Improved object library with preview

Post by ABeton »

Yes, if you could give me some advice how to do it, it would be perfect :) I never used it before(except to dowload stuff).
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Improved object library with preview

Post by carlopav »

Sure! At first I had some problems with using GIT with the command line, so i decided t go for GitKraken, now with the help of @matthijskooijman I'm moving some first steps with commandline, and i'm loving how powerful it can be. So let's see if I did understand something and i'm able to at least put you on the track using the console!

Anyone spotting errors and mistakes, please be kind and tell me :) And also @ABeton if something looks wierd shout for help.

I assume you already have git installed on your computer and the workbench downloaded with the AddonManager, and you have also a GitHub account.

First You need to fork https://github.com/yorikvanhavre/BIM_Workbench . By git fork you create your copy of the BIM WB so you can have writing privileges on the copy and you can add to it you changes. You can do that by logging in Github and pressing the fork button (upper right part of the screen of the previous link). You will be asked where to fork, and you can choose your place (@ABeton).

Yorik repository is called upstream (even if i'm not completely sure about that name), while your repository on GitHub will be called origin. You have now privileges to modify origin, through committing your code against that repository, and you can ask yorik to include your changes in the upstream through a Pull Request.

At the moment you still do not have the code downloaded into your computer (that we will call working copy). Let's do it. Locate the place the workbench is installed (I think you know it cause you modified already the code). Make a copy of it in a safe place so you do not lose your changes, and erase the BIM Workbench, so the folder is clean.
To my small understanding GIT is basically how to deal with those 3 places where code is stored: upstream is your final target, the place where the software grows, origin is your place to store your private mess and make it visible to others (or grow more powerful than upstream :twisted: ), and your local working copy that is the place where the mess actually happens. :)

Now you need to obtain the workbench source code. You can use the command line (GitBash) or a graphical interface like GitKraken. I'll go with the command line, since I can't use it and I can take advantage and learn something while illustrating it to you.

1 CLONE the origin repo into your computer:
Open GitBash, browse to your Mod folder (ex. cd c:/Users/ABeton/AppData/Roaming/FreeCAD/Mod) and type git clone https://github.com/ABeton/BIM_Workbench. Now you will have a cloned copy of your personal BIM_Workbench! congrats!

2 enter the repo
just change to the workbench folder with cd BIM_Workbench. You will notice that a label (master) is added after the folder! type git status to check the status of your repository. git will answer On branch master. Your branch is up to date with 'origin/master'. nothing to commit, working tree clean. It basically says that your local working copy is in sync with your origin.

3 small check
try to open FreeCAD and see if you still can use the BIM Workbench. it should work ok!

4 let's start to mess up the code!
You have already noticed the (master) label. What is that? it's the main branch of your repo. Imagine a tree: you can have multiple branches where you can make different experiments on the code, and then choose which one is good to be kept and which one you will just abandon. So, not good to develop in master. Keep it clean as you can keep it in sync with upstream and do not loose the contact with the upstream tree. To make our experiment we need another branch.
git branch bim_super_library and here you have you own local branch to messing around!
you need to tell git you want to enter that branch: git checkout bim_super_library. Now check it with git status, just to be sure.

5 and now it's done, git will keep track of your changes in the bim_super_library branch.
try to change some file and check git status. It will tell you what you have modified the code. So add your changes to object library now! substitute BimLibrary.py

your changes are atm watched, but not recorded. the record process is called commit. A commit represent an atomic change that should be correctly described to be reviewed... but dont care about that now!
let's look at the commit history: git log --oneline. it's the commit history of your local working copy! press q to quit.

6 you want for sure your changes to be there!
git status will show you that you modified BimLibrary.py
you need to stage that file to allow git understand that you want to commit it. You can stage several file and then commit them together by the way. So git add BimLibrary.py, and git status again will show you that the changes are ready to be committed!
git commit and your editor will be opened, allowing you to write a commit comment. write something like "carlopav I hate you", save, close the editor.
Now git status will show you no changes again on your current workingcopy try git log --oneline:

Code: Select all

1abef0f (HEAD -> bim_super_library) carlopav I hate you
db0017f (origin/master, origin/HEAD, master) Created horizontal and vertical dimension tools
82b287b Added Leader command
etc.
Your code is committed to your local working copy!

7 push your changes to origin
Your local working copy is up to date, but noone will see the code, cause it's only in your computer.
You need to push it to origin/bim_super_library, so others can see the changes and eventually start a Pull Request to incorporate it into BIM Workbench (upstream/master). so git push and... oops, it tells you The current branch ABeton has no upstream branch.. Your bim_super_library is only in your machine, but git suggest the deal: git push --set-upstream origin bim_super_library. Login and go!

DONE!

now you can git status and git log --oneline to check everything is fine. Browse your github account in the web browser and see the changes. You could also create a Pull request directly in your browser to ask yorik to merge your changes or review them. We can at that point git checkout your branch and inspect the changes and try the code.

Of course it's a bit overwhelming for this task, but it's good if you want to keep contributing, cause it makes easier for yorik to review.
Actually it's easier to do than to explain :lol:
follow my experiments on BIM modelling for architecture design
ABeton
Posts: 150
Joined: Tue Sep 03, 2019 6:39 pm

Re: Improved object library with preview

Post by ABeton »

I think I did it :lol: I dont know if I remember anything I did, but it is done :lol: Grazie mille for this you explained it perfectly :D And this "carlopav I hate you" lol :lol: It is literaly called "bim_super_library", I just copied the code :oops: Try it out and let me know if it works.

https://github.com/Beton1/BIM_Workbench ... er_library
paullee
Veteran
Posts: 5092
Joined: Wed May 04, 2016 3:58 pm

Re: Improved object library with preview

Post by paullee »

ABeton wrote: Tue Jun 01, 2021 10:07 am To try the changes out it is necessary to put the file attached bellow, to the place where the BIM folder is and replace the existing "BimLibrary.py" file. First do a backup of course. If this i not the propper way to share and test code please let me know, because I don't know any better at the moment :? :lol:

Thanks! May have a closer look later :)

BTW, is this something relevant to earlier discussion [Discussion Features] Library of Coloured Textured Wall / Furnitures / Floor Finishes / Light ? I had one or two models there.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Improved object library with preview

Post by carlopav »

ABeton wrote: Wed Jun 02, 2021 4:41 pm It is literaly called "bim_super_library", I just copied the code :oops:
ahahahaah that made me laugh a lot!

Nice that you tried! BTW i'm still using mostly GitKraken, and I find it really intuitive. I think that it is more than enough at the beginning :)
Anyway I did a git checkout of your branch and tried it.

Very nice work. I just love to browse the list and have the documents opened for preview!
I have never looked before at the BimLibrary code, so It's hard to me to say if it's good to merge as is or not as I do not forsee any potential problems. It would be the best if yorik could say what he thinks about that.

I just can add some random thoughts to the discussion in the hope they could be of some help to you:
- does FreeCAD documents provide a kind of preview, so you can have an idea of what is inside without opening the document? I mean something like what is used to customize the file icon. I'm saying that cause it could be quite time consuming to open some documents for preview expecially with old hardware. Eventually a checkbox to disable preview could be desirable in some cases I think.
- does the link button work? It would be super useful, but it doesn't seem to produce any result. On this it could be useful to have also an "insert as a Part::Feature" (the most simple Part object, having the library element shape condensed into), and an "insert as a PartDesign::SubShapeBinder" (another super interesting object that I suggest you to checkout). Take this last point as an unnecessary improvement. :)


If you want I can leave
I left some inline comments on the code :), but take into account that i'm not a developer by education but just a dumb architect with really few spare time, except today that it's national holidays here :)
follow my experiments on BIM modelling for architecture design
ABeton
Posts: 150
Joined: Tue Sep 03, 2019 6:39 pm

Re: Improved object library with preview

Post by ABeton »

paullee wrote: Wed Jun 02, 2021 6:10 pm
ABeton wrote: Tue Jun 01, 2021 10:07 am To try the changes out it is necessary to put the file attached bellow, to the place where the BIM folder is and replace the existing "BimLibrary.py" file. First do a backup of course. If this i not the propper way to share and test code please let me know, because I don't know any better at the moment :? :lol:

Thanks! May have a closer look later :)

BTW, is this something relevant to earlier discussion [Discussion Features] Library of Coloured Textured Wall / Furnitures / Floor Finishes / Light ? I had one or two models there.
Thanks :D It is not related to that, that much, but it I am trying to do a general improvement of the library.
carlopav wrote: Wed Jun 02, 2021 7:03 pm
ABeton wrote: Wed Jun 02, 2021 4:41 pm It is literaly called "bim_super_library", I just copied the code :oops:
ahahahaah that made me laugh a lot!

Nice that you tried! BTW i'm still using mostly GitKraken, and I find it really intuitive. I think that it is more than enough at the beginning :)
Anyway I did a git checkout of your branch and tried it.

Very nice work. I just love to browse the list and have the documents opened for preview!
I have never looked before at the BimLibrary code, so It's hard to me to say if it's good to merge as is or not as I do not forsee any potential problems. It would be the best if yorik could say what he thinks about that.

I just can add some random thoughts to the discussion in the hope they could be of some help to you:
- does FreeCAD documents provide a kind of preview, so you can have an idea of what is inside without opening the document? I mean something like what is used to customize the file icon. I'm saying that cause it could be quite time consuming to open some documents for preview expecially with old hardware. Eventually a checkbox to disable preview could be desirable in some cases I think.
- does the link button work? It would be super useful, but it doesn't seem to produce any result. On this it could be useful to have also an "insert as a Part::Feature" (the most simple Part object, having the library element shape condensed into), and an "insert as a PartDesign::SubShapeBinder" (another super interesting object that I suggest you to checkout). Take this last point as an unnecessary improvement. :)


If you want I can leave
I left some inline comments on the code :), but take into account that i'm not a developer by education but just a dumb architect with really few spare time, except today that it's national holidays here :)
Hahahahhaa, that is the official name from now on :lol:

For now I just used GitBash, but I will try GitKraken next time.

I am glad that you like it, and there is quite a lot of work I need to do, and isues to adress before it could me merged. I read your comments, and I made changes to names as you said. I will check if some other names should be better as well. Also I wrote some responses in Github.

- the Library macro has the preview option, with images as you say, but for some reason it works with a very small number of models. When I finish this, I will try to figure it out. Having both preview options which you can turn on and off would be the best.

- the link does work, but it is necessary to sellect all the items you want to link. It would be good if the link worked in the same way as the "Insert" command. I am not sure about your second sugestion, because I think it would be better to have rules that dictate how the files which are added to the library organised. So that each file added to a library should already be put in the Part::Feature by it's creator. What do you think about this?

Thanks for the comment, and I guess that makes us two dumb architects on this forum :lol: Yes I know, I study in Italy hahahaha, happy Republic day :)
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Improved object library with preview

Post by carlopav »

ABeton wrote: Wed Jun 02, 2021 9:36 pm I read your comments, and I made changes to names as you said.
Good! you should commit the changes and resolve the conversations that are already handled by you :)
so... git status to check your modified files since last commit, git add to add the files to the staging area, git commit to commit them to your local tree and git push to send them to your online repository (origin/bim-super-library)!
- the Library macro has the preview option, with images as you say, but for some reason it works with a very small number of models. When I finish this, I will try to figure it out. Having both preview options which you can turn on and off would be the best.
good!
- the link does work, but it is necessary to sellect all the items you want to link. It would be good if the link worked in the same way as the "Insert" command.
yes, indeed... btw it could be worth to gather more comments from the COMMUNITY on the behavior of linking a library object (is it a link to the library object itself, could the command make a local copy in your document folder and then link it so the library stay safe, etc.).
I am not sure about your second sugestion, because I think it would be better to have rules that dictate how the files which are added to the library organised. So that each file added to a library should already be put in the Part::Feature by it's creator. What do you think about this?
Well, it's good to leave it for the moment. Anyway, since we still have to cope with a limited number of objects in the document, something that keep that number low is lot of time a desirable option :)
Thanks for the comment, and I guess that makes us two dumb architects on this forum :lol: Yes I know, I study in Italy hahahaha, happy Republic day :)
eheh, nice, where do you study? maybe we are not so far away :)

EDIT: I forgot a small suggestion: when you quote a post, do not quote the whole post, but just the sentences you are referring to, so it's easier to follow the flow :)
follow my experiments on BIM modelling for architecture design
ABeton
Posts: 150
Joined: Tue Sep 03, 2019 6:39 pm

Re: Improved object library with preview

Post by ABeton »

carlopav wrote: Thu Jun 03, 2021 5:53 pm Good! you should commit the changes and resolve the conversations that are already handled by you :)
so... git status to check your modified files since last commit, git add to add the files to the staging area, git commit to commit them to your local tree and git push to send them to your online repository (origin/bim-super-library)!
I did all that I think, you can check if it is in the repository.
yes, indeed... btw it could be worth to gather more comments from the COMMUNITY on the behavior of linking a library object (is it a link to the library object itself, could the command make a local copy in your document folder and then link it so the library stay safe, etc.).
I made changes to this, what it does now is that when you press link it first asks you to save the file("Save as") I think it is best to save the file in a folder where you are doing the project and not the library, because it would bloat the library really fast. When you save in this way, it remembers in which folder you saved last time and when you try to link consecutive times, it opens the same folder every time. If you use the "Save" option than it again saves to the library folder.

Also the "Link" command selects all the root files of a document and links them. The result is similar to "Insert" command, but the problem is that some objects can't be linked(like Groups for example).

This brings me to the next point. We should establish rules that would define how should users add their objects to the library. So for example the final object can only be a Part object, or some Arch object in case of architecture objects. These is just of the top of my head, but when we agree on all the rules, we should put them in the wiki perhaps, and when someone wants to add objects to the library, they should follow those rules.

This is also important because of the image preview that you mentioned before. The image preview works(in the Library object macro, which is another macro), but only if the users saved the thumbnail image while they were saving the file. To activate this option it is necessary to go to Edit/Preferences/General/Document and tick the "Save thumnail into project file when saving document". Also I would set the image size to 256 or even 512 so we have a good quality thumnail.

Maybe when these rules are established someone could go through the existing files in the library and adjust them to the rules(I know it is no fun do to it :lol: , but if several people split the work it can be done).
eheh, nice, where do you study? maybe we are not so far away :)
I study Industrial design in Bari, but I finished architecture before. If your location is correct I think we are on different ends of the country :lol:
EDIT: I forgot a small suggestion: when you quote a post, do not quote the whole post, but just the sentences you are referring to, so it's easier to follow the flow :)
And I think that now I have fixed my lazy quoting habits :lol:
Post Reply