1 (edited by yenda 2018-02-16 13:27:21)

Topic: Force renumber all items (autonumbering)

Hi all,
we are using autonumbering feature inside the drawings for contactors, terminals, inverters etc. So far so good.
Now I need to change numbering scheme for terminal or filling the gaps thanks to deleting a few of them and the re-adding (and I forgot to manually change sequence number).
Is here any way to automatically renumber whole project or at least one device type?

I'm using v 0.7 lastest dev.
Thanks!
Regards

Jan.

Re: Force renumber all items (autonumbering)

Hi,

the only thing i think is to hack the XML file of your project ...
Just notice the automatic prefix and formula is breaking with the lastest 0.7-dev (5238 here),  lost the auto element prefix, and no  push formula label result in new dynamic label, can you confirm it?

Laurent

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

Re: Force renumber all items (autonumbering)

Hi,
autonumbering seems to work ok, but you need to reopen the project again on order to see it...

Is there a plan to implement renumbering feature?

Cheers,

Jan

Re: Force renumber all items (autonumbering)

Thanks for informations.
Not that I know.. and Davi management policy seem now break.


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

Re: Force renumber all items (autonumbering)

scorpio810 wrote:

Hi,

the only thing i think is to hack the XML file of your project ...

In this video example I change formula, but in your case you need filter by element name, I think you need to write a script for it, find, sed, etc.

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

Re: Force renumber all items (autonumbering)

Hi,
ok, seems clear - so I wrote small script in awk which will do this work for me.
Maybe somebody else find it usefull...

Before trying be sure you have proper backup! As I'm not really aware of all xml syntax, it can go very wrong!

Cheers,

Jan.

Post's attachments

Attachment icon renumber_v3.awk 1.71 kb, 679 downloads since 2018-02-17 

Re: Force renumber all items (autonumbering)

Nice, I try it tomorrow.

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

Re: Force renumber all items (autonumbering)

awk -f renumber_v3.awk 1.qet > test_awk.qet

https://download.qelectrotech.org/qet/forum_img/1.png
https://download.qelectrotech.org/qet/forum_img/awk.png

Post's attachments

Attachment icon 1.qet 20.47 kb, 599 downloads since 2018-02-18 

Attachment icon test_awk.qet 20.34 kb, 557 downloads since 2018-02-18 

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

Re: Force renumber all items (autonumbering)

It's a good start, but it's going to be very complicated if you want to renumerate an entire project following rules, I think. nomicons/smile

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

Re: Force renumber all items (autonumbering)

Hi,
yes, it is going to be VERY complicated if you like catch every possible rule. This should be done inside the Qelectrotech and not externally (my opinion).
I did play with the script little more and implemented functionality to renumber items according to the "prefix", so with each prefix it starts a new numbering (new seqt_1 sequence from 1 up to items with the same prefix).

./renumber_v4.awk contacts.qet > contacts_renumbered.qet

The problems:
- it can go wrong if you have different formula than "%id%prefix%seqt_1"
- if you have device without prefix, it will not work (can be easily fixed but anyway, it is not a solution)
- the numbering increases the item value as it flow through the xml file. So it seems to be a little random... and I have no idea how to fix this.

For my needs I can use as it is... but not really helpful in other cases. The script would be really difficult to implement if you like to catch every possibility.

Regards

Jan.

Post's attachments

Attachment icon renumber.zip 9.32 kb, 642 downloads since 2018-02-18 

Re: Force renumber all items (autonumbering)

The most difficult is to respect a sequence of re numbering left to right and from top to bottom.

https://download.qelectrotech.org/qet/forum_img/awk2.png

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

Re: Force renumber all items (autonumbering)

yenda wrote:

Hi,

./renumber_v4.awk contacts.qet > contacts_renumbered.qet

Depend on distro packaging..

laurent@debian:~/Desktop$ ./renumber_v4.awk 1.qet > test_awk.qet
bash: ./renumber_v4.awk : /bin/awk : mauvais interpréteur: Aucun fichier ou dossier de ce type
[14:13:37] laurent@debian:~/Desktop$ awk -f renumber_v4.awk 1.qet > test_awk.qet  
[14:14:33] laurent@debian:~/Desktop$ whereis awk
awk: /usr/bin/awk /usr/lib/x86_64-linux-gnu/awk /usr/share/awk /usr/share/man/man1/awk.1.gz
[14:15:25] laurent@debian:~/Desktop$ whereis gawk
gawk: /usr/bin/gawk /usr/lib/x86_64-linux-gnu/gawk /usr/share/man/man1/gawk.1.gz
[14:15:46] laurent@debian:~/Desktop$ whereis original-awk
original-awk: /usr/bin/original-awk /usr/share/man/man1/original-awk.1.gz

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

Re: Force renumber all items (autonumbering)

OK, your awk is in different location... then you can use it as before, with direct awk call. nomicons/smile

I'm thinking about solving the issue of numbering from left to right + from up to down and it would need me to parse whole xml and do really, really a lot of stuff... I'm afraid this is no way, no quick solution for the moment. Giving up nomicons/sad 

Regards

Jan.

Re: Force renumber all items (autonumbering)

I understand that it needs a lot of work, thank you for sharing your script, maybe someone will one day be interested in this challenge..
In my case at my work I never use autonumbering. 
I only refresh old projects and is always a hard work to refresh and re draw old schemes on modified installations.

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

Re: Force renumber all items (autonumbering)

Hi,
so I did not really gave up and tried a XML framework for python - as parse whole XML in awk is insane. (It is installed in my OpenSuse as default, hope other distributions have it too).

Usage

python xmlparse.py -i xmltest.qet -o xmltest_renumbered.qet

and result should be renumbered all "ten"s and "hundred"s according to the prefix and position in schematics from top down and left right manner. Items without these tags are ignored.

It actually does only this and nothing else, it does not care at all about any formulas etc.

This is definitely enough for me now - hope somebody find it also useful and perhaps add additional functionality as I really do not have needed skills in Python.

Cheers,
Jan.

Post's attachments

Attachment icon xmlparse.zip 11.31 kb, 747 downloads since 2018-02-18 

Re: Force renumber all items (autonumbering)

Wow, nice Jan. nomicons/smile

https://download.qelectrotech.org/qet/forum_img/xmlpython.png

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

17 (edited by ksgordillot 2021-03-26 20:36:43)

Re: Force renumber all items (autonumbering)

Hi,

Thank you for your script Jan, it was definitely useful for me. I modified it a little bit according to my needs, I have numbering configurations with text with more than 1 letter, and the prefix was different (only the first letter of the label). This script renumbers all the elements in the project that have a label in the element information, overlooking the prefix. So the elements are organized according to the label, also is only for units, but I think it can be easily modified for tens and hundreds. Also, it changes the sequential number, the element information, and the dynamic text, so when you export the components list the label and the formula are the same (if it had a formula in the beginning).

Usage

python xmlparse_unit.py -i xmltest.qet -o xmltest_renumbered.qet

I hope somebody finds this useful as well.

Regards,

Karen

Post's attachments

Attachment icon xmlparse_unit.py 3.82 kb, 353 downloads since 2021-03-26 

Re: Force renumber all items (autonumbering)

Hello gents,

Can someone tell me about autonumbering of old elements? At first I put labels manualy. But then find out autonumbering. For new elements its working perfectly. But I want to go from first folio and rename with autonumbering.

Thanks.

Re: Force renumber all items (autonumbering)

Hi Paulius,

Do the old elements have any labels already? or are they without label?

20 (edited by paulius 2021-04-18 11:49:46)

Re: Force renumber all items (autonumbering)

Hi,

I prepared example. please find attachment.

Yes old elements label was written in elements information/label.

With new element KM1; 2; 3 all works fine.

But how to apply autonumbering for old.

Sorry for dumb questions.

Post's attachments

Attachment icon Screenshot from 2021-04-17 18-41-47.png 295.89 kb, 100 downloads since 2021-04-18 

21 (edited by ksgordillot 2021-04-19 20:37:31)

Re: Force renumber all items (autonumbering)

Hi Paulius,

From what I saw your old elements don´t have the same prefix as the new elements (KM1, KM2, KM3). The script posted previously won't renumber those old elements as they do not have the same prefix. I have been working on the script, adding some functionalities, I will post about this later, but for the time this might help you.

I made an example emulating what you posted. I relabeled the elements (OLD, VERYOLD). The element's name is:embed://import/10_electric/fabricantes/controladores_visualizadores/pixsys/atr142-abc.elmt and the prefix I want to use is KM.

Usage:

python xmlrenumber.py -i TEST.qet -o TEST_vr.qet -s8 -e atr142-abc.elmt -p KM

This will number the elements with the name 'atr142-abc.elmt' with a prefix different to KM. This only works with the formaula text+number.

Notice they won´t be numbered with the elements in the order of position x,y. If you want to organize them, then use: python xmlrenumber.py -i TEST_vr.qet -o TEST_vr.qet -s4

You might need to install lxml to run the script https://lxml.de/installation.html

Hope this helps.

Post's attachments

Attachment icon RenumberQET.zip 148.4 kb, 397 downloads since 2021-04-19 

Re: Force renumber all items (autonumbering)

Hi All, i am brand new to this software but i am very excited. I have noticed that there is a auto numbering function built into version 0.9 but when i try to apply it nothing changes. We want to be able to recalculate the numbers of all elements with a script or via the software. The reason is we dont redraw all our projects from scratch, we always modify older projects to save time, The idea is when you have added and deleted elements that you can say recalculate somehow and all the elements gets fresh numbers, Without this capability we will not be able to use this because renaming every element manually is just too much work. I really hope someone can point us in the right direction