Summary :
export data to a CAD environment like AUTOCAD.(by Toby Borland) (April 2004). 					

Description :
This macro has been tested on AutoCAD 2002. The code should be adequately
commented for readability, also included within the comments is the technical
source from which the code is derived.
The macro limits itself to outputs ('POINT', '3DFACE', 'POLYLINE' + variants)
which may use discrete points, the rationale is documented within the macro.
The input can be vector or matrix depending on whether a surface or line is
desired. Scan the code for the input parameters which should be reasonably
self-explanatory

// The format is based around the Autodesk AutoCAD R11 specification for .DXF
files 
//
// input		input flag options	DXF output
//
// 2..3 coords					POINT
//				'POINT'--------> for arrays of points
// >6 vectors/matrices coords			POLYLINE + VERTICES
//				'closed'
//				'polyface'
//				'tessa'
//				'N_closed'
// matrices			'3DFACE'	3DFACE
//				'layer=[?..?]'
//				'color=[-256(?)..256]'
//				'handle_offset=??'
//
// assume polyline if vector input given
// assume polymesh if matrix input given and 'POINT' not specified

'tessa' may require some explanation. This is a format whereby input matrices
can create triangular meshes.

Basically:

(0,0) - (0,1) - (0,2) - ... (0,m)
  | \     | \     | \         |
  |  \    |  \    |  \    .   |
  |   \   |   \   |   .    .  |
  |    \  |    \  |    .    \ |
(1,0) - (1,1) - (1,2) - ... (1,m)
  | \     | \     | \         |
  |  \    |  \    |  \    .   |
  |   \   |   \   |   .    .  |
  |    \  |    \  |    .    \ |
(2,0) - (2,1) - (2,2) - ... (2,m)
  | \     | \     | \         |
  .  .    .  .    .  .    .   .
  .   .   .   .   .   .    .  .
  .    .  .    .  .    .    \ .
(n,0) - (n,1) - (n,2) - ... (n,m)

so the first triangle is formed by the elements {X(0,0), Y(0,0)},{X(1,0),
Y(1,0)},{X(1,1), Y(1,1)} where X and Y are n x m matrices. Note Z is optional,
a matrix of zeros is created if  no Z coords are given, or if a single value is
given, this is treated as z .* ones(size(X,1), size(X,2))

In other words diagonal connections are drawn.

					

Corresponding Author : Toby Borland
File Name : writeDXF.lsm
File Name : writeDXF.sce


Your comments

Reviewer : dfendel@club-internet.fr
Hi
very useful... do you have "readDXF" ?
Thanks		


Reviewer : tobyborland@hotmail.com
When using this program in conjunction with AutoCAD 2003(R), set  the 
Vx_3D_Polyline bit on line 370 to 1, otherwise AutoCAD performs an "audit" on
the data and deletes everything. Other CAD programs tested show no difficulty

I am currently considering a readDXF version; trickier format		

Number of Comments :2

Leave your comment

Your email address :
Your rate : Love it  Useful Just OK none
Comments :


Confirmation code :

Enter the code exactly as you see it.
The code isn't case sensitive.