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

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.


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.

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, 330 downloads since 2018-02-17 

Re: Force renumber all items (autonumbering)

Nice, I try it tomorrow.

Re: Force renumber all items (autonumbering)

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

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

Post's attachments

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

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

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

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, 317 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.tuxfamily.org/qet/forum_img/awk2.png

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

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.

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, 410 downloads since 2018-02-18 

Re: Force renumber all items (autonumbering)

Wow, nice Jan. nomicons/smile

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

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, 15 downloads since 2021-03-26