fcinfo utility

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

fcinfo utility

Post by yorik »

With git commit c7440ef, I added a little utility in src/Tools called fcinfo. By using it on a FreeCAD file like this:

Code: Select all

fcinfo myfile.FCStd
It prints the following text:

Code: Select all

Document: test.fcstd (73K)
   SHA1: 14e427fb29a614f39a02c99433b06d67f292e23d
   Comment : 
   Company : 
   CreatedBy : Yorik van Havre <xxx@xxx.xx>
   CreationDate : 2015-06-26T17:27:35-03:00
   FileVersion : 1
   Id : 
   Label : structure-test
   LastModifiedBy : Yorik van Havre <xxx@xxx.xx>
   LastModifiedDate : 2015-06-26T18:23:31-03:00
   License : CreativeCommons Attribution
   LicenseURL : http://creativecommons.org/licenses/by/4.0/
   ProgramVersion : 0.16R5121 (Git)
   Uid : 7d02aff3-beb6-43f4-b4cc-18fd60492fce
   Objects: (4)
       Shape : Part::Feature (342K)
       Structure : Part::FeaturePython (3K)
       Structure001 : Part::FeaturePython (3K)
       Structure002 : Part::FeaturePython (3K)
It might of course be extended, but the idea is to provide a nice readable to humans description of the contents of a freecad file, and also serve for text-based diffs. Since it inclues a hash code, you're sure to get a difference even if the contents of the file appear the same. For ex:

Code: Select all

./fcinfo test.fcstd > t1.txt && ./fcinfo test.fcstd1 > t2.txt && diff t1.txt t2.txt
which is the same file, I only pressed the "save" button, gives:

Code: Select all

1,2c1,2
< Document: test.fcstd (73K)
<    SHA1: b2ffae4562f1ebf510654af8b913414cdd33e966
---
> Document: test.fcstd1 (73K)
>    SHA1: 14e427fb29a614f39a02c99433b06d67f292e23d
11c11
<    LastModifiedDate : 2015-06-27T20:08:22-03:00
---
>    LastModifiedDate : 2015-06-26T18:23:31-03:00
This utility can also be used by git, if you manage a git repo that contains freecad files, git can use this to show you a diff between two files. This is just for viewing purpose, the files are still considered binary by git, and stored as full copies (instructions there: https://git-scm.com/book/en/v2/Customiz ... Attributes )
drei
Posts: 479
Joined: Sun May 11, 2014 7:47 pm
Location: Mexico
Contact:

Re: fcinfo utility

Post by drei »

@ yorik,
Pardon my ignorance, but how do I enable the tool after compiling FreeCAD? Did I need to add a new CMake flag or something? I went to my build directory, but there isn't a Tools folder under src.
Need help? Feel free to ask, but please read the guidelines first
wmayer
Founder
Posts: 20321
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: fcinfo utility

Post by wmayer »

Pardon my ignorance, but how do I enable the tool after compiling FreeCAD?
I haven't looked at it but it looks like it's an independent script not related at all to the FreeCAD application.
mario52
Veteran
Posts: 4699
Joined: Wed May 16, 2012 2:13 pm

Re: fcinfo utility

Post by mario52 »

hi
it is not likely to be confused with the macro FCInfo
(a suggestion why not appoint fcstdinfo )

est ce qu'il ne risque pas d'y avoir une confusion avec la macro FCInfo
(une suggestion pourquoi ne pas la nommer fcstdinfo )
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: fcinfo utility

Post by yorik »

@drei yes it's just a little independent python script. No need to compile, and it is not installed (at the moment). If you want to use it, just copy it (or link it) from the source tree to some place in your exec path. Not sure it works out of the box on windows, though, it might require some testing...

@mario good point.. Maybe we should rename it...
mario52
Veteran
Posts: 4699
Joined: Wed May 16, 2012 2:13 pm

Re: fcinfo utility

Post by mario52 »

hi
thanks
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
hmk
Posts: 159
Joined: Tue Sep 29, 2020 1:19 pm
Location: Berlin, Germany

Feature request: Support backup file extensions

Post by hmk »

I think it would be useful to also support .FCStd1, .FCStd2, ... extensions. (Perhaps at least from 1 up to 9.)

For example, this would allow to directly diff the current version with the most recent backup:

Code: Select all

diff <(fcinfo x.FCStd) <(fcinfo x.FCStd1)
(Not sure if this the right/best place for a feature request, please let me know if I should do this at a different spot.)
User avatar
Chris_G
Veteran
Posts: 2601
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: fcinfo utility

Post by Chris_G »

hmk wrote: Fri Dec 18, 2020 5:33 pm I think it would be useful to also support .FCStd1, .FCStd2, ... extensions. (Perhaps at least from 1 up to 9.)
PR submitted.
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: fcinfo utility

Post by kisolre »

This should also support the new FCBak... format.
User avatar
Chris_G
Veteran
Posts: 2601
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: fcinfo utility

Post by Chris_G »

OK, FCBak support added
Post Reply