Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Display vector formats in VFP?
Message
De
24/02/1998 03:49:09
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00080619
Message ID:
00080708
Vues:
23
>A current application needs to read an AutoCAD or DXF file format drawing and display it, associated with the record for that image. To date, I've been grabbing the image as a BMP - but it'll be MUCH slicker, mor compact and more readable if I can just use vector.
>
>I did an APPEND GENERAL to bring in a DXF, but VFP could not display it. What am I looking for and where shall I look?
>
>TIA
First I refer to DXF not DWG. DXF is a plain ASCII text file holding vector data, polylines, layers etc. You could read that file and interpret, then draw using VFP line, shape etc controls. Of course it wouldn't be in the way AutoCAD does but at least you would have the drawing. I used only line sections to draw maps and here is the code if helps :
parameters lOverDraw
if parameters() < 1 
	lOverDraw = .f.
endif	
if !lOverDraw
	clear
endif	
set talk off
close all
do while .t.
	infile = getfile("DXF")
	if empty(infile)
		exit
	endif
	outfile = left(infile,rat(".",infile))+"XYZ"
	=convert(infile,outfile)
	lOverDraw = .t.
enddo
	
function convert
parameters infile, outfile
h1 = fopen(infile)
create cursor tXYZ (x1 n(10,6), y1 n(10,6), z1 n(10,6), x2 n(10,6), y2 n(10,6), z2 n(10,6))

do while !feof(h1)
	msection=upper(alltrim(fgets(h1,500)))
	if msection = "LINE"
		=getxyz()
	endif
enddo
=fclose(h1)
h2 = fcreate(outfile)
select tXYZ
calculate max(x1), max(x2) ,max(y1), max(y2) to maxx1, maxx2, maxy1, maxy2
nConst = _screen.height / max(maxx1, maxx2, maxy1, maxy2)

_screen.forecolor = iif(lOverDraw,rgb(255, 0 ,255),rgb(0,0,0))
go top
_screen.pset(x1*nConst,y1*nConst)

scan for !(x1 = x2 and y1 = y2)
	=fputs(h2,str(x1,10,6)+","+str(y1,10,6))
	=fputs(h2,str(x2,10,6)+","+str(y2,10,6))
	_screen.line(x1*nConst,y1*nConst)
	_screen.line(x2*nConst,y2*nConst)
endscan
=fclose(h2)



function getxyz
do while !feof(h1)
	m.firstid = alltrim(fgets(h1))
	if isalpha(m.firstid)
		if m.firstid # "CONTINUOUS"
			return
		else
			loop
		endif	
	endif
	if !(m.firstid == "10")	&& Discard x1 identifier
		loop 			
	endif	
	m.x1 = val(fgets(h1))
	if !(alltrim(fgets(h1)) == "20")	&& Discard y1 identifier
		loop 			
	endif	
	m.y1 = val(fgets(h1))
	if !(alltrim(fgets(h1)) == "30")	&& Discard z1 identifier
		loop 			
	endif	
	m.z1 = val(fgets(h1))
	if !(alltrim(fgets(h1)) == "11")	&& Discard x2 identifier
		loop 			
	endif	
	m.x2 = val(fgets(h1))
	if !(alltrim(fgets(h1)) == "21")	&& Discard y2 identifier
		loop 			
	endif	
	m.y2 = val(fgets(h1))
	if !(alltrim(fgets(h1)) == "31")	&& Discard z2 identifier
		loop 			
	endif	
	m.z2 = val(fgets(h1))
	insert into tXYZ from memvar
enddo
It writes out a XYZ file (X, Y, Z values for vectors) and draw on screen. If lOverdraw if .f. doesn't clear the screen (to compare a time series drawing).
As I remember this was for shorelines. So I might have missed ie: islands. Pls check with a test DXF.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform