Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with types in DWG -> JSON -> DWG conversion #1040

Open
michal-josef-spacek opened this issue Nov 19, 2024 · 7 comments · Fixed by #1041
Open

Issues with types in DWG -> JSON -> DWG conversion #1040

michal-josef-spacek opened this issue Nov 19, 2024 · 7 comments · Fixed by #1041

Comments

@michal-josef-spacek
Copy link
Contributor

I found two issues with conversion:

2384c2384
<     "minus_1": 4294967295,
---
>     "minus_1": 2147483647,
8421c8421
<           4278190080
---
>           2147483647

which is XRECORD xdata item

...
        [
          102,
          "RTVSPost2010Prop51ColorRGB"
        ],
        [
          90, 
          2147483647
        ],
...

dwgread of them:

  xdata[99] type: 90 [RS]
xdata[99]: -16777216 [RL 90]
  xdata[100] type: 102 [RS]

and

xdata[98]: "RTVSPost2010Prop51ColorRGB" [TV 102]
  xdata[99] type: 90 [RS]
xdata[99]: 2147483647 [RL 90]
  xdata[100] type: 102 [RS]
@michal-josef-spacek
Copy link
Contributor Author

I prepared fix for 1), but I don't see where is issue for 2)

@michal-josef-spacek
Copy link
Contributor Author

Still issue 2)

@michal-josef-spacek
Copy link
Contributor Author

michal-josef-spacek commented Nov 20, 2024

Testing file: Circle_Original.dwg.gz
Testing environment: Windows (tested on mingw version)

@michal-josef-spacek
Copy link
Contributor Author

Structure (via dwgread):

xdata[98]: "RTVSPost2010Prop51ColorRGB" [TV 102]
  xdata[99] type: 90 [RS]
xdata[99]: -16777216 [RL 90]
  xdata[100] type: 102 [RS]

is in DXF:

102
RTVSPost2010Prop51ColorRGB
 90
-16777216

and JSON:

        [
          102,
          "RTVSPost2010Prop51ColorRGB"
        ],
        [
          90,
          4278190080
        ],

This means, that conversion from DWG to JSON is wrong.

@michal-josef-spacek
Copy link
Contributor Author

michal-josef-spacek commented Nov 20, 2024

btw: Conversion to DXF via LibreDWG dwg2dxf.exe is fine.

102
RTVSPost2010Prop51ColorRGB
 90
-16777216

@michal-josef-spacek
Copy link
Contributor Author

Conversion from DWG to JSON is bad in Windows and Linux too (-16777216 → 4278190080).

@michal-josef-spacek
Copy link
Contributor Author

When I change:

diff --git a/src/out_json.c b/src/out_json.c
index f2e63e24c..4a066d6b7 100644
--- a/src/out_json.c
+++ b/src/out_json.c
@@ -170,6 +170,7 @@ static char *_path_field (const char *path);
 #define VALUE_RC(value, dxf) VALUE (value, RC, dxf)
 #define VALUE_RS(value, dxf) VALUE (value, RS, dxf)
 #define VALUE_RL(value, dxf) VALUE (value, RL, dxf)
+#define VALUE_RLd(value, dxf) VALUE (value, RLd, dxf)
 #define VALUE_RLx(value, dxf) VALUE ((BITCODE_RL)value, RL, dxf)
 #define VALUE_RLL(value, dxf) VALUE (value, RLL, dxf)
 #ifdef IS_RELEASE
@@ -1184,7 +1185,7 @@ json_xdata (Bit_Chain *restrict dat, const Dwg_Object_XRECORD *restrict obj)
                      rbuf->type);
           break;
         case DWG_VT_INT32:
-          VALUE_RL (rbuf->value.i32, 0);
+          VALUE_RLd (rbuf->value.i32, 0);
           LOG_TRACE ("xdata[%u]: %d [RL %d]\n", i, (int)rbuf->value.i32,
                      rbuf->type);
           break;

Conversion on Linux is -16777216 →-16777216, but on Windows still -16777216 → 4278190080.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant