Perforce JViews Framework Sample: Reading a DXF File
Description
This sample shows how to read DXF files in Perforce JViews.
How to Use the Sample
-
The demonstration automatically loads the file
resources/namap.dxf
. - You can select the DXF file to import by pressing the "Load" button.
How to Run the Sample as an Application
This sample can
be run as an application.
The installation directory contains
an executable JAR file,
jviews-dxf-reader.jar
,
that allows you to execute the sample with a double click from a
file browser. Note that if you are using Internet Explorer, you can
open the installation directory
and execute the JAR file from the browser. This
technique may not work in other Web browsers.
Alternatively, you
can run the sample application from the command line.
First check that the Ant utility is properly configured. If not, see the
instructions on how to configure Ant for Perforce JViews.
Then, go to the installation directory
of the sample and type:
ant run
Topics Covered
- Reading DXF Files.
- Converting DXF Files to IVL Files.
Detailed Description
This sample shows how to read DXF files by using the DXF reader provided in Perforce JViews.
Using the DXF Reader
The DXF Reader can be used in other applications. To read a DXF file, you can write the following code:
IlvManager manager = new IlvManager(0); // with no layer IlvDXFReader reader = new IlvDXFReader(); try { reader.read("myDXFFile.dxf", manager); } catch (IOException ex) { ex.printStackTrace(); }The
read
method of the IlvDXFReader
reads the DXF file
and adds the graphic objects defined in the DXF file to the manager.
If an error occurs during this process, an exception of the type
IOException
can be thrown that must be caught.
About the DXF Format
The DXF format (Drawing Interchange Format) is the interchange format of AutoCAD. This format supports vector graphics (polygons, arcs, lines, points, ...) and layers.
A sample DXF file is provided with this sample.
Installation Directory
The Reading a DXF File sample is installed here.