[futurebasic] Re: DXF Files into FB

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: Robert Covington <t88@...>
Date: Sun, 30 May 1999 21:09:05 -0700 (MST)
>Hi all,
>
>Does anybody know where I can get information on the DXF file/record
>structure?
>
>TIA
>
> Ian Mann

Go here:

<http://www.mhri.edu.au/~pdb/>

Paul Bourke's site, makes it fairly clear. Has the spec's on DXF 10 and 12 releases or later. 
Also, <http://www.wotsit.org> If you can't find them, let me know, I can email them to you.

I haven't gotten my own DXF importer written just yet, because I haven't needed it at this point, but I do have a working DXF exporter for triangular 3D facets in FB that tailored to my own application.

I have attached below an incomplete FB port of Bourke's DXF exporter in C from a library I got off his site. It needs some additions for an array of XYZ points and edge/poly list and some better handling of n, which I think is used for going though the edge list. I found it helpful to export simple squares or rectangles from Ray Dream and Strata Vision 3D and Poser 3 to see how they handle things themselves. 

For importing 3D Faces, you are going to generally need an array for the XYZ vertices, an edge list array, and a polygon array, all cross referenced/pointing to the vertices by number,typically.

Let me know what you come up with.

Robert Covington



COMPILE 0,_dimmedVarsOnly
'Constants
_myLine   = 2
_3DFace = 4
DIM gFileName$
END GLOBALS

'end constants, there are more for PolyLine, etc.

'Write a DXF header
LOCAL MODE

LOCAL FN WriteDXF(X,Y,Z,n)
  DIM x
  DIM y
  DIM z
  DIM n
  DIM i
  DIM gFileName$
  'n=NumPoints 
  DIM volRefNum%
  
  DEF OPEN "TEXTttxt"
  
  OPEN "O", 1, gFileName$,,volRefNum% 
  
  PRINT #1, "999"
  PRINT #1, "DXF from FutureBasic"
  PRINT #1, "0"
  PRINT #1, "SECTION"
  PRINT #1, "2"
  PRINT #1, "HEADER"
  PRINT #1, "0"
  PRINT #1, "ENDSEC"
  PRINT #1, "0"
  PRINT #1, "SECTION"
  PRINT #1, "2"
  PRINT #1, "ENTITIES"
  
 
  '  WriteDXFFacet  XYZ(or point),n)

  
  FOR i=0 TO NumPts
    
    	LONG IF (n < 2)
      RETURN
    END IF
    		
    
    	SELECT n 
      	CASE _myLine
        		PRINT"0"
        		PRINT "LINE"
        		FOR i=0 TO n
          PRINT #1, STR$(10+i)
          PRINT #1, STR$(x(i))  
          PRINT #1, STR$(20+i) 
          PRINT #1, STR$(y(i)) 
          PRINT #1, STR$(30+i) 
          PRINT #1, STR$(z(i)) 
        NEXT i
        
      CASE 3
        
        'Undeclared at the moment
        
      	CASE _3DFace
        	
        		PRINT #1, "0"
        		PRINT #1, "3DFACE"
        		
        		FOR i=0 TO n                'n = number of vertices
          		
          PRINT #1, STR$(10+i)
          PRINT #1, STR$(x(i))	
          PRINT #1, STR$(20+i))
          PRINT #1, STR$(y(i))  
          PRINT #1, STR$(30+i)
          PRINT #1, STR$(z+i))
          
          	LONG IF n = 3
            PRINT #1, 13
            PRINT #1, STR$(x(2))  
            PRINT #1, 23
            PRINT #1, STR$(y(2))  
            PRINT #1, 33
            PRINT #1, STR$(z(2))  
          	END IF
          	      
        	   NEXT i
        
    END SELECT
       
  NEXT i
  
  ' Write a DXF footer
  
  PRINT "0"
  PRINT "ENDSEC"
  PRINT "0"
  PRINT "EOF"
  
  CLOSE #1
  
END FN