Unexpected entity when using dwg2dwg.bat

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
yamyam
Junior Member
Posts: 22
Joined: Fri Apr 19, 2024 2:31 am

Unexpected entity when using dwg2dwg.bat

Post by yamyam » Tue Feb 25, 2025 10:14 am

Hello everyone,

My QCAD version is QCAD Pro 3.30.1.0, and my OS is Windows 10.

When I use dwg2dwg.bat to convert DWG format drawings to DXF format, entities that do not exist in the DWG drawings appear in the DXF drawings.

The dwg drawing is as follows:
origin.png
origin.png (24.6 KiB) Viewed 73184 times
The dxf drawing is as follows:
dxf.png
dxf.png (30.24 KiB) Viewed 73184 times
The attached file is the dwg file with problem. Without modifying the original dwg drawing, how can I modify the .bat file or others to make the generated dxf entity consistent with the original drawing?
Attachments
test.dwg
(49.77 KiB) Downloaded 540 times

CVH
Premier Member
Posts: 4943
Joined: Wed Sep 27, 2017 4:17 pm

Re: Unexpected entity when using dwg2dwg.bat

Post by CVH » Tue Feb 25, 2025 10:32 am

Not really a topic for this sub-forum.
More a topic for: QCAD Troubleshooting and Problems

Opening the file with the QCAD GUI reports:
  • Unsupported XData type NOT imported: 1005
Suspecting that <origin.png> is how it is opened with QCAD. (Like it did over here)
And that the original drawing looked as <dxf.png> in another CAD-application.

The additional data is probably an external reference.
See this reply or this reply.

From what you report the additional data is included in the export created by dwg2dwg.
That would mean that this command tool is capable of including external content.
Already beyond the expectations. :P
You did not attach such an external file, so it is impossible to test the outcome correctly.

There is no fix using the QCAD GUI for the moment, not for over 12 years now (FS#693).
You could include the external reference as a standard CAD block in the drawing file with the native application.

Remember that an external reference may use the same layer names with different attributes.
The same blocks by name with different content.
And so on ...

I presume that it is this possible duality that makes it hard to implement.

Regards,
CVH

yamyam
Junior Member
Posts: 22
Joined: Fri Apr 19, 2024 2:31 am

Re: Unexpected entity when using dwg2dwg.bat

Post by yamyam » Wed Feb 26, 2025 1:44 am

Hi, CVH
CVH wrote:
Tue Feb 25, 2025 10:32 am
Not really a topic for this sub-forum.
More a topic for: QCAD Troubleshooting and Problems
I'm sorry. I'll pay attention next time. Or is there any way to move this topic to that sub-forum?
CVH wrote:
Tue Feb 25, 2025 10:32 am
Suspecting that <origin.png> is how it is opened with QCAD. (Like it did over here)
origin.png is the screenshot of the dwg file in my attachment opened using qcad.
CVH wrote:
Tue Feb 25, 2025 10:32 am
And that the original drawing looked as <dxf.png> in another CAD-application.
dxf.png is the screenshot of the dwg file after I converted it to a dxf file using dwg2dwg.bat and then opened it using qcad.

I used the .bat file in the Windows CMD by typing

Code: Select all

dwg2dwg.bat -o test.dxf test.dwg
I didn't introduce any external references, and I don't understand why it generates unexpected entities :oops:

CVH
Premier Member
Posts: 4943
Joined: Wed Sep 27, 2017 4:17 pm

Re: Unexpected entity when using dwg2dwg.bat

Post by CVH » Wed Feb 26, 2025 3:52 am

Hi,

A moderator is able to move the topic.
CVH wrote:
Tue Feb 25, 2025 10:32 am
From what you report the additional data is included in the export created by dwg2dwg.
That would mean that this command tool is capable of including external content.
Already beyond the expectations. :P
I can not confirm that.
- I don't have the additional content of the XREF.
- The source is a DWG and is binary.
If that was a DXF and textual then we could look for the XREF specification.

Out of curiosity: Could you attach the exported DXF file?

Regards,
CVH

yamyam
Junior Member
Posts: 22
Joined: Fri Apr 19, 2024 2:31 am

Re: Unexpected entity when using dwg2dwg.bat

Post by yamyam » Wed Feb 26, 2025 4:05 am

Hi,
CVH wrote:
Wed Feb 26, 2025 3:52 am
I don't have the additional content of the XREF.
When I open the file test.dwg with AutoCAD, the interface is the same as <origin.png>. And when I save it as a dxf file with AutoCAD, no extra entities appear.
CVH wrote:
Wed Feb 26, 2025 3:52 am
Out of curiosity: Could you attach the exported DXF file?
Of course, this is the dxf file generated by the .bat file.
Attachments
test.dxf
(141.52 KiB) Downloaded 584 times

CVH
Premier Member
Posts: 4943
Joined: Wed Sep 27, 2017 4:17 pm

Re: Unexpected entity when using dwg2dwg.bat

Post by CVH » Wed Feb 26, 2025 5:42 am

yamyam wrote:
Wed Feb 26, 2025 4:05 am
When I open the file test.dwg with AutoCAD, the interface is the same as <origin.png>. And when I save it as a dxf file with AutoCAD, no extra entities appear.
Could it be that you opened the test.dwg file after saving it from within the QCAD GUI?
Using the GUI, the XREF is not loaded, when saved again it is no longer included.

The copy of the DWG on the forum still reports the exception.
Try to open that with AutoCAD.

Regards,
CVH

yamyam
Junior Member
Posts: 22
Joined: Fri Apr 19, 2024 2:31 am

Re: Unexpected entity when using dwg2dwg.bat

Post by yamyam » Wed Feb 26, 2025 6:50 am

Hi,
CVH wrote:
Wed Feb 26, 2025 5:42 am
Could it be that you opened the test.dwg file after saving it from within the QCAD GUI?
Using the GUI, the XREF is not loaded, when saved again it is no longer included.
I used QCAD to save test.dwg as test2.dwg.
When I opened test2.dwg, there was no Unsupported XData type NOT imported: 1005 error.
But there were still unexpected entities.
Attachments
test2.dwg
(22.58 KiB) Downloaded 529 times

CVH
Premier Member
Posts: 4943
Joined: Wed Sep 27, 2017 4:17 pm

Re: Unexpected entity when using dwg2dwg.bat

Post by CVH » Wed Feb 26, 2025 8:49 am

yamyam wrote:
Wed Feb 26, 2025 6:50 am
I used QCAD to save test.dwg as test2.dwg.
Please specify: With the QCAD GUI or with the command line tool dwg2dwg

It is starting to be a chicken-egg conversation.
What came before what? What application is used for what?

Correct me if I am wrong:
- test.dwg posted [Tue Feb 25, 2025 10:14 am] was originally created with AutoCad.
- Converted to DXF with dwg2dwg it looked like dxf.png with additional content.
- Opening the source test.dwg within the QCAD GUI looks like origin.png ... There is an exception reported, additional content not loaded.

We can't replicate the export of dwg2dwg:

Code: Select all

08:41:23: Debug:    Input file:  ###Obscured###QCAD/QCAD_32.1/test(org).dwg
08:41:23: Debug:    Output file:  ###Obscured###QCAD/QCAD_32.1/test(conv).dxf
08:41:23: Debug:    DXF/DWG Release:  R27
08:41:23: Debug:    addObject: block: "*Model_Space"
08:41:23: Debug:    addObject: block: "*Paper_Space"
08:41:23: Debug:    addObject: block: "*Model_Space"
08:41:23: Debug:    addObject: block: "*Paper_Space"
Cannot import file: ###Obscured###QCAD/QCAD_32.1/test(org).dwg
Probably because we don't have a copy of the external reference.

Regards,
CVH

yamyam
Junior Member
Posts: 22
Joined: Fri Apr 19, 2024 2:31 am

Re: Unexpected entity when using dwg2dwg.bat

Post by yamyam » Thu Feb 27, 2025 1:59 am

Hi,
CVH wrote:
Wed Feb 26, 2025 8:49 am
yamyam wrote:
Wed Feb 26, 2025 6:50 am
I used QCAD to save test.dwg as test2.dwg.
Please specify: With the QCAD GUI or with the command line tool dwg2dwg
Sure, this is generated using the QCAD GUI.
CVH wrote:
Wed Feb 26, 2025 8:49 am
Correct me if I am wrong:
- test.dwg posted [Tue Feb 25, 2025 10:14 am] was originally created with AutoCad.
- Converted to DXF with dwg2dwg it looked like dxf.png with additional content.
- Opening the source test.dwg within the QCAD GUI looks like origin.png ... There is an exception reported, additional content not loaded.
Yes, your understanding is completely correct. And opening the source test.dwg within the AutoCAD also looks like origin.png.
When I save test.dwg as the dxf format with AutoCAD, the result is also like origin.png.
CVH wrote:
Wed Feb 26, 2025 8:49 am
We can't replicate the export of dwg2dwg:

Code: Select all

08:41:23: Debug:    Input file:  ###Obscured###QCAD/QCAD_32.1/test(org).dwg
08:41:23: Debug:    Output file:  ###Obscured###QCAD/QCAD_32.1/test(conv).dxf
08:41:23: Debug:    DXF/DWG Release:  R27
08:41:23: Debug:    addObject: block: "*Model_Space"
08:41:23: Debug:    addObject: block: "*Paper_Space"
08:41:23: Debug:    addObject: block: "*Model_Space"
08:41:23: Debug:    addObject: block: "*Paper_Space"
Cannot import file: ###Obscured###QCAD/QCAD_32.1/test(org).dwg
This is the information printed out after I converted the dwg using the command line.

Code: Select all

E:\QCad>dwg2dwg.bat -o test.dxf test.dwg
QCAD version  3.30.1
08:56:21: Debug:    loading plugins...
08:56:21: Debug:    RHelpPlugin::init
08:56:21: Debug:    RPolygonPlugin::init
08:56:21: Debug:    RProScriptsPlugin::init
08:56:21: Debug:    RProxiesPlugin::init
08:56:21: Debug:    RTracePlugin::init
08:56:21: Debug:    RDwgPlugin::init
08:56:21: Debug:    loading static plugins...
08:56:21: Debug:    Input file:  E:/QCad\test.dwg
08:56:21: Debug:    Output file:  E:/QCad\test.dxf
08:56:21: Debug:    DXF/DWG Release:  R27
08:56:21: Debug:    calling odInitialize
Warning:  cannot assign original handle to object "0x14"
Warning:  collision with object of type: 2
Warning:  new handle "0x39"
Warning:  cannot assign original handle to object "0x15"
Warning:  collision with object of type: 2
Warning:  new handle "0x3a"
Warning:  cannot assign original handle to object "0x16"
Warning:  collision with object of type: 2
Warning:  new handle "0x3b"
Warning:  cannot assign original handle to object "0x10"
Warning:  collision with object of type: 2
Warning:  new handle "0x3c1"
Warning:  cannot assign original handle to object "0x3c1"
Warning:  collision with object of type: 3
Warning:  new handle "0x3c2"
Warning:  cannot assign original handle to object "0x22"
Warning:  collision with object of type: 2
Warning:  new handle "0x3c3"
Warning:  cannot assign original handle to object "0x1f"
Warning:  collision with object of type: 2
Warning:  new handle "0x3c4"
08:56:21: Debug:    dynamic block ref
Conversion finished.
CVH wrote:
Wed Feb 26, 2025 8:49 am
Probably because we don't have a copy of the external reference.
If external reference refers to the missing information in test.dwg, then I don't actually have it. The only file I have is test.dwg.

CVH
Premier Member
Posts: 4943
Joined: Wed Sep 27, 2017 4:17 pm

Re: Unexpected entity when using dwg2dwg.bat

Post by CVH » Thu Feb 27, 2025 5:25 am

Hi,

I can now replicate loading the DWG within the QCAD GUI and save it as DXF with the additional data.
As well with QCAD 3.32.1.0 version as with an older version 3.27.6.0

My fault before was to reopen the original.
With proper naming I did not make that mistake. :oops:
I have too many files called 'test' downloaded from the forums. :wink:


Near the end of the conversion process is another clue:

Code: Select all

08:56:21: Debug:    dynamic block ref
Block 13 and *U2 are representations of windows and how they open.
The additional data appears to be shutters ... Dynamically adjusted to both window sizes.
Something said to be unsupported.


I did encountered that before ... Searching ... Found it.
In this reply as answer to my own questions, under the second title [SOLVED]:
  • This tickle down to another level of visibility, the RObject itself being set 'Invisible'.
    Supported by QCAD on load and an unknown property for QCAD users BUT also cleared :!: while saving.
I did report something like that ... Seems to be already 5 years back: FS#2146
And that points to an open question ... Unanswered.


Bottom line: QCAD clears the invisible state of some objects.

Unfortunately, as a simple user I cannot help you any further than reporting this additionally.

Regards,
CVH

yamyam
Junior Member
Posts: 22
Joined: Fri Apr 19, 2024 2:31 am

Re: Unexpected entity when using dwg2dwg.bat

Post by yamyam » Thu Feb 27, 2025 7:02 am

Thank you, CVH, I have seen the report you submitted: https://qcad.org/bugtracker/index.php?d ... sk_id=2146

Is there any way we can increase the priority of this bug? Actually, I have encountered similar problems with many of my drawings.

CVH
Premier Member
Posts: 4943
Joined: Wed Sep 27, 2017 4:17 pm

Re: Unexpected entity when using dwg2dwg.bat

Post by CVH » Thu Feb 27, 2025 7:44 am

Yes,
You can vote it up ....
For that you need to be logged on as user.
You can apply for an account, it is independent of the QCAD forum account.

Not aware that trailing reports (5 years) are looked at or that additional comment is even considered.
It won't hurt, right? :wink:

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”