dxfjs / writer

A JavaScript dxf generator written in TypeScript.
https://dxf.vercel.app
MIT License
90 stars 17 forks source link

I am not able to add image in dxf #31

Closed DeepankarGupta13 closed 2 years ago

DeepankarGupta13 commented 2 years ago

i tried this

const imgDef = dxf.addImage("door.jpg", 'door.jpg', point3d(20, 20, 0), 10, 10, 1, 0);

the file gets download without any error but the file is not opening it says press enter to continue and after that nothing happens.

i consoled the imgDef i got this image

pls help.

DeepankarGupta13 commented 2 years ago

image this is what i got in dxf file

tarikjabiri commented 2 years ago

Hi,

Please try this:

// And for the image to show up it should be in same location as the dxf file.
const img = dxf.addImage(".\\door.jpg", 'door.jpg', point3d(20, 20, 0), 10, 10, 1, 0);

// Or use an absolute path so it will show up regardless of dxf location.
const img = dxf.addImage("C:/path/to/image/door.jpg", 'door.jpg', point3d(20, 20, 0), 10, 10, 1, 0);

You can take a look in the example code in docs

regards

DeepankarGupta13 commented 2 years ago

sir, it's still not working same issue as above press enter to continue tried absolute path, move the file inside the src folder.

tarikjabiri commented 2 years ago

Can I ask how you visualize your dxf file

DeepankarGupta13 commented 2 years ago

image like this

tarikjabiri commented 2 years ago

Ok you are using AutoCAD. I can't reproduce can I have a look at your code if possible or an example producing the same result so I can investegate

DeepankarGupta13 commented 2 years ago

https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2021/ENU/AutoCAD-Core/files/GUID-18152523-0866-40EF-BC6D-8FAA1127BDD9-htm.html

DeepankarGupta13 commented 2 years ago

these are the steps to attach image in autocad dxf

tarikjabiri commented 2 years ago

Note that I am also a AutoCAD user so I now how to use it. I jsut asked to know which softawre you are using. Autocad is the most good software at reading dxf files.

I asked about your code using my lib so I can investegate why you got that error

DeepankarGupta13 commented 2 years ago

sorry, I misunderstood your previous msg.

the below is the dxf code i got after running the code https://docs.google.com/document/d/1fRXgNIQCfvl7kEYbahYuAJmAOhoUxlzoZaPWQQ1DeHE/edit?usp=sharing

and my code is this https://github.com/DeepankarGupta13/ThreeJS_Test/blob/dxfWriter/src/script.js

DeepankarGupta13 commented 2 years ago

i am using vuejs

tarikjabiri commented 2 years ago

Did you push the changes I cant see where you are using addImage()

DeepankarGupta13 commented 2 years ago

srry i shared wrong link i changed now this is the new link https://github.com/DeepankarGupta13/ThreeJS_Test/blob/dxfWriter/src/script.js

DeepankarGupta13 commented 2 years ago

IMAGEDEF 5 1A 330 1D 102 {ACAD_REACTORS 330 1D 330 1C 102 } 100 AcDbRasterImageDef 1 C:/Users/deepa/OneDrive/Desktop/threejsPrac/ThreeJS_Test/src/test.png 10 1792 20 1280 11 1 21 1 280 1 281 0 0 IMAGEDEF_REACTOR 5 1C 330 0 100 AcDbRasterImageDefReactor 90 2 330 1B 0

this code was getting repeated in the dxf file i removed and it worked.

tarikjabiri commented 2 years ago

And why is repeated like that is it my lib doing that 🤔

DeepankarGupta13 commented 2 years ago

i guess so, because i am calling the addImage() function only once.

tarikjabiri commented 2 years ago

I found the issue, these lines shouldn't be there 🤦‍♂️.

Also I am using AutoCAD 2013 is not complaining about this it opens the dxf with no errors.

I was adding those object twice so they getting serialized twice.

DeepankarGupta13 commented 2 years ago

thanks sir.