I don't know if I understand correctly. if it comes to e.g. to eliminate chaos after unintentional file shifts, you only need to write a script which moves fcstd and txt files of the same name back into a common directory.
[solved] "All"-File management / database with text files in the directory tree for linux
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- thomas-neemann
- Veteran
- Posts: 11921
- 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
Last edited by thomas-neemann on Tue Nov 16, 2021 7:09 pm, edited 1 time in total.
Re: File management / database with text files in the directory tree for linux
No it is different thing, you could do many things.
You could have in the Gui a button that will "zip the directory" and put the zip into a predetemined position, as you could issue shell commands.
All without touching anything on the FCStd files that are containing parts.
This way you could even have a sqlite3 dump object that could be used to hold all the "relations between files".
It's up to you to make all things, using python.
A sort of "Customized way to do things".
I usually have a minimal Gui that show up, like:
That will load the ini file containing the information about the thing I want to make.
and in this case:
Hope to have been clear.
Carlo D.
- you load an ipotetic
it opens in the "macro editor" and you could launch it with the "big green arrow"project.py - It show up a "Gui window" on which you could choose what you want, one options could be "load project files"
- project files could be loaded using some other data stored in the "project.py" that is a readable python source code file
You could have in the Gui a button that will "zip the directory" and put the zip into a predetemined position, as you could issue shell commands.
All without touching anything on the FCStd files that are containing parts.
This way you could even have a sqlite3 dump object that could be used to hold all the "relations between files".
It's up to you to make all things, using python.
A sort of "Customized way to do things".
I usually have a minimal Gui that show up, like:
That will load the ini file containing the information about the thing I want to make.
and in this case:
- It will create the model
- if there is the appropriate flag in the ini file it will create also:
- Draft Files to be modified maybe to add some holes or similar things
- automatically make Draft Files and export them to DXF to be fed to a CAM program that will produce code to cu the parts on a CNC machine
Hope to have been clear.
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/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- thomas-neemann
- Veteran
- Posts: 11921
- 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
i have great respect for the work of jriegel wmayer yorik and all the other programmers. i don't want to cause you any more work or create new problems, so i try shell scripts and shell tools. i have been working with shell since the 80s. i'm just starting with python. make my first attempts at walking.
Re: File management / database with text files in the directory tree for linux
No problem at all, I'm not a developer in strict sense, only a "importune" that sometimes will make some post and sometimes will "reach the target", maybe suggesting some thing to more skilled developers. (Only for this reason I'm on FreeCAD Credits page).
Said so, if you want some code to test, let me know?
I could put together some code with a "simple Gui", and some button to test "the way" of doing things I have illustrated.
And maybe with some "concrete code" here discussion will be more "constructive", but I think that it has already been "constructive".
At the very end I usually try to make things works, without asking too much, a part of asking for clarification about some internals to skilled developers.
Regards
Carlo D.
Said so, if you want some code to test, let me know?
I could put together some code with a "simple Gui", and some button to test "the way" of doing things I have illustrated.
And maybe with some "concrete code" here discussion will be more "constructive", but I think that it has already been "constructive".
At the very end I usually try to make things works, without asking too much, a part of asking for clarification about some internals to skilled developers.
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/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: File management / database with text files in the directory tree for linux
Simple test code:
It will create a persistent window from which you could control something, there is only a button that will create a new empty file and write in the Log Tab a simple phrase.
execution code is in
it is not doing what the name is telling, as I've reused code from one existing project making minimal changes, but this will show you a way of doing things.
place maybe the code in a text file named "project.py" and place in a directory.
Regards
Carlo D.
Code: Select all
"""test-gui.py
Copyright 2021 Carlo Dormeletti
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
"""
import os
import sys
from datetime import datetime
import FreeCAD
from FreeCAD import Placement, Rotation, Vector
import Draft
import Part
import math
from PySide import QtGui, QtCore
from functools import partial
DOC_NAME = "test_gui"
HOME = u"/home/carlo"
DOC = FreeCAD.activeDocument()
def clear_doc(doc_name):
"""
Clear the document deleting all the objects
"""
doc = FreeCAD.getDocument(doc_name)
doc.recompute()
objects = doc.Objects
for obj in objects:
# debug info do not delete
#print("Tipo : {}".format(obj.TypeId))
# fake if when i find what is causing the failure
if obj.TypeId in ("App::"):
pass
else:
doc.removeObject(obj.Name)
def ensure_document(doc_name, action = 0):
"""Ensure existence of document with doc_name and clear the doc
Returns:
string Document name from obj.Name
Parameters:
doc_name string document name
action integer clear action if document exist
0: close and reopen the document with the same name
1: delete all objects
"""
doc_root = FreeCAD.listDocuments()
doc_exist = False
for d_name, doc in doc_root.items():
# debug info do not delete
print("ED: doc name = {}".format(d_name))
if d_name == doc_name:
print("Match name")
if action == 0:
# when using clear_doc() is not possible like in Part.Design
FreeCAD.closeDocument(doc_name)
doc_exist = False
else:
doc_exist = True
clear_doc(doc_name)
FreeCAD.setActiveDocument(d_name)
if doc_exist == False:
# debug info do not delete
#print("ED: Create = {}".format(doc_name))
FreeCAD.newDocument(doc_name)
return FreeCAD.activeDocument().Name
def setview(doc_name, t_v = 0):
FreeCAD.setActiveDocument(doc_name)
VIEW = FreeCAD.Gui.ActiveDocument.ActiveView
if t_v == 0:
VIEW.viewTop()
else:
VIEW.viewAxometric()
VIEW.setAxisCross(True)
VIEW.fitAll()
class main_dia(QtGui.QDialog):
"""Create Main window input box
"""
if_fields = ()
tab_names = (
('Main', 'mn'), ("Log", "lg"))
ap_style = "font-size: 14px"
tx_style = "font-size: 16px"
# needed to not trow error prior to push validate button,
# dictionary is totally overwritten by validate_data
vals = {'validate': ["KO"]}
config = None
base_name = ""
action = ""
main_doc = None
def __init__(self):
super(main_dia, self).__init__()
now = datetime.now()
run_time = now.strftime("%y-%m-%d-%H-%M")
self.base_name = "test_gui_" + run_time
self.initUI()
def initUI(self):
self.result = ""
# create our window
sc_wid = QtGui.QDesktopWidget().screenGeometry().width()
sc_hei = QtGui.QDesktopWidget().screenGeometry().height()
# get dimensions for available space on screen
av_wid = QtGui.QDesktopWidget().availableGeometry().width()
av_hei = QtGui.QDesktopWidget().availableGeometry().height()
w_wid = av_wid * 0.33
w_hei = av_hei * 0.60
x_loc = (sc_wid - w_wid) * 0.5
y_loc = (sc_hei - w_hei) * 0.5
# define window xLoc,yLoc,xDim,yDim
self.setGeometry(x_loc, y_loc, w_wid, w_hei)
self.setWindowTitle("Test Gui main Window")
self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
self.lay = QtGui.QVBoxLayout(self)
self.tabw = QtGui.QTabWidget(self)
for tab_o in self.tab_names:
tab = QtGui.QWidget()
tab.setObjectName('t_' + tab_o[1])
lay = QtGui.QGridLayout(tab)
lay.setObjectName(tab_o[1])
self.tabw.addTab(tab, tab_o[0])
wid = self.tabw.findChild(QtCore.QObject, "mn")
self.Btn_acp = QtGui.QPushButton('Load ', self)
self.Btn_acp.clicked.connect(self.load_file)
self.Btn_acp.setAutoDefault(False)
wid.addWidget(self.Btn_acp, 1, 0)
self.txt_win = QtGui.QTextEdit()
self.txt_win.setStyleSheet(self.tx_style)
self.txt_win.setReadOnly(True)
self.txt_win.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)
wid = self.tabw.findChild(QtCore.QObject, "lg")
wid.addWidget(self.txt_win, 0, 0)
self.lay.addWidget(self.tabw)
self.setLayout(self.lay)
self.show()
def load_file(self):
ensure_document(DOC_NAME)
Lmsg = (("file {} created".format(DOC_NAME),))
self.write_log(Lmsg)
def closeEvent(self, event):
event.accept()
def write_log(self, Lmsg):
self.txt_win.clear()
out_msg = "\n".join(Lmsg)
self.txt_win.setText(out_msg)
if __name__ == "__main__":
main_f = main_dia()
main_f.show()
execution code is in
and his very simple.load_file()
Code: Select all
def load_file(self):
ensure_document(DOC_NAME)
Lmsg = (("file {} created".format(DOC_NAME),))
self.write_log(Lmsg)
place maybe the code in a text file named "project.py" and place in a directory.
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/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: File management / database with text files in the directory tree for linux
True. But sqlite will not handle the amount CAD files. If you only took screws from
- size: M4 - M30
- lenght
- material from 8.8, 10.9, 12.9, A2-50, A2-70, A4-50, A4-70, C1-50, .....
- surface treatment: A2F, PHR, tzn
- head and drive: ISO4014, ISO4017, ISO4762, ISO7984, ISO10642, ....
then you will get many many screws. If you want to make a database, then all parts must be separated. To think, that you can load only one screw and adapt this with a table in the screw, will not work in real life, since you will send a BoM to an ERP system, which need all parts separated. And when you can configure it in a table, then often in the background a new screw will be loaded or generated. And now think about nuts, washers, bearings, taper pins, ......
At least you can do it like Tryton and make it open, which databasesystem you use. Tryton is able to use sqlite, postgresql and a third one, which can not find it the docs at the moment (i think it was mysql).
I mean internal sabotage, the reason why you need logs (also have seen this recently). Also someone can accidentally make parts of the text files invalid. Also then you will need logs.thomas-neemann wrote: ↑Tue Nov 16, 2021 4:21 pm I have been able to secure some companies to the intrnet, but I think it is impossible to secure a company internally. that can only be based on trust. in my opinion
Greetings
user1234
- thomas-neemann
- Veteran
- Posts: 11921
- 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
my customers create data backups for accidental damage
Re: File management / database with text files in the directory tree for linux
And you know, all parts the person edited in the session? Without logs it will be pure guessing. Also a backup can only save and actual state, which means while someone edited parts false, 100 other people have done all correct. With a backup you will delete all work from the others, when you do not know the diffs. So you need the logs to correct only the faulty one.
Greetings
user1234
Greetings
user1234
- thomas-neemann
- Veteran
- Posts: 11921
- 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
they are empirical values from over 30 years. as soon as this turns out to be no longer usable, you can upgrade
Re: File management / database with text files in the directory tree for linux
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
Greetings
user1234