Topic: freepascal-code to take a QET- Element and scale the content by a fact

plc-user wrote:

Hello S.DEFFAUX!

Who do you want to punish with such work?  nomicons/wink
Checking all existing QET-Elements if they show a
front-view and then scale them by hand...

In the Lazarus-/freepascal-Wiki I found the beginning
of the now existing freepascal-code to take a QET-
Element and scale the content by a factor.

You find the sources and pre-compiled versions for
Debian unstable and ReactOS at
https://github.com/plc-user/QET_ElementScaler

The code compiles/runs with Lazarus 2.0.10 and
FreePascal 3.2.0 on Debian/GNU Linux (unstable) and
ReactOS (0.4.15-dev-1196) (didn't try, but should run
on win7 or 10, too)

In combination with a small shell-script the program
edited all front-views of "my" elements (about 800)
in 1.5 seconds.


But still the main-Question is: What scaling-faktor
do we want to use for front-views of our elements.
In my opinion 100 mm -> 200 px is a good value!
That means that ${someone} has to check, if the already
existing parts use the same scaling-factor. As I wrote
in a previous message: The three examples had three
different factors and I guess there are even more in the
QET-collection ...


Best regards
  plc-user

Re: freepascal-code to take a QET- Element and scale the content by a fact

I hadn't really tested this little utility yet, but recently I had to get back to drawing at work for a new electrical project ...
and this great tool has made it much easier to work with thumbnails not always at the right scale factor.

https://download.tuxfamily.org/qet/forum_img_2/QET_ElementScaler.png

Very easy to use:
example

laurent@debian:~/.qet$ ./QET_ElementScaler elements/nx300320190520.elmt 10
laurent@debian:~/.qet$ ./QET_ElementScaler elements/nx300320190520.elmt 0.5
laurent@debian:~/.qet$ ./QET_ElementScaler elements/nx300320190520.elmt 5


laurent@debian:~/.qet/elements$ ls -al | grep nx
-rw-r--r-- 1 laurent laurent   691553  1 juin   2021 nx300320190520.elmt
-rw-r--r-- 1 laurent laurent   673021  9 mai   21:21 nx300320190520.SCALED.elmt

Just reload collection by right click, drag and drop new scaled.elmt.

Great tool, thanks plc-user.

BTW, I added description and link to plc-user Github for download this nice tool on QET download main page.

Re: freepascal-code to take a QET- Element and scale the content by a fact

scorpio810 wrote:

Great tool, thanks plc-user.

You're welcome, Laurent!

4 (edited by plc-user 2022-08-14 18:08:49)

Re: freepascal-code to take a QET- Element and scale the content by a fact

EDITED
Just created a new version of QET_ElementScaler:
With the newly added optional parameter "-o" or "--stdout" it is now possible to write the scaled element-data to stdout instead of writing a renamed file.

The new option "-i" or "--stdin" allows QET_ElementScaler to be used with re-direction and/or pipes on the commandline:
The input-data is read from stdin and the output will be written to stdout.

Examples to write to stdout:
QET_ElementScaler -o InputElement.elmt 1.4 > NewScaledElement.elmt
QET_ElementScaler -o InputElement.elmt 1.4 | OtherSoftwareBinary

Examples to use re-direction and/or pipes:
QET_ElementScaler -i  1.4 < InputElement.elmt > NewScaledElement.elmt
cat  InputElement.elmt | QET_ElementScaler -i 1.4 | OtherSoftwareBinary

Have a look and give it a try:
https://github.com/plc-user/QET_ElementScaler

Re: freepascal-code to take a QET- Element and scale the content by a fact

Today I uploaded a new version of "QET_ElementScaler" to github: https://github.com/plc-user/QET_ElementScaler

This version is completely rewritten in C++, where I (like QET) use pugixml for handling the contents of the element files.

I made a few additions/changes that makes working with the software easier: The XML description line no longer needs to be removed afterwards!

As before, x and y scaling factors can be specified, input is via STDIN (-i) or a file (-f FILEINAME) and output is, as before, to a new file or to STDOUT (-o).

In addition, I have added the possibility to remove "terminals" from the element. This can be useful when terminals can be omitted from overloaded front views.

Furthermore, there is now the possibility to flip polygons and lines horizontally and/or vertically. This can be useful during the development of complex front views, as long as these functions are not yet available in the QET element editor.

Special care should be taken with the option "--OverwriteOriginal", because here the original file will be overwritten WITHOUT further request!

The scaled values of the new element are written into the new file with a maximum of 2 decimal places. In my view, this is completely sufficient for the display of schematic symbols and front views (thumbnails). In some elements present in the QET collection I have seen values with up to six decimal places, which in my opinion is excessive.
To "fix" such elements, QET_ElementScaler can of course be used! With the call:

QET_ElementScaler -f FILENAME

the values are rounded to max. 2 decimal places and any font sizes with decimal places are rounded to whole numbers.

I wish all users of the software a lot of fun and success with it and would like to see bugs reported (e.g. here or at github). Of course, I also have an "open ear" for suggestions for improvement!

Best regards
plc-user

Re: freepascal-code to take a QET- Element and scale the content by a fact

;-)