Copyright: ® Ideal Engineering (1995)


Contents
DXF Developer's Suite

•	Use the DXF-IN for VB library to easily display and manipulate 2D DXF files with Visual Basic.

•	Use the TurboDXF library to easily create DXF files with any Windows development tool including Visual Basic and Access.

Introduction

An introduction to the DXF-IN for VB and TurboDXF libraries.

Features

What the libraries can do.

Getting Started

Installing the demo. Things to try with the demo.

Developer's Overview

An overview of how to use the two libraries.

Ordering

Ordering information, pricing and features planned for future versions.

Ideal Engineering

How to contact us.

Disclaimer


Map

This is the sample DXF file (DXFSUITE.DXF) that is included with the demo. It is a street map of a subdivision, taken from an AutoCAD drawing. The DXF file was loaded into the DXFSUITE demo application and then saved as a Windows bitmap.


Getting Started

1.	To keep the electronic download times to a minimum a Setup program is not distributed with the demo. A diskette based demo is available that includes all the Visual Basic support files and an automated Setup program. Please see Ordering for details.

2.	To use this demo you must have VBRUN300.DLL already installed in your \WINDOWS\SYSTEM directory. VBRUN300.DLL is included on the Demonstration diskette.

3.	The ZIP file includes the following files:

To try the demo simply copy the files to the directories shown in the table. From Program Manager or File Manager run the DXFINVB.EXE or DXFOUTVB.EXE file.

Demonstration Application

An overview. How try all the features of the libraries.


Introduction

•	The DXF-IN for VB library allows you to easily display 2D DXF files in Visual Basic.

•	The DXF-IN for VB library is a combination Visual Basic BAS file and Windows DLL.

•	DXF files can be displayed in a standard picture control with as little as 2 function calls.

•	The companion TurboDXF library creates DXF files. This library is available as a DLL, Visual Basic source or Microsoft Access source. The demonstration application uses the Visual Basic version of the TurboDXF library to create DXF files.

The DXF-IN for VB library supports most of the commonly used features of the DXF definition. To keep the library open and easily modified and integrated, as much of it as possible was written in Visual Basic. When significant performance increases were achievable by moving specific functions to the DLL "engine", they were moved.

The companion TurboDXF library creates DXF files with a series of function calls. This library is frequently used with data base applications to create DXF drawings from the tables.

DXF and CAD files can become very large and complicated. Huge files created with the latest and most powerful hardware and software and containing hundreds of thousands of entities are probably not best suited for displaying with Visual Basic. You wouldn't tow an 20' Airstream trailer with a Honda Civic.

We have had a great deal of success integrating DXF display into applications where the files are of moderate size, up to about 4 or 5MB. The real power of this library is the ease with which you can display a DXF file and then leverage Visual Basic and the vast array of other add-ons to do build a truly imaginative and customized solution.

For more information please contact  Ideal Engineering

Features of the libraries

How they work

What are DXF files?


Ideal Engineering

#29 - 8560 162nd Street

Surrey, BC

Canada

V4N 1B4

(604) 572-8614

On CompuServe at 76625,2337


Displaying a DXF file

Two subroutine calls are all that is really necessary to load a DXF file with the DXF-IN for VB library:

'InFileName$ is the DXF file to load; form1.Panel3D1 is the percentage status bar

LoadDXF InFileName$, form1.Panel3D1

'Extents is the drawing limits, Picture2 is the control that will receive the DXF file, false indicates we are not creating a Windows metafile

Zoom Extents, Picture2, false


How it works
How the Librairies Work

DXF-IN for VB is a combination Visual Basic BAS file and a compiled DLL graphics "engine".

1.	The Visual Basic .BAS file contains all the file and array manipulation routines. These routines read and parse the DXF file and create an internal drawing data base. In Visual Basic this internal data base can be up to 64MB.

2.	A companion Windows DLL (DXFIN.DLL) contains scaling and mapping routines as well as Windows API drawing routines.

3.	The TurboDXF export library can be used with the DXF-IN for VB library. TurboDXF is used to create DXF files. For example you can load a large DXF file, zoom in on a smaller area and then save the zoomed area as a new, smaller DXF file.


What are DXF files?

The AutoCAD drawing database (.dwg file) is written in a  compact format that changes significantly as new features are added to AutoCAD, AutoDesk does not document its format and does not recommend that you attempt to write programs to read it directly.

To assist in  interchanging drawings between AutoCAD and other programs, AutoDesk created a Drawing  Interchange file format (DXF). All implementations of AutoCAD and many other Windows and non-Windows applications can read and/or write this format.

A Drawing Interchange File is simply an ASCII text file with a file type of .dxf and specially formatted text.


Features of the library
Features of the DXF-IN for VB library

Features of the TurboDXF Library

Add DXF support to the standard Visual Basic picture control!

Support for industry standard 2-D DXF files

Support for drawing layers and colors by layer. Layers can be turned on and off. Layer colors can be changed. Entities can be colored based on their entity color or the layer color.

Demo application shows many techniques usually found in high end CAD packages such a right-click "on the spot" zooming, "bird's eye" window and panning.

Support for text and rotated text. Text is only drawn when it is big enough to see, using TrueType fonts.

Support for lines and polylines (thick lines)

Support for 3 and 4 point filled solids

Support for circles and arcs

Standard version supports an internal drawing database of up to 64MB or up to 32,000 drawing entities.

Drawing engine is a small DLL using standard API calls for speed.

Extensive Windows Help file explaining library usage and strategies.

A variety of sample applications are available with your order. These include a very simple DXF reader, a simple GIS-style interface (click on the drawing to search an Access data base)

DXF-IN for VB works with Ideal Engineering's companion TurboDXF library to save manipulated DXF files and zoomed views. Allows you to "clip out" parts of larger DXF files.

Color and B & W printing of current window

Save full drawing or current window as a Windows metafile (.WMF)

Save full drawing or current window as a Windows bitmap (.BMP)


Features of the TurboDXF Library

•	Create DXF files from Visual Basic, Microsoft Access, Turbo Pascal or any other Windows development tool

•	Support for lines, polylines, circles, arcs, text, layers, solids etc.

•	Available as a compiled Windows DLL or as source code

•	Support for AutoCAD text and line styles

•	Works great with data base applications to create a drawing from the data

•	Source code version includes source code for Visual Basic, Access and Turbo Pascal/Delphi. Combine DXF "primitives" into your own application specific functions.


Samples
Demonstration Application

•	The demonstration application shows the features of both the DXF-IN for VB and TurboDXF librairies.

•	The demo ships with a sample DXF file called DXFSUITE.DXF. To try the features of the library run the demo (DXFSUITE.EXE) and then load DXFSUITE.DXF following the directions below.

•	All the points that follow assume DXFINVB.DXF is loaded. You can load any other 2D DXF file into the demo. Note the DXF file limitations in this Help file. The demonstration drawing is a drawing of a sub-division taken from a Microstation DGN drawing.

Things to try:

1.	To make it easier to follow along, print this topic.

2.	Load DXFSUITE.DXF by clicking on the first button on the button bar, or from the File menu.

3.	Try zooming in with the "+" magnifying glass button. Click left, hold, drag and release.

4.	Zoom in again (on a smaller area).

5.	Click the "-" magnifying glass to "zoom previous".

6.	Click the right button to zoom on the spot (stationary zoom). The default is 125% but this can be changed under the Zoom | Stationary zoom menu. Notice how the "pick point" stays under the mouse while the drawing zooms in.

7.	Pan with the "Pan" button. Click the button then click left, drag and release.

8.	While zoomed in click on the "birds eye" window  to zoom to a new position. Turn the birds eye window on and off with the "eye" button on the toolbar.

9.	Turn layers on and off with the layers control panel. Click the "layers" button to open the panel. Double click on a row to toggle a layer on or off. When you dismiss the dialog the drawing will be refreshed to show any changes.

10.	Zoom in on four or five lots. Pick "Zoom to text" from the Zoom menu. A dialog opens with all the text strings in the drawing in a list box. Scroll up and down the list and select an entry. Click on the "Zoom" button to re-zoom to that text string. The drawing will be panned to center the text string in the window while maintaining the current zoom.

11.	Zoom in on four or five lots and click "Save current view as DXF file" from the File menu. Save the file as DXF2.DXF. The current view will be exported as a new DXF file using the TurboDXF library. Now open the newly created DXF file (DXF2.DXF) with the "File Open" command or button.

12.	Try creating two (or more) separate DXF files from different views of the same drawing. For example zoom in to the upper left quarter of the map. Click "Save current view as DXF file" from the File menu Call it DXF3.DXF. Next zoom in to the upper right quarter of the map. Save this as DXF4.DXF. Now open DXF3.DXF. Just the upper left quarter of the map appears. From the file menu choose "Add a DXF file to the current view". Select DXF4.DXF. The drawing is put back together!

13.	Click on the Annotation button (the Pencil on the toolbar). This lets you annotate the drawing. Click in the middle top of the drawing (in an open area) and add the text "Subdivision Plan". Click the mouse, the text is added to the drawing. Zoom in or out and the text is still there. If you save the drawing as a DXF file it will be added to the new file, if the layer the annotation is on is turned on. Note that the text is added to what ever layer is the "current layer" as set by the combo box on the tool bar. You can add a new layer from the layer dialog box if you want all the annotations on a specific layer.

14.	You can measure things in the drawing from the Zoom menu. Click left, drag and release. A message box will give the length etc.

15.	The "Show" menu shows all the entities from the internal drawing data base in a grid.


Programming Overview
Developer's Overview

How to create a DXF file with TurboDXF

The default configuration of the DXF-IN for VB library requires:

1.	The name of the DXF file you want to load. The demo uses the Windows file common dialog to get the file name.

2.	The Visual Basic picture control that will accept the DXF file. Modifications to the BAS module allow you to display the DXF file on any control that has an hWnd and hDC property.

3.	A status control capable of showing "percent complete". The demo uses the THREED.VBX that ships with the professional version of Visual Basic. DXF files can get quite large and displaying a status bar while the file is being loaded is usually necessary. Once loaded into memory the redraws occur quickly enough that an hourglass is usually sufficient.

Once a DXF file is loaded into the internal drawing data base the programmer can use it as he/she sees fit.

Typically this will involve displaying the drawing. The Zoom subroutine takes as parameters a rectangle defining the corners of the required view and the control on which to draw the image.

The programmer does not have to display the image. For example if you wanted to calculate the sum length of all the lines on a certain layer of a DXF file you could read it in to memory and then sum up the lengths with a simple loop. Once the DXF file is in memory there are many non-graphical and non-typical uses.

See How it Works.


License information and pricing
Ordering Information

Future releases


The DXFIn 3.0 library will support
Unsupported features and the next release

•	This version of the library does not support blocks or block insertions. An easy way around this is to simply EXPLODE all the blocks in the native drawing before saving it as a DXF file. Version 3.0 will support blocks.

•	This version uses standard Visual Basic huge arrays. This imposes a limitation of 32,767 entities (array elements) or 64MB of data. In testing it appears that a typical DXF file will reach the array element limit at around 5 to 6MB. Version 3.0 will use a third party array manager to break the array element limitation

•	This version does not support all the features of AutoCAD dimensioning. The dimensions created by many CAD packages however are stored as line, solid and text entities and are fully supported. Version 3.0 will support a basic sub-set of the AutoCAD dimensioning commands.

•	This version does not use the linestyle table in the DXF file. All lines are drawn as solid lines. Version 3.0 will use Windows default linestyles in addition to solid lines.


Disclaimer

Copyright 1994, 1995 Ideal Engineering. All rights reserved. DXF-IN for VB and TurboDXF are trademarks of Ideal Engineering. All other products are registered trademarks of their manufacturers.

Ideal Engineering retains title and copyrights to the library, accompanying documentation and any
legitimate backup copy made by you. Unauthorized copying of the program or the
accompanying documentation, or failure to comply with the above restrictions will result
in automatic termination of this license.

LIMITED WARRANTY AND DISCLAIMER:

IDEAL ENGINEERING MAKES NO WARRANTIES, EXPRESS, IMPLIED, STATUTORY OR IN ANY COMMUNICATION WITH YOU, AND IDEAL ENGINEERING SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

LIMITATION OF LIABILITY
IN NO EVENT WILL IDEAL ENGINEERING BE LIABLE FOR ANY DAMAGES, INCLUDING LOSS OF DATA, LOST PROFITS OR OTHER SPECIAL, INCIDENTAL, CONSEQUENTIAL OR INDIRECT DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE OR ACCOMPANYING DOCUMENTATION, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY. THIS LIMITATION WILL APPLY EVEN IF IDEAL ENGINEERING HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. YOU ACKNOWLEDGE THAT USING THIS SOFTWARE REFLECTS THIS ALLOCATION OF RISK.

IDEAL ENGINEERING SHALL NOT BE LIABLE FOR THE RESULTS OBTAINED THROUGH THE USE OF TurboDXF OR DXF-IN for VB. PERSONS USING TurboDXF OR DXF-IN for VB ARE RESPONSIBLE FOR THE SUPERVISION, MANAGEMENT, AND CONTROL OF THIS SOFTWARE. THIS RESPONSIBILITY INCLUDES, BUT IS NOT LIMITED TO, THE DETERMINATION OF APPROPRIATE USES FOR TurboDXF OR DXF-IN for VB AND THE SELECTION OF TurboDXF OR DXF-IN for VB AND OTHER PROGRAMS TO ACHIEVE INTENDED RESULTS. PERSONS USING TurboDXF OR DXF-IN for VB ARE ALSO RESPONSIBLE FOR ESTABLISHING THE ADEQUACY OF INDEPENDENT PROCEDURES FOR TESTING THE RELIABILITY AND ACCURACY OF ANY PROGRAM OUTPUT, INCLUDING ALL ITEMS DESIGNED BY TurboDXF.


Creating a DXF file

The procedure to create a DXF file is:

1	Create and open an ASCII file

2	Add some header data (drawing limits, layer names and colours etc.)

3	Add all the entities (lines, arcs, polygons, text etc.), normally in a control loop

4	Close the DXF file