DWG files contain vector images as well as metadata so that any off-book information is not needed to comprehend the drawings. Such drawings are used by engineers, architects, or town planners to create huge designs. In certain situations, you might require to convert a DWG file to an OBJ 3D Object format file. According to such use cases, this article covers how to convert a DWG file to an OBJ file programmatically in Java.
DWG to OBJ Converter – Java API Installation
Aspose.CAD for Java API supports working with different file formats including DWG, IGES, and PLT files. You can configure the API by downloading its JAR file from the Downloads or specify the following configurations under the pom.xml file to install it from Aspose Repository:
Repository
<repositories>
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>http://repository.aspose.com/repo/</url>
</repository>
</repositories>
Dependency
<dependencies>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cad</artifactId>
<version>22.1</version>
</dependency>
</dependencies>
Convert DWG to OBJ File Programmatically in Java
You need to follow the steps below to convert a DWG file to OBJ format:
- Create an object of the Image class to load the source DWG file.
- Type-cast formerly declared object to CadImage class.
- Export the DWG file to OBJ format with the Save method.
The code snippet below demonstrates how to convert DWG to OBJ file programmatically in Java:
Explore More Features
You may visit the documentation space to explore working with different CAD image formats. It covers working with different AutoCAD drawings in your projects.
Conclusion
In this article, you have learned the steps and the sample code snippet to convert DWG drawings to 3D Object files in OBJ format. Moreover, this article also explains the simple configuration details which do not require any other UI application. Please feel free to reach out to us at the forum for discussing any of your requirements or concerns.