2

I have a simple program that has Scene3d in qml like this code :

  Scene3D
{
    id : scene3d
    anchors.fill: parent
    focus: true
    aspects: ["render", "logic", "input"]
    hoverEnabled: true
    cameraAspectRatioMode: Scene3D.AutomaticAspectRatio


    antialiasing: true

}

I want to load a .dwg AutoCAD file in this Scene3D . I know that for doing this I should use a library like Assimp but the problem is that Assimp doesn't support this format of files so I find libdxfrw but I don't know how should I use it in my project and how to use it in qml Scene3d.

I know that SceneLoader can import .obj files , is there any way to convert .dwg files to .obj ?

Parisa.H.R
  • 3,303
  • 3
  • 19
  • 38
  • Have you tried googeling "convert dwg to obj"? Seems like there are some converters online. – Florian Blume Jun 21 '21 at 09:52
  • I want to use it in my program as an option , the problem is not converting one obj file to dwg. means that my program does this convert. – Parisa.H.R Jun 21 '21 at 10:34
  • for example, if you see applications like a blender , they have one part in the menu called import and export that supports some type of files. now I want this the same but can import .dwg and export .dwg file from my 3d objects in scene3d. – Parisa.H.R Jun 21 '21 at 11:15
  • Well then you have to create the geometry yourself. Find out how `libdxfrw` makes the mesh data available and then load it into a `QGeometry`. [There exist examples in Qt3D how to do it](https://doc.qt.io/GammaRay/gammaray-qt3d-geometry-mycylinder-cpp.html). – Florian Blume Jun 21 '21 at 15:11
  • Thanks for your answer, but what will happen if the geometry inside the .dwg wasn't a usual geometry like lines, circles, and..., is there any way to convert it to .obj and then get it to [SceneLoader](https://doc.qt.io/qt-5/qml-qt3d-render-sceneloader.html)? – Parisa.H.R Jun 23 '21 at 06:35
  • The SceneLoader supports all formats that Assimp supports. So if Assimp doesn't support .dwg files you have to load them manually. I'm not sure what you mean by 'wasn't a usual geometry' but with Qt3D you can do everything you can do with OpenGL, i.e. if you can display it using OpenGL you can display it using Qt3D. Like I said, you have to load it manually and convert the objects in the .dwg file to OpenGL objects. – Florian Blume Jul 16 '21 at 10:28
  • 1
    For example, you could use [libopencad](https://github.com/sandyre/libopencad) to load the files and then manually convert them Qt3D. If there are special objects in the file (maybe elaborate what you mean by that) then you have to handle them somehow. Sorry for the imprecise comments but I don't really get what you mean ;) – Florian Blume Jul 16 '21 at 10:32
  • special objects like bolts and nuts or something like that , something that isn't a line , a circle that has simple geometry. – Parisa.H.R Jul 16 '21 at 10:39
  • One of my problems is that I can't build and run GammaRay or other projects like this with my qt. I use `Qt 5.14.0` . why Qt doesn't have backward compatibility – Parisa.H.R Jul 16 '21 at 10:42
  • But when you have a bolt in your file then there are vertices that form that bolt, so just get the vertices and supply them to Qt3D. The two libraries I posted here both provide the vertices of the objects to you. I'm not sure why you would need GammRay here and I'm not sure what you mean by that you can't build other projects with your Qt, like how? – Florian Blume Jul 16 '21 at 13:34
  • Thanks @FlorianBlume , I will test that libs. Qt versions don't have backward compatibility , For example, when I clone one repo like [this](https://github.com/qt-labs/qt3d-editor/tree/9f4d089f5d2868c79242c76b8f29c8834f304887) it didn't show me anything. I guss it need Qt 5.15.0 or higher . this thing happens for kuesa or GammaRay .I compile my program in Qt 5.14.0 and it works and then when I compile it with Qt 5.14.2 It crashed :) – Parisa.H.R Jul 16 '21 at 14:01
  • Ah yeah, the Qt3DEditor, that one gave me trouble already, too. I works with a lower Qt version, like 5.9 or something. You can simply install another Qt version and use it. But this is all going far to far away from your original question... Post another one, you've asked like 20 different things here already ;) – Florian Blume Jul 16 '21 at 14:05
  • 1
    You are right thank you so much . – Parisa.H.R Jul 16 '21 at 14:08

0 Answers0