1

(10 replies, posted in Import)

For what it's worth, I have forked the dxf2elmt program, and have started making changes. I have a version of it offline that supports blocks without exploding them first in something like QCad. I had hoped to clean it up and release it last week, but sometimes life gets in the way of our best intended plans. Hopefully I'll finish cleaning it up soon, and after that people won't need to worry about if there DXF file has blocks or not.

2

(93 replies, posted in Import)

plc-user wrote:

Hello Vadoola,

the angles for the graphic element "arc" are available as integers without decimal places in QET.

Good catch, I'll get that corrected.

3

(93 replies, posted in Import)

Hello Laurent

scorpio810 wrote:

Thanks Vadoola for fixing stdout we can use now your dxf2elmt binary on QET element

You're welcome. I disabled the info printing by default which cleared this up. It occurred to me last night that really a better solution would be to make the info and verbose flags mutually exclusive. The info is on by default if you are running it from the CLI, but passing the -v flag disables the info, it's one or the other. I'll create an issue to document that, but I won't worry about it right away.


scorpio810 wrote:

but FYI build make some warnings:

Sorry, you checked out my master branch which is in a partially complete state. If you grab commit 03efbd8, that has the stdout fix, but shouldn't generate any warnings.

The master branch commit 8309837 has some partially completed restructuring. I'm adding in some code to read the DXF and store the element information before writing it out to XML. This should make it easier for some entities to reference other parts of the drawing (such as blocks), and I believe creates some better encapsulation. Rust by default warns on dead code, functions and structs that are never used, code that can't be reached etc. None of this new code to store the element information from the DXF is called anywhere, hence the warnings. In the main.rs there is line 42:

mod qelmt;

This tells rust the qelmt module (similar to a C++ namespace) exists. If you comment it out, rust won't compile it and all the warning should go away. I had meant to do this before committing, but obviously forgot. All the rest of the code functions as it did before, this last commit is just some of the ground work for refactoring.

4

(93 replies, posted in Import)

plc-user wrote:

This also includes the polygons with only one point each: The original dxf program must have "thought" of representing some parts as 1-point polygons, but do we need that in the QET element? I didn't find anything missing from the example!

This is part of why I wanted to see the original dxf that created these single point polygons (thank you for attaching it). I agree that a single point polygon makes no sense, and these could possible be lines that extend out in the direction away/into the viewport, and they are represented as single point polygons in the exported dxf. I just want to make sure that these aren't being created by some bug in dxf2elemt that is dropping points in the dxf that should exist in the resulting element file. If after some testing we can safely say there is no bug and these are represented in the dxf as single point polygons, it would be easy to filter those out simply by looking at the length of the vector holding the points. Similarly if we end up with a polygon with only two points, it's easy to recognize that and convert it to a line.

plc-user wrote:

My knowledge of DXF is poor, but as I see it, many commercial programs, for example, export single circles as multiple splines, which can never become a space-saving circle or ellipse again when converting. Unless you rework the element in the element editor by hand

plc-user wrote:

On the contrary:
In the dxf and therefore also in the resulting QET element, there are very often polygons that lie directly on top of each other, but which are not recognizable as individual graphic elements.
Nowadays, this is often due to the fact that devices are no longer made from several 2D drawings, but are created directly as 3D models. A 2D dxf drawing is then made from this, which accordingly also contains many hidden lines that inflate the resulting QET element, but do not provide any additional information.

I agree, converting multiple splines that form a circle into a circle element within QET would be preferred, as would getting rid of extra polygons that overlap and aren't seen, and polygons with multiple points that form a straight line. All of these are great ideas and something that I can try and work on, however they can get far more complicated than just checking the number of points. With a straight line multi-point polygon I need to do some math on it to determine if it's a line.

With the multiple spline circles, or overlapping polygons I need to look at multiple elements in combination to determine the shape, this gets far more complicated, as now not only am I trying to determine a shape from multiple elements, but I might need to do this processing on multiple combinations of splines withing the dxf. each new object would significantly increase the number of combinations that need to be looked at.

I could try and start with an easier route. After I get clean up and get the block importing finalized I could try and do some shape testing for circles made of splines etc, just within each block. This would reduce the number of combinations that need to be processed.

I think these points that you have brought up are very worth goals, and I'll add them to the issue tracker for the project, but they are quite complicated features, and I'll probably concentrate on some other simpler clean up and fixes before I try and tackle them.

5

(93 replies, posted in Import)

plc-user could you share the original dxf file that created these single point polygons?

6

(93 replies, posted in Import)

scorpio810 wrote:

