This project has moved. For the latest updates, please go here.

Text position

Jun 19, 2016 at 7:01 PM
Hi,

I tried to modify a text bloc by removing it and adding it after text modification. I noticed that the text is not anymore in the same position. In the screen copy, text 157 is ok and was not modified, text 156a had an equivalent position before modification and is partially hidden after.

I'm not familiar with Autocad and just beginning with netdxf, thanks for any explanation.

https://we.tl/gtkgom6WL0

Olivier
                foreach (var o in dxf.Inserts) {
                    if (o.Block.Name == "FT_CHEXI") {
                        foreach (var a in o.Attributes) {
                            if (a.Tag == "CH_COD1") {
                                if ((string)a.Value == "156") {
                                    Debug.WriteLine(a.Value.ToString());
                                    del = o;
                                    a.Value = "156a";
                                    add = o;
                                }

                            }
                        }

                    }

                }
                if (del != null) dxf.RemoveEntity(del);
                if (add != null) dxf.AddEntity(add);
                dxf.Save("D:/netdxf2.dxf", true);
Coordinator
Jun 21, 2016 at 1:03 PM
I have tried to reproduce your problem with the piece of code you have shown, but I have not been able to find any issues. Changing an attribute value do not affect its position, perhaps the origin of the problem is somewhere else. I have a couple comments about your code in case it helps:
  1. There is no need to remove from the document the "del" entity to add later the "add" entity, since both are actually the same object.
  2. Just in case, if there are several insert in your dxf that comply with the criteria in your loops, the "del" and "add" object will point to the last insert found.
  3. You can safely delete all references to the variables "add" and "del", they are not really need it, if what you want is change the attribute value of an insert.
Try to build a full sample from which I can reproduce your issue.

Daniel
Jun 25, 2016 at 7:54 AM
Hi Daniel,

Thanks for your answer. I tried again, removing del, add, remove,entity, addentity. The result is exactly the same, The entity with changed text is slightly moved. I sent files here to show it [https://we.tl/jgDGGYGjqX]
                   DxfDoxcument dxf = DxfDocument.Load(" <file>")
                    foreach (var o in dxf.Inserts) {
                    if (o.Block.Name == "FT_CHEXI") {
                        foreach (var a in o.Attributes) {
                            if (a.Tag == "CH_COD1") {
                                if ((string)a.Value == "156") {
                                    Debug.WriteLine(a.Value.ToString());
                                    a.Value = "156a";
                                }

                            }
                        }

                    }

                }
                dxf.Save("D:/netdxf2.dxf", true);
Coordinator
Jun 25, 2016 at 1:44 PM
Check your link to the files, it is broken.

Daniel
Jun 27, 2016 at 9:00 AM
Sorry, it's the last char that came part of the url https://we.tl/jgDGGYGjqX
Jun 30, 2016 at 9:08 AM
Hi,

No answer ? I add a new lnk as it's duration is limited, thanks for any help.

https://we.tl/DQ49fGc0pi

Olivier
Coordinator
Jun 30, 2016 at 7:26 PM
A little bit of patience, I do this in my free time.

I am not detecting anything wrong. What program are you using? Perhaps it has to do with the attribute text alignment. While there are a couple codes in the attribute dxf specification to define its text alignment, it also requires an additional point when the alignment is set to anything but left. To properly define this point it is required to know the length of the text, something that at the moment I cannot know.

Therefore, try to stick to left alignments and try again. The position and the alignment should be enough information to make it work. I tried reading it with DWG TrueView and AutoCad, at least the versions I tested it, do not show any weird behavior, but perhaps other programs might not show the text alignment correctly, if that point I was talking about is not set up correctly, but again it requires to calculate the length of the text something that at the moment I cannot do.

This same limitation also appears with Text entities, that is why I recommend to use MText entities over the older Text. You can also try to reproduce your problem with Text entities, to see if they also show that same behavior, if they do, definitively the origin of the problem lies with the text alignment. In any case I have not seen any problems with the position just the alignment.

Daniel
Jun 30, 2016 at 7:54 PM
Hi Daniel,

Sorry, I do apologize.

Here are some more information :

I do not have Autocad, so I'm looking at those files with https://client.autocad360.com.

I have to modify dxf which are sent to me, so I'm not able to modify them by myself.

Olivier
Coordinator
Jul 1, 2016 at 7:36 PM
I do not have much more to say, if it does not work for you I do not know what else to do. I do not have the hardware to test the AutoCad360, and in the web address you have sent it says Beta, so who knows.

If a desktop cad viewer is enough for you, instead of a mobile application I would recommend the Dwg TrueView it is free and also from Autodesk, I make tests with it I it works fine. All three applications AutoCad, AutoCad 360, and Dwg TrueView come from the same company, so I guess they share some internal code, and I do not know why you are experiencing those issues with the 360.

Daniel
Marked as answer by olivier57 on 7/1/2016 at 2:03 PM
Jul 1, 2016 at 10:03 PM
You're right, display is correct with TrueView.
I hoped not to use this huge soft just for viewing dxf but eventually I had to.
Perhaps it's a bug from Autocad360.
Thanks very much for you help.

Olivier