Is there any way to convert from dwg file to gltf file?

I have 1 cad file (dwg). Is there a way to convert it to a gltf file?
I tried converting according to this link but got an error:

Does anyone have a way to convert from dwg file to gltf? Please support me.

Screenshot_2.png (27.8 KB)

@dunglh

You can please use Aspose.CAD and Aspose.3D to do this job. First convert the .dwg to .obj file using Aspose.CAD, and then use Aspose.3D to convert .obj to .gltf.

1 Like

@asad.ali Thanks you!.

I tried to do the same as you and exported the gltf file. But when I use the tool to view it, I can’t see anything.
Tool gltf viewer: https://gltf.pmnd.rs/

@dunglh

Would you please share your sample source files along with sample code snippet? We will test the scenario in our environment and address it accordingly.

@asad.ali send to you source code and dwg file.

My code:

if (openFileDialog.FileName.EndsWith(".dwg"))
                {
                    //Load file dwg by Aspose.CAD
                    Aspose.CAD.License license = new Aspose.CAD.License();
                    license.SetLicense("D:\\Dung\\Sample\\Winform\\SampleDwg\\SampleDwg\\License\\Aspose.CAD.NET.lic");
                    Aspose.CAD.Image image = Aspose.CAD.Image.Load(openFileDialog.FileName);
                    CadImage cad = (CadImage)image;
                    var options = new Aspose.CAD.ImageOptions.ObjOptions();

                    //Export file dwg to obj by Aspose.CAD
                    var fileName = openFileDialog.FileName.Replace(".dwg", ".obj");
                    image.Save(fileName, options);


                    //Load file obj by Aspose.3D
                    Aspose.ThreeD.License license1 = new Aspose.ThreeD.License();
                    license1.SetLicense("D:\\Dung\\Sample\\Winform\\SampleDwg\\SampleDwg\\License\\Aspose.3D.NET.lic");                    
                    Aspose.ThreeD.Scene scene = new Aspose.ThreeD.Scene(fileName);

                    //Convert file obj to glb by Aspose.CAD
                    GltfSaveOptions saveOptions = new GltfSaveOptions(Aspose.ThreeD.FileContentType.Binary);                    
                    var fileName1 = fileName.Replace(".obj", ".glb");
                    scene.Save(fileName1, saveOptions);
                }

File dwg: https://drive.google.com/file/d/1_tGHhrb-Qg3DmEkChoRDnlITbM5mk3YZ/view?usp=sharing

Thanks you!

@dunglh

An issue as THREEDNET-1235 has been logged in our issue tracking system to further investigate this case. We will look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

1 Like

@asad.ali Okie. Thanks for support!

1 Like

@dunglh

Can you share the generated .obj and .glb file? The .glb file we generated on our side does have something in the online .gltf viewer and in our Windows’ built-in 3D viewer.