Macos arm64 dxf2elmt for test.
FYI it's only work in an terminal...


Hmm, when I initially made my announcement I had only tested the CLI, since I hadn't realized antonioaja had made changes to the argument parsing, I just assumed it had still worked from QET. This time around I acatually tested it in QET and it seemed to work fine on my machine, although maybe I made a mistake. I'm currently testing it on Windows, and I now see that I have a dxf2elmt exe in both C:\Program files\QElectrotech\bin as well as C:\Users\Vadoola\AppData\Roaming\qet\binary. Perhaps I dropped the exe in he wrong place and it was using the old 0.30 release version from antonioaja repository. I'll take another look into this, and do a more thourough testing job this time around.

plc-user wrote:

In all dxf drawings I had to convert so far, the individual splines were not really long or complex. That's why I'm wondering whether we really need 100 segments in the corresponding polygon for each spline as a default setting for the conversion to QET elements?
I have tried a few files with different numbers of polygon segments and I think that 10 or 12 points should be enough for good results.

I agree that 100 does seem like a lot and could make the resulting element unnecessarily large. This should be an easy change, I'll do some testing to see how 10-12 points do, and make sure it still works well.

plc-user wrote:

Do we really need the full precision of up to 14 decimal places from dxf for use in QET elements?
For all graphical elements in the element editor, a maximum of two decimal places can be entered or edited and the graphical editor only allows changes in the tenths range. Therefore, in my opinion, it is completely sufficient to use a maximum of two decimal places in conversion programs for QET elements.

Completely agree, I can change the default behavior to round to 2 decimals of precision.

plc-user wrote:

I also noticed that the converted element file contains polygons with a only one point! QET_ElementScaler filters them out, but should they not be eliminated from the element file in the first place?

While doing some testing this past week on QET element files I found on github, there were a few I found converted with (I believe) the old C++ dxftoelemt that had polygon's with only 2 points. I created an issue (https://github.com/Vadoola/dxf2elmt/issues/120) to try and filter those out and convert them to lines. I could also easily filter out polygons with only 1 point and just not write them out, but I'll take a closer look at the file you attached and try to find out WHY there are single point polygons in the first place. Perhaps removing them isn't the proper way forward and they have a purpose and need to be handled differently (like a point that needs a thickness or something, that is converted to a circle element?)

Antonioaja has also responded to my pull request (https://github.com/antonioaja/dxf2elmt/pull/3). I asked for clarification if he is fine with my fork being the QElectrotech recommended fork, but it sounds like he said the project did what he needed and had no real plans to continue development.

7

(93 replies, posted in Import)

scorpio810 wrote:

@vadoola:Do you think it's possible to solve this problem?
https://github.com/antonioaja/dxf2elmt/issues/2

Do we still have to do ‘select all and make explode all’ and save again in a DXF program before using df2elmt?

Just an FYI I seem to have solved this. I haven't committed it yet, because the code is a bit crude and I want to clean it up first. Hopefully I will get around to it sometime this week.

8

(93 replies, posted in Import)

scorpio810 wrote:

@vadoola:Do you think it's possible to solve this problem?
https://github.com/antonioaja/dxf2elmt/issues/2

Do we still have to do ‘select all and make explode all’ and save again in a DXF program before using df2elmt?

Since I don't really have access to the Antonioaja's issue tracker I started issues on my own.

I created two issues that might be relevant: https://github.com/Vadoola/dxf2elmt/issues/8 and https://github.com/Vadoola/dxf2elmt/issues/4

I started digging into this a little last night just looking at that circle dxf in the initial issue. It looks like it's using an Insert Element which is why it's not working. I'm not an expert on dxf so I don't know if it's this specific dxf or all blocks in dxf that use an Insert Entity.

This is one the things I want to focus on first, as I feel this is a big limitation.

9

(93 replies, posted in Import)

I see the problem:

if info {
    //prints info
} else if verbose_output {
    //print to stdout
}

if the info flag is passed (which defaults to true), it never checks if the verbose flag is used.

Looks like this change was made as part of commit 67557ff on 2022-10-15

10

(93 replies, posted in Import)

plc-user wrote:

In a deep subdirectory, from the compiled result I find the file "entities.rs" with (among other things) this content

Perfect you pointed me to exactly what I need, since the info is already there it's a simple 2 line fix putting the correct info int he XML instead of having it hard coded to true or false. So far I've only tested it on the arrow.dxf you provided and the 4_inlet.dxf scorpio810 provided in this thread https://qelectrotech.org/forum/viewtopic.php?id=2265 that caused Antonioaja to change it from closed=true to closed=false. But it works well and correctly handles both of them, as can be seen int he 2 attached elmt files.

plc-user wrote:

At first glance, there's no difference - both do a remarkable job.

As my changes so far have been a some simple organizational changes, and updating some dependencies, I wouldn't expect there to be much if any difference. Hopefully going forward as I try to add some more features I won't break anything.

plc-user wrote:

Maybe just look at this post: nomicons/wink
https://qelectrotech.org/forum/viewtopi … 299#p20299.

Just saw that after already fixing it on my end. I pretty much did the same thing, except instead of using

if self.flags & 1 == 0 {

I used

if !self.get_is_closed() {

Same result in the end.

11

(93 replies, posted in Import)

plc-user wrote:

When I change the entries "70  1"  to "70   0" the polygons are shown open in LibreCAD.
I therefore think that it should be possible to be implemented in dxf2elmt...  nomicons/wink

Thanks this gives me a place to start looking.

12

(93 replies, posted in Import)

plc-user wrote:

In summary, it can be said that the order of the parameters is decisive for the original code.
With Vadoola's code, the call in QET would have to be adapted.

I looks like the last release and binary are dated 2022-07-21, but there was a commit on 2022-07-22 where Antonioaja switched from manually parsing command line arguments to using the clap argument parsing crate. I imagine that's where this discrepancy is coming from. I'll see what I can do to correct this. Probably no reason to update how QElectrotech is calling dxf2elmt if I can resolve the difference.

13

(93 replies, posted in Import)

So I just did a quick look and test with the latest version in antonioaja's repo that I initially forked from. In order to get the XML on stdout you need to use both the

-i AND -v 

command line flags.

The -i flag turns off printing the info such as the number of elements that were converted etc, and the -v flag turns off creating the elmt file.

If you use the -i flag without the -v you get something along the lines of

XXX.elmt was created...
Now converting XXX.dxf...

If you use

dxf2elmt.exe -i -v -f mydxf.dxf

, you get the XML output to stdout.

This works the same in both my repo and antonioaja's. The choice of flags and combinations seems a bit odd to me, and I might make some changes at some point, but it does output to stdout if you set the correct cli flags.

14

(93 replies, posted in Import)

Well it looks like this post sparked some conversation, good to see.

scorpio810 wrote:

No activity of Antionio since November 8, 2023 : https://github.com/antonioaja

I hope he's all right .... "

I hope so too, I know how things can get and they may just have other priorities, so despite the lack of updates, I didn't just want to assume the project was unmainted without trying to reach out.

scorpio810 wrote:

Program work well in a terminal with CLI, not when I put the binary dxf2elmt in ~.qet/binary/   and I use QET element editor
menu Import DXF, not  stdout?

So far I'm made some minimal changes, and in my tests it seems to be working, but I will admit I have not fully tested it yet, and only ran it from the command line. I thought the stdout support was added by Antionio with the -v flag. I can't think of any reason my changes would have broken that, but I'll take a look, as it's certainly possible I made a mistake.

scorpio810 wrote:

ps: size of the binary is very big after cargo build... ~57,6 Mio (60414840) (debug?)

cargo build

creates a debug build, and they can be pretty big.

cargo build --release

will create a smaller release build, and also striping the symbols as suggested by plc-user will reduce the size even more.

plc-user wrote:

What bothers me more about dxf2elmt:
The default behavior for polygons of dxf2elmt seems to be "closed=false", but for QET the default behavior is "closed=true". (see attachments)

This change to use closed=false by default was made by Antonioaja as the solution to a bug found by scorpio810. This original post about this is at https://qelectrotech.org/forum/viewtopic.php?id=2265. I'll  have to do a bit of digging to determine what the proper solution is here. If it should be closed or not, and if it should be closed, what else was going wrong with the dxf in the other thread.

15

(93 replies, posted in Import)

Hello,

The dxf to elmt conversion program hasn't been updated in over a year, and has a few issues, as well as doesn't support all features of dxf.

I forked the project a couple of weeks ago and started to try and update it some. I don't know how much time I will have to dedicate to it, but I thought I would give it a go to try and fix some of the issues with it, as well as possibly try and add in some of the missing features.

I've submitted a pull request to the original project, and as of yet have heard nothing back (it has only been 1-2 weeks).

If anyone is interested in my fork you can find it at https://github.com/Vadoola/dxf2elmt.

I know QElectrotech links to the original repo, and I'm not suggesting this be updated to point to mine, as I feel like we need to give the original creator more time to respond before we declare it dead/unmaintained. I do hope to try and spend some time updating it however, and if the original author doesn't respond, at some point it might make sense to link to my updated repo.