Hello all,
I became intrigued by the discussion on converting dxfs, so I wrote my own. I'm
releasing it as code so that people can modify it for the many different flavors of
dxfs they may encounter. Also, it is only set up for lines, points and polylines at
this point. It includes the option of disregarding a specific Z value. Simply cut out
the grc code and gxc code and compile them. I'll leave it to someone else to add a
progress bar, or other options.
I will set up a web page in a couple of days with the code and a compiled gx.
cheers,
Marc
//--------- DDXF2XYZ.GRC ------------------------------------------------------
RESOURCE,FORM,DDXF2XYZ,"Convert a dxf to XYZ",1
FEDIT ,,,30,"DXF file",R,OLD,,,*.dxf
FEDIT ,,,30,"XYZ file",R,,,,*.xyz
EDIT ,,,5, "Dummy value",,REAL
EBUT,&OK,0
EBUT,&Cancel,1,cancel
//========= DDXF2XYZ.GXC =====================================================
NAME = "DDxf2XYZ - Convert a 3D dxf to an XYZ file"
VERSION = "v1.00 copyright 2000 Data Donkey"
DESCRIPTION = " It's FREE!
Currently only works for points, lines and polylines
created by Marc Pelletier ([EMAIL PROTECTED])
August 21, 2000
"
//===========================================================================
RESOURCE="DDxf2XYZ.gr"
#include "DDxf2XYZ.grh"
//===========================================================================
#include <all.gxh>
//===========================================================================
// VARIABLES
//===========================================================================
real rX, rZ, rTest;
string(GS_MAX_PATH) sInFile, sOutFile, sInLine, sOutLine;
int IsEntity,iEOF;
DGW Diag;
RA InFile;
WA OutFile;
//===========================================================================
// Main loop
//===========================================================================
{
// --- Are we running interactively ? ---
if (iInteractive_SYS()) {
// --- Create the Dialogue ---
Diag = Create_DGW("DDXF2XYZ");
SetInfoSYS_DGW(Diag,_DDXF2XYZ_0,DGW_FILEPATH,"DDXF2XYZ","DXF");
SetInfoSYS_DGW(Diag,_DDXF2XYZ_1,DGW_FILEPATH,"DDXF2XYZ","XYZ");
SetInfoSYS_DGW(Diag,_DDXF2XYZ_2,DGW_TEXT,"DDXF2XYZ","DUMMY");
// --- Run the Dialogue ---
if (iRunDialogue_DGW(Diag) != 0)
Cancel_SYS();
// --- Put values back in INI ---
GetInfoSYS_DGW(Diag,_DDXF2XYZ_0,DGW_FILEPATH,"DDXF2XYZ","DXF");
GetInfoSYS_DGW(Diag,_DDXF2XYZ_1,DGW_FILEPATH,"DDXF2XYZ","XYZ");
GetInfoSYS_DGW(Diag,_DDXF2XYZ_2,DGW_TEXT,"DDXF2XYZ","DUMMY");
// --- Destroy the Dialogue ---
Destroy_DGW(Diag);
}
// --- Get Variables ---
GetString_SYS("DDXF2XYZ","DXF",sInFile);
GetString_SYS("DDXF2XYZ","XYZ",sOutFile);
rTest = GetReal_SYS("DDXF2XYZ","DUMMY");
// --- Open Files ---
InFile = Create_RA(sInFile);
OutFile = Create_WA(sOutFile,0);
// --- Read Write Loop ---
iEOF = 0;
IsEntity = 0;
while ( iEOF != 1)
{
iEOF = iGets_RA(InFile,sInLine); // read one line
rX = ScanR_STR(sInLine);
if (rX == 0.0) {
iEOF = iGets_RA(InFile,sInLine);
TrimSpace_STR(sInLine,3);
if ((iStrcmp_STR(sInLine,"VERTEX",0) == 0) || // used for polylines
(iStrcmp_STR(sInLine,"INSERT",0) == 0) || // used for points
(iStrcmp_STR(sInLine,"LINE",0) == 0)) {
IsEntity = 1;
} else IsEntity = 0;
}
else if ((IsEntity) &&
((rX == 10.0) || (rX == 11.0))) {
iEOF = iGets_RA(InFile,sInLine);
Justify_STR(sInLine,sInLine,12,2);
Strcpy_STR(sOutLine,sInLine);
iEOF = iGets_RA(InFile,sInLine);
iEOF = iGets_RA(InFile,sInLine);
Justify_STR(sInLine,sInLine,12,2);
Strcat_STR(sOutLine,sInLine);
iEOF = iGets_RA(InFile,sInLine);
iEOF = iGets_RA(InFile,sInLine);
rZ = ScanR_STR(sInLine);
if (rZ != rTest) {
Justify_STR(sInLine,sInLine,12,2);
Strcat_STR(sOutLine,sInLine);
Strcat_STR(sOutLine,"\n");
Puts_WA(OutFile,sOutLine);
}
}
}
// --- Close Files ---
Destroy_RA(InFile);
Destroy_WA(OutFile);
}
---------------------------------------------------------------------------
Data Donkey - Geophysical Data Processing, Consulting and Software Development
Creator of the POWER TOOLBOX utilities for OASIS montaj
contact: mailto:[EMAIL PROTECTED] tel (306) 931-6853 or http://www.datadonkey.com
_______________________________________________________
More mailing list info http://www.geosoft.com/support/listserv/index.html