How Autocad Can Work with Java

Using an autocad java interface is the easiest way to get the two very different platforms to work in concert with one another. Fortunately C++ has an AutoCAD plugin that works with it, and the two languages aren’t dissimilar so Java programmers might want to give that a try. Basically the bridge utilities JNI and takes Java calls before turning them into C++ and converting that to C#, which is then used by AutoCAD.

Doing Some Conversions

While it would be possible to use COM objects in a java autocad interface and have the AutoCAD plugin call them there is one way that might be easier. The Open Design Alliance has been pushing the Teigha platform system for engineering applications for some time. They have a C++ SDK that can work with .dwg files, but perhaps most importantly they have a Teigha system for Java based web applications.

That converts between .dwg and .dxf files and makes them into .pdf and .bmp files, which are readily useable on the web and with Java. It’s very easy to use the file converter. While it doesn’t work literally with the AutoCAD software, it’s not hard to save a file in AutoCAD and then upload it into Java.

Those who want to import .dwg to a C# interface so that it can be back converted into Java might want a little code to do so. A layer loop might help:

if(drawing layers == "1layer")
messagebox.show("1layer is the current layer!")
else
this.close();

Something like that will help define each layer, so it can be perfected before back-conversion to Java.

autocad java

image credit: kotaku.com.au

Interfaces Will Work

Even though java Swing autocad interfaces might end up needing the assistance of professional programmers, they will eventually start to work. The two platforms are dissimilar, though, so that’s a big thing people should watch out for. Adding the conversion layers will make things slow down quite a bit. Give the computer ample time to work through, and if its in an organizational structure make sure that the computer or device in question doesn’t run too many other processes at the same time.

You may check more Java sample codes our writers >>>.