[solved] "All"-File management / database with text files in the directory tree for linux

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: File management / database with text files in the directory tree for linux

Post by thomas-neemann »

user1234 wrote: Tue Nov 16, 2021 8:14 pm Yes that i heard this often. Then you get an other ERP system, which can not handle this sort of "table" and so you must edit 100000+ per hand, also have seen this. This is not about the empirical datas, this is about to maintain the datas!

Greetings
user1234
i suspect that you work in an industrial environment. i work with companies with up to 50 employees and around 10-20 cad workstations
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: File management / database with text files in the directory tree for linux

Post by thomas-neemann »

here is the first part. a macro to create a data sheet

Code: Select all

import subprocess
import shlex
import FreeCAD as app
import PySide
from PySide import QtCore, QtGui
from PySide.QtGui import QLineEdit, QRadioButton
global filename


try:
    filename, filefilter = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(), 'Open An asc File', '*.FCStd')
except Exception:
    param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path
    path = param.GetString("MacroPath","") + "/"                        # macro path
    filename, filefilter = PySide.QtGui.QFileDialog.getOpenFileName(None, "asc File", path, "*.FCStd")

datei = open('/tmp/textdatei.txt','w')
datei.write(filename)
datei.close()



subprocess.call('/home/pc50/.FreeCAD/mds.sh')
FreeCAD.openDocument(filename)

/home/pc50/.FreeCAD/mds.sh


Code: Select all

#!/bin/bash
value=$(</tmp/textdatei.txt)
cp /home/pc50/.FreeCAD/vorlage.txt $value".txt"
gedit $value".txt"

https://www.youtube.com/watch?v=7q2b1WVXHyI


phpBB [video]
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
user1234
Veteran
Posts: 3347
Joined: Mon Jul 11, 2016 5:08 pm

Re: File management / database with text files in the directory tree for linux

Post by user1234 »

thomas-neemann wrote: Tue Nov 16, 2021 8:17 pm i suspect that you work in an industrial environment. i work with companies with up to 50 employees and around 10-20 cad workstations
That is not easy to answer, yes this sounds odd. Partially, so yes and no. But my former employer has the same issue and struggle with that a lot and have not more than 100 employees. The also had to change due license their system. They also said, minimum effort, because the old stuff is good (which indeed is). But they forget, that they have to maintain the datas for a good implementation in an ERP system, which can change processes over the time. And in lack of a good database, the had to make a 6 count number to edit, while there are many drawing and processes in there. Also firm in the near of me had the indent issue. So when i hear PDM and ERP system change, i hear all alarm bells ringing.

Greetings
user1234
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: File management / database with text files in the directory tree for linux

Post by thomas-neemann »

user1234 wrote: Tue Nov 16, 2021 8:58 pm
It is very easy to automate an import with text files as they are created here
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
user1234
Veteran
Posts: 3347
Joined: Mon Jul 11, 2016 5:08 pm

Re: File management / database with text files in the directory tree for linux

Post by user1234 »

Not when they have issues like not uniformed name (which can happen over the years), different datatypes, datetypes, UTF-8 vs. ISO-8859-1 vs. ASCII fields (which are not marked as any kind of type), text position swaps, different line ends, ⌀ vs. ∅ vs. Ø vs. ø vs. ⊘, ...... and that in only one type of part. In a database you have also sometimes variation, but can force at least some sort of uniformation, that when you are searching result, you get all valid results.

Greetings
user1234
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: File management / database with text files in the directory tree for linux

Post by thomas-neemann »

With this version it is possible to manage, find and edit "all" data types.
drawings, parts lists, emails pdf etc

Code: Select all

import subprocess
import shlex
import FreeCAD as app
import PySide
from PySide import QtCore, QtGui
from PySide.QtGui import QLineEdit, QRadioButton
global filename


try:
    filename, filefilter = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(), 'Open An  File', '*.*')
except Exception:
    param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path
    path = param.GetString("MacroPath","") + "/"                        # macro path
    filename, filefilter = PySide.QtGui.QFileDialog.getOpenFileName(None, " File", path, "*.*")

datei = open('/tmp/textdatei.txt','w')
datei.write(filename)
datei.close()



subprocess.call('/home/pc50/.FreeCAD/mds.sh')

mds.sh is unchanged



https://www.youtube.com/watch?v=xZkW16DLxtY


phpBB [video]
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: "All"-File management / database with text files in the directory tree for linux

Post by thomas-neemann »

here the final version with automatic $ HOME recognition.

everything in one piece with template and shell script, please copy your own configuration before use in order to restore the original state if necessary

Code: Select all

subprocess.call(os.environ['HOME']+'/.FreeCAD/mds.sh')
PunktFreeCAD2021nov17.zip
(21.81 KiB) Downloaded 27 times
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: [solved] "All"-File management / database with text files in the directory tree for linux

Post by onekk »

@thomas-neeman maybe using home like that and hardcoding ~/.FreeCAD is not what you want for "long term stability", as some changes are to be integrated

see: https://forum.freecadweb.org/viewtopic.php?f=9&t=63648

A little not complete resume:
This mainly affects Linux users where config and data files are no longer written to $HOME/.FreeCAD. Instead config files now go to $HOME/.config/FreeCAD, data files go to $HOME/.local/share/FreeCAD and temporary files go to $HOME/.cache/FreeCAD/Cache. The latter were written to /tmp in the past and thus got deleted after a reboot. So, now they will survive a reboot.
....

Ideally there is nothing to change at all if the AddonManager uses the suitable functions. These are App.getUserAppDataDir() that returns $HOME/.local/share/FreeCAD and a special function for macros App.getUserMacroDir(True).

The user is allowed to configure the macro path and that's why True should be passed to App.getUserMacroDir() to read the user setting. If you don't pass an argument or False App.getUserMacroDir() returns the default path $HOME/.FreeCAD/Macro.

The only new function is App.getUserConfigDir() that returns $HOME/.config/FreeCAD and there we store user.cfg, system.cfg and FreeCAD.conf (created by Qt's QSettings class).

It is true that current version are not affected, but this change would modify standard location in favour of the XDG system, so at a first glance all the file that are in ~/.FreeCAD will be go in ~/.config/FreeCAD and related directories.

Regards

Carlo D.
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
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: [solved] "All"-File management / database with text files in the directory tree for linux

Post by thomas-neemann »

onekk wrote: Wed Nov 17, 2021 3:53 pm

thanks for the hint, i hadn't read that. i will consider it in the future
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
onekk
Veteran
Posts: 6149
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: [solved] "All"-File management / database with text files in the directory tree for linux

Post by onekk »

Read also my question, https://forum.freecadweb.org/viewtopic. ... 41#p547541

I hope that my question will be taken in account, as thing like this could make the difference in a scenario like you reported in this post.

Regards

Carlo D.
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/
Post Reply