haplokuon / netDxf

.net dxf Reader-Writer
MIT License
981 stars 400 forks source link

netDXF and WEBGL UNITY - open dxf file in browser gives error #403

Closed Kabum80 closed 2 years ago

Kabum80 commented 2 years ago

Hi, we are creating webgl application that runs in browser. We created interface that converts dxf elements into Uinty instances, like line renderer and so on.. Everything works in editor. No errors, no problem. When we export app into webgl and try to import dxf file into app it gives us error.

Before going into error section, I would like to ask. Does netDXF library works in webgl ? Strange thing is that export to dxf file works. But importing doesn't not. My idea is, that when loading dxf files over browser gives error, because load function doesn't read url correctly. Am I right?

When testing importing and figuring out what is wrong, I imported dxf file as plain text. I got the result, but I don't know if netDXF library gives me some options to use that plain text string or must importing be done exclusively over document.load method?

i hope I represent my error struggle clear enough.

thank you for helping me out..

haplokuon commented 2 years ago

The way you decide to draw the entities of a DXF file is independent on the way they are read from the file. It doesn't matter what graphic engine you use, netDxf does not have any rendering capabilities it just reads the contents from a DXF file.

I do not use Unity so I cannot help you with that.

Kabum80 commented 2 years ago

Thank you @haplokuon. What I did was I looked at Load method and what I found was that you can use memory stream as an input. So, I created a memory stream from plain text that I got from loading dxf file and created memory stream that I used with the Load method.

            byte[] byteArray = Encoding.ASCII.GetBytes( your plain text );
            MemoryStream stream = new MemoryStream( byteArray ); 

It works!