1 (edited by unalcalde 2016-08-13 17:17:07)

Topic: Terminal block generator cross-platform

Hi, I finished a python program to make terminal block based on the previous bash script. I think it works well and fast. I've only tested it on linux, maybe some changes are needed to work in windows.

This version drwa a libe (bridge) between near terminals with same cable numbers.

If someone can test and improve it will be good for QElectroTech users !!


(sorry for my english)
http://i65.tinypic.com/11rxla8.jpg

Post's attachments

Attachment icon QET_TB_maker.py 12.34 kb, 1361 downloads since 2016-08-13 

Re: Terminal block generator cross-platform

Great, I will test it on linuxmint !

3 (edited by galexis 2016-08-13 18:07:49)

Re: Terminal block generator cross-platform

What line command need to write on terminal ? How choose project ?

4 (edited by unalcalde 2016-08-13 19:27:23)

Re: Terminal block generator cross-platform

Hi, edit the QET_TB_maker.py and write the path where are your QET collection in the line started by USER_COLLECTION_PATH. Normaly will be something like "/home/<you user name here>/.qet/elements/<folder where terminals blocks will save>/". Don't forget to write de last / symbol !!

Later at the command line write:
python QET_TB_maker.py <your QET schematic.qet>

You need python 3. When finish, reload the library in QET and appears at the bottom the terminals blocks created.

When you run the program print on screen some usefull info.

This is a first version. Later we autodetect collection qet folder and more details to do it more usefull.

5 (edited by galexis 2016-08-13 21:51:15)

Re: Terminal block generator cross-platform

Ok, it's work Important: folder need to exist before execute script. Wonderfuls elements !

Label of terminal don't respect minuscule letter : for example : label "Vbox " become "VBOX" (all in capital)

The script don't add missing terminals like reserve. See next post ...

Post's attachments

Capture du 2016-08-13 20-49-08.png, 18.46 kb, 492 x 315
Capture du 2016-08-13 20-49-08.png 18.46 kb, 691 downloads since 2016-08-13 

6 (edited by galexis 2016-08-13 20:57:36)

Re: Terminal block generator cross-platform

Terminals reserve : image

It's not possible to have gui to select project ?

Post's attachments

Capture du 2016-08-13 20-56-16.png, 34.76 kb, 602 x 534
Capture du 2016-08-13 20-56-16.png 34.76 kb, 794 downloads since 2016-08-13 

Re: Terminal block generator cross-platform

Good job Unalcalde !

8 (edited by unalcalde 2016-08-13 21:14:24)

Re: Terminal block generator cross-platform

Thanks !!.

I made a To Do list. When it have enough things to fix,  I'll do.

About reserve of terminal: the terminals could have numeric or no numeric label: X1:3, X2:R1, X2:S1,... The program place first no numeric terminals and later numeric terminals. So I don't know if reserve of terminals it's a good idea.

Maybe we can place alphanumeric terminals, and when start the numeric terminals I can make reserve if no consecutive numbers.

Please, you check too terminals with the same name, and test I bridge line is ok.

If you schema have diferent terminal blocks names ( X1:1, X2:4,...) it will create differents terminal blocks for every one.

At the start of the program you can specify whats the max length for a terminal block. If it's longer, generates various elements to put in differents folios.

Re: Terminal block generator cross-platform

unalcalde wrote:

Please, you check too terminals with the same name, and test I bridge line is ok.

If you schema have diferent terminal blocks names ( X1:1, X2:4,...) it will create differents terminal blocks for every one.

At the start of the program you can specify whats the max length for a terminal block. If it's longer, generates various elements to put in differents folios.

All this 3 points work fine.

10 (edited by galexis 2016-08-13 21:53:05)

Re: Terminal block generator cross-platform

This script python use "id" of folio but not "folio".
On the last version of script, we can choose between two system of numbering....
https://qelectrotech.org/forum/viewtopi … 4837#p4837

11 (edited by galexis 2016-08-13 21:50:30)

Re: Terminal block generator cross-platform

About Xref: I have some problem with column. I think there is problem with calcul and round.
Exemple with XA:14

Post's attachments

Capture du 2016-08-13 21-49-45.png, 9.83 kb, 129 x 656
Capture du 2016-08-13 21-49-45.png 9.83 kb, 646 downloads since 2016-08-13 

Re: Terminal block generator cross-platform

unalcalde wrote:

Hi, edit the QET_TB_maker.py and write the path where are your QET collection in the line started by USER_COLLECTION_PATH. Normaly will be something like "/home/<you user name here>/.qet/elements/<folder where terminals blocks will save>/". Don't forget to write de last / symbol !!

Hello Unalcalde,

on UNIX System you could change your command line in the script "/home/<you user name here>/.qet/elements/"

by


~/.qet/elements/


On MS Windows, with installer is located in c:\users\user_name\AppData\Roaming\qet\elements.
To try :


%USERPROFILE%\AppData\Roaming\qet\elements\

Or

%APPDATA%\qet\elements\

With the ReadyToUse version is located on the folder  "conf\elements\" where ReadyToUse is (USB drive or other) .

http://stackoverflow.com/questions/1854 … -in-python
http://stackoverflow.com/questions/4719 … ning-under

Laurent

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Terminal block generator cross-platform

For Gnu/linux add home user path to qet element and create temp_tb folder if isn't exist.




--- QET_TB_maker.py    2016-08-14 16:02:26.208878660 +0200
+++ QET_TB_maker.py    2016-08-14 18:31:58.000000000 +0200
@@ -8,7 +8,11 @@
 import xml.etree.ElementTree as etree
 
 ########## GLOBAL CONSTANTS
-USER_COLLECTION_PATH="/home/raul/.qet/elements/temp_tb/" #path to create terminal blocks elements
+
+USER_COLLECTION_PATH= os.environ['HOME'] + '/.qet/elements/temp_tb/' #path to create terminal blocks elements
+if not os.path.exists(USER_COLLECTION_PATH):
+    os.makedirs(USER_COLLECTION_PATH)
+
 TB_BLOCKS_IN_A_FOLIO = 50
 TB_HEAD_WIDTH = 40
 TB_HEAD_UNION_HEIGHT = 45



For MS Windows :
http://stackoverflow.com/questions/2176 … ory-python

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

14 (edited by unalcalde 2016-08-15 08:15:33)

Re: Terminal block generator cross-platform

Hi, I introduce the version 0.2. Change log:

- Now is not necessary to run with the QET project file path as argument. It can run directly. The program autodetect the path of QET collection dependig the OS, but ask for the path if is not correct. If the past is correct, only a Enter is needed.

- Saves recent proyects used at 'recent.his' file for easy selection of the lastest projects and print on screen. By default, pressing Enter uses the last project, but you can enter a number of the list of type once a new project. I thought to access to the QET database for this purpose, but it implies the install dependencies to python default instalation.

- Creates the collection temp directory for terminal blocks if not exist.

- Now respect case. Be careful, now becasue 'X1' is different than 'x1' and will make 2 different Terminal Blocks.

- The form of then name in collection for the element created is : Project X1(<from_teminal>-<to terminal>). It's easy to select the correct if have a lot.

- Fix XRef calc. The problem was that the grid top and left labels are 25px width. I considered this size to calc XRef.

Post's attachments

Attachment icon QET_TB_maker_v0.2.py 16.48 kb, 750 downloads since 2016-08-15 

Re: Terminal block generator cross-platform

Thank you Unalcalde,

you could send a example project for try or debug?


laurent@Toshiba:~/Documents$ python3 QET_TB_maker_v0.2.py 12.qet  
 
 
<< Terminal Block maker for QET 0.2 - by Raul Roda >>
 
 
 
Remember the next conditions:
 
 * Terminal elements must be 'terminal' as type in the Element Editor.
 
 * If terminal elements has more than one textfield, the first one is considered.
 
 * Name of terminals must be in form 'x:a'.  x = Terminal Block name; a = Terminal name.
 
 
 
Path to place created QET Terminal Blocks  [/home/laurent/.qet/elements/temp_tb/]:  
 
 
Select recent project number or type full path  []:  
 
 
Calculating...
 
Traceback (most recent call last):
 
 File "QET_TB_maker_v0.2.py", line 386, in <module>
 
   qet_tree = etree.parse(sQETProjectFile)   
 File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 1184, in parse
 
   tree.parse(source, parser)
 
 File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 585, in parse
 
   source = open(source, "rb")
 
FileNotFoundError: [Errno 2] No such file or directory: ''

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Terminal block generator cross-platform

I have this error :

python ./Téléchargements/QET_TB_maker_v0.2.py ./Bureau/Projet_chateau_d_eau-v3.qet

<< Terminal Block maker for QET 0.2 - by Raul Roda >>

Remember the next conditions:
  * Terminal elements must be 'terminal' as type in the Element Editor.
  * If terminal elements has more than one textfield, the first one is considered.
  * Name of terminals must be in form 'x:a'.  x = Terminal Block name; a = Terminal name.

Path to place created QET Terminal Blocks  [/home/alexis/.qet/elements/temp_tb/]:
Traceback (most recent call last):
  File "./Téléchargements/QET_TB_maker_v0.2.py", line 365, in <module>
    sTBCollectionPath = getUserInput ('Path to place created QET Terminal Blocks ', QETDataPath() )
  File "./Téléchargements/QET_TB_maker_v0.2.py", line 307, in getUserInput
    sInput = input ( sMessage + ' [' + sDefaulInput + ']: ' )
  File "<string>", line 0
   
    ^
SyntaxError: unexpected EOF while parsing

Re: Terminal block generator cross-platform

@Galexis python3 !

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Terminal block generator cross-platform

The first script work with python (not python3).

return:

python3 ./Téléchargements/QET_TB_maker_v0.2.py ./Bureau/Projet_chateau_d_eau-v3.qet

<< Terminal Block maker for QET 0.2 - by Raul Roda >>

Remember the next conditions:
  * Terminal elements must be 'terminal' as type in the Element Editor.
  * If terminal elements has more than one textfield, the first one is considered.
  * Name of terminals must be in form 'x:a'.  x = Terminal Block name; a = Terminal name.

Path to place created QET Terminal Blocks  [/home/alexis/.qet/elements/temp_tb/]:

Select recent project number or type full path  []:

Calculating...
Traceback (most recent call last):
  File "./Téléchargements/QET_TB_maker_v0.2.py", line 386, in <module>
    qet_tree = etree.parse(sQETProjectFile) 
  File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 1184, in parse
    tree.parse(source, parser)
  File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 585, in parse
    source = open(source, "rb")
FileNotFoundError: [Errno 2] No such file or directory: ''

Re: Terminal block generator cross-platform

laurent@Toshiba:~/Documents$ python3 QET_TB_maker_v0.2.py

<< Terminal Block maker for QET 0.2 - by Raul Roda >>

Remember the next conditions:
 * Terminal elements must be 'terminal' as type in the Element Editor.
 * If terminal elements has more than one textfield, the first one is considered.
 * Name of terminals must be in form 'x:a'.  x = Terminal Block name; a = Terminal name.

Path to place created QET Terminal Blocks  [/home/laurent/.qet/elements/temp_tb/]:  

Select recent project number or type full path  []: /home/laurent/Documents/12.qet

Calculating...


Done.

laurent@Toshiba:~/Documents$

But temp_tb folder is empty

@Galexis : t'as un mini projet à envoyer pour tester?

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

20 (edited by galexis 2016-08-15 16:24:08)

Re: Terminal block generator cross-platform

Ok, it's work.

python3 ./Bureau/QET_TB_maker.py ./Bureau/Projet_chateau_d_eau-v3.qet
  File "./Bureau/QET_TB_maker.py", line 286
    print ("\n<< fichier QET " + name + " - alexis >>\n")
                                                        ^
TabError: inconsistent use of tabs and spaces in indentation
alexis@alexis-SATELLITE-L70-C-14E ~ $ python3 ./Téléchargements/QET_TB_maker_v0.2.py

<< Terminal Block maker for QET 0.2 - by Raul Roda >>

Remember the next conditions:
  * Terminal elements must be 'terminal' as type in the Element Editor.
  * If terminal elements has more than one textfield, the first one is considered.
  * Name of terminals must be in form 'x:a'.  x = Terminal Block name; a = Terminal name.

Path to place created QET Terminal Blocks  [/home/alexis/.qet/elements/temp_tb/]:

Select recent project number or type full path  []: ./Bureau/Projet_chateau_d_eau-v3.qet            

Calculating...

Done.

You need to write manually project adress.

21 (edited by galexis 2016-08-15 17:09:21)

Re: Terminal block generator cross-platform

I propose to you somme modfication to have GUI to choose project file.
You have to install python3-tk and use commande or launcher :

python3 adress_script.py

Post's attachments

Attachment icon QET_TB_maker_v0.2.py 16.27 kb, 677 downloads since 2016-08-15 

Re: Terminal block generator cross-platform

galexis wrote:

I propose to you somme modfication to have GUI to choose project file.
You have to install python3-tk and use commande or launcher :

python3 adress_script.py

python3 path to your QET_TB_maker_v0.2.py


Traceback (most recent call last):
 File "QET_TB_maker_v0.2.py", line 375, in <module>
   sQETProjectFile = askopenfilename(title="Choose QET project",filetypes=[('qet files','.qet'),('all files','.*')])
 File "/usr/lib/python3.5/tkinter/filedialog.py", line 375, in askopenfilename
   return Open(**options).show()
 File "/usr/lib/python3.5/tkinter/commondialog.py", line 48, in show
   s = w.tk.call(self.command, *w._options(self.options))
_tkinter.TclError: can't invoke "grab" command: application has been destroyed


Windows tk is empty.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Terminal block generator cross-platform

With full graphical interface for element directory and project (last project used).

Post's attachments

Attachment icon QET_TB_maker_v0.2.py 16.74 kb, 697 downloads since 2016-08-15 

24 (edited by unalcalde 2016-08-15 19:16:08)

Re: Terminal block generator cross-platform

Hi, 
From python IDE works for me, but in the terminal raise the same error that you. I've checked and the problem is the version of python.

Try with: python3 QET_TB_maker_v0.2.py.


Galexis, GUI for select  projects is a good idea, but I thinks there are 2 problems:
 - maybe not everyone have all dependencies
 - is slower than press a number. The first time you use a new project make copy/paste and later only you ned to press a number; and if recalculate the last project, with an Enter is enough. Check, and if you consider GUI is bether, I'll do.

Galexis, fails to me on linux:

raul@pb:~/Descargas/a$ python QET_TB_maker_v0.2\ \(1\).py 


<< Terminal Block maker for QET 0.2 - by Raul Roda >>


Remember the next conditions:
  * Terminal elements must be 'terminal' as type in the Element Editor.
  * If terminal elements has more than one textfield, the first one is considered.
  * Name of terminals must be in form 'x:a'.  x = Terminal Block name; a = Terminal name.


/home/raul/.qet/elements/temp_tb/
Traceback (most recent call last):
  File "QET_TB_maker_v0.2 (1).py", line 369, in <module>
    from tkinter.filedialog import *
ImportError: No module named tkinter.filedialog


I post the sample project I used.

Post's attachments

Attachment icon electric_plane.qet 1.22 mb, 1282 downloads since 2016-08-15 

25 (edited by unalcalde 2016-08-15 19:18:54)

Re: Terminal block generator cross-platform

Use: python3 QET_TB_maker_v0.21.py

Post's attachments

Attachment icon QET_TB_maker_v0.21.py 16.53 kb, 787 downloads since 2016-08-15