Hot File

Simple DXF Reader/Viewer with Spline Support

View: 1403    Dowload: 2   Comment: 0   Post by: naruto  
Author: none   Category: Autodesk AutoCAD   Fields: Computers - Technology

6 point/6 review File has been tested

Download   simple-dxf-reader-viewer-with.zip (624.67 KB)

You need to Sign In to download the file simple-dxf-reader-viewer-with.zip
If you do not have an account then Sign up for free here

Download error   Report copyright violation

Is your email address OK? You are signed up for our newsletters but your email address is either unconfirmed, or has not been reconfirmed in a long time. Please click here to have a confirmation email sent so we can confirm your email address and start sending you newsletters again. Alternatively, you can update your subscriptions.

Introduction

Introduction

The aim of this tip is to deal with DXF files with the most common AutoCAD entities.

Background

I searched a DXF reader source code in the CodeProject archive and found two articles. One is A DXF Reader Solution and Simple DXF Viewer by Evren Daglioglu, another is DXF Import .NET: Read and View AutoCAD Format Files by Chuzhakin. Both are C# code and have no spline solution. In the comments of these articles, I have seen that other developers need it. So, I decided to implement a basic DXF reader supporting spline entity. I used C++ classes to provide you easy integration of reader to your project. Hope to help you.

General

Line, lwpolyline, arc, circle and spline entities are supported. All the entities in the file are loaded into proper classes when the file is opened. Afterwards, they are drawn on the screen. Highlight and selection of each entity, indication of points, sliding, zoom in, zoom out and pan zoom functionalities are available.

Using the Code

The source code is organized by C++ classes to provide you easy integration into your own code. CLine, CPolyline, CArc, CCircle and CSpline classes are used to hold the entities. These classes are in very basic structure. You may improve them for your own purposes. CDxf class is used to hold the file. Use LoadFile member function of CDxf class to hold the file. In order to load sample.dxf file, use the following code:


CDxf m_dxf;
m_dxf.Init();
m_dxf.LoadFile("sample.dxf");

All the entities are loaded to proper classes by LoadFile function. CDxf class has member variables of CLine, CPolyline, CArc, CCircle and CSpline. The number of each entity can be obtained. For example; to get how many circle entity is available in the file, use GetCircleCount member function. The number of line, lwpolyline, arc and spline entity can be got in a similar way.


UINT iCircleCount;
iCircleCount = m_dxf.GetCircleCount(); 

After loading all the entity in CDxf class, they are drawn on the screen. I used several strings for layer entry to draw each entity in different colors. If the layer of an entity is not one of these strings, the entity color is green default. Modify SelectLayer function with your own strings. Drawing of spline entity is a little bit different. I don't use the poly bezier drawing functions of MFC. I generated the intermediate points between given spline vertices. By the way, you can use these points for different purposes other than drawing.


//fx and fy hold x anf y coordinate values of given spline vertices.
//iCount is the number of generated spline points.
//points are the generated spline points.

int iCount = 0;
float fx[128],fy[128];
POINT points[65535];
 
for(UINT i = 0; i < m_dxf.GetSplineCount(); i++)
{
    //Load fx and fy array from CSpline
    //...

    Spline spline(fx,fy,m_dxf.m_Spline[i].m_FitPointCount);
    spline.Generate();
    spline.GetCurve(points,iCount);
}   

The source code, binary, and a sample dxf file are in a single zip file. Download and explore the source code. Have fun...

DXF Standard

DXF standard is an open ASCII format supplied by Autodesk. Plenty of information is available on the net. If these five entities solve your problem, you don't need to deal with the standard. Just use the classes.

License

This article, along with any associated source code and files, is licensed under

Simple DXF Reader/Viewer with Spline Support

Simple DXF Reader/Viewer with Spline Support Posted on 21-03-2014  Is your email address OK? You are signed up for our newsletters but your email address is either unconfirmed, or has not been reconfirmed in a long time. Please click here to have a confirmation email sent so we can confirm your email address and start sending you newsletters again. Alternatively, you can update your subscriptions. 1/10 1403

Comment:

To comment you must be logged in members.

Files with category

  • Ground Modelling information using AutoCAD

    View: 222    Download: 1   Comment: 0   Author: none  

    Ground Modelling information using AutoCAD

    Category: Autodesk AutoCAD
    Fields: Other

    2.25/2 review
    This tutorial describes how to create a 3D surface model from contour information using AutoCAD and Key TERRA-FIRMA. The requirement to visualise terrain in 3D, whether existing or proposed is very common in the environmental design professions.

  • 3D Tree Exercise in AutoCAD

    View: 254    Download: 1   Comment: 0   Author: none  

    3D Tree Exercise in AutoCAD

    Category: Autodesk AutoCAD
    Fields: Other

    2.25/2 review
    It is quite difficult to construct convincing looking 3D trees in AutoCAD, however, with a few simple 3D commands at your disposal you should be able to create something which is identifiable as a tree and perhaps hint at a species.

  • Create Basic 3D and Surface Modelling

    View: 257    Download: 1   Comment: 0   Author: none  

    Create Basic 3D and Surface Modelling

    Category: Autodesk AutoCAD
    Fields: Other

    2.25/2 review
    Although AutoCAD has a number of commands for creating special 3D objects, a lot can be achieved by changing the properties of basic 2D objects like polylines. Most 2D objects can be given a thickness using the thickness option in the Properties...

  • Document Model AutoCAD Meshes to Bryce

    View: 261    Download: 0   Comment: 0   Author: none  

    Document Model AutoCAD Meshes to Bryce

    Category: Autodesk AutoCAD
    Fields: Other

    1.5/3 review
    Although you can create very realistic terrain objects in Bryce, it is often difficult to get them to look just like a real place. However, you can use Key Terra-Firma with AutoCAD to create an accurate terrain model from contour or other height...

  • Using AutoCAD to Bryce

    View: 322    Download: 1   Comment: 0   Author: none  

    Using AutoCAD to Bryce

    Category: Autodesk AutoCAD
    Fields: Other

    1.3333333333333/3 review
    This tutorial explains how to take a model built in AutoCAD into Bryce, how to assign materials to the various components of your model,how to use image textures, how to create a simple setting and how to render the resulting scene. Although the key...

  • DXF Import .NET: Read and View AutoCAD Format Files

    View: 2366    Download: 4   Comment: 0   Author: none  

    DXF Import .NET: Read and View AutoCAD Format Files

    Category: Autodesk AutoCAD
    Fields: none

    0/5 review

  • Writing AutoCad DXF files

    View: 1991    Download: 2   Comment: 0   Author: none  

    Writing AutoCad DXF files

    Category: Autodesk AutoCAD
    Fields: Art - Photography

    0/3 review
    This article demonstrate how to write an ASCII DXF files. A DXF file is a file composed of sections and associated values. They are read by AutoCad and then converted to a drawing.

  • Catalogo ETABS v9.6 Documentation

    View: 857    Download: 1   Comment: 0   Author: none  

    Catalogo ETABS v9.6 Documentation

    Category: Autodesk AutoCAD
    Fields: Interior Design - Building

    0/2 review
    For nearly 30 years, ETABS has been recognized as the industry standard for Building Analysis and Design Software. Today, continuing in the same tradition, ETABS has evolved into a completely Integrated Building Analysis and Design Environment. The...

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd