home *** CD-ROM | disk | FTP | other *** search
/ BUG 11 / BUGCD1998_02.ISO / aplic / turbocad / tcw.z / Expoint.bas < prev    next >
BASIC Source File  |  1997-05-05  |  2KB  |  71 lines

  1. ' This sample program is an example of how to do custom file IO from
  2. ' TurboCAD. All vertices of selected graphics are output to a table
  3. '
  4. ' Author    : Mike Cartwright, Tamara Cartwright (updated to TurboCAD 4.0 interface)
  5. ' Date        : 01/08/96,  3/8/97
  6. 'Constants
  7. Global Const GK_GRAPHIC = 11
  8. Global Const NULL         = 0
  9.  
  10. Sub Main ()
  11.     Dim FileName As String
  12.     Dim myLine As String
  13.     Dim g As Long
  14.     Dim v As Long
  15.     Dim vi As Long
  16.     Dim vCount As Long
  17.     Dim gCount As Long
  18.     Dim i As Long
  19.     Dim fh As Long
  20.     Dim dActive As Long
  21.     
  22.         ' Check for valid drawing
  23.     dActive = TCWDrawingActive ()
  24.         If dActive = NULL Then
  25.            MsgBox "Program requires active drawing. Open any drawing and try again."
  26.            ' Terminate the program
  27.            Stop
  28.         End If
  29.        
  30.         ' Get the name of the output file.
  31.         FileName = InputBox("Type in the filename to export to")
  32.         If FileName <> "" Then
  33.         gCount = TCWSelectionCount()        
  34.         If (gCount = 0) Then
  35.             MsgBox "Need to have at least one graphic selected"
  36.             Stop
  37.         End If
  38.         
  39.           ' Open the output text file.
  40.         fh = TCWOpenOutput(FileName)
  41.        
  42.             ' Walk through the selected graphics and pick only
  43.             ' GK_GRAPHICS.
  44.         for i = 0 to gCount - 1
  45.             g = TCWSelectionAt(i)
  46.             if TCWGraphicPropertyGet(g, "Kind") = GK_GRAPHIC Then
  47.                 if vi > 0 then
  48.                     ' Place a blank line after the previous graphic
  49.                      TCWWriteOutput fh, ""
  50.                 End If
  51.                 
  52.                 vCount = TCWVertexCount(g)
  53.                 ' Iterate through the vertices of the graphic g.
  54.                 for vi = 0 to vCount - 1
  55.                     v = TCWVertexAt(g, vi)
  56.                     ' Write the coordinates of vertex v into the string Line.
  57.                     ' The delimeter for numeric fields is chr(9) character.
  58.                     myLine = Str$(vi) & chr$(9) & Str$(TCWGetX(v)) & chr$(9) & _ 
  59.                              Str$(TCWGetY(v)) & chr$(9) & Str$(TCWGetZ(v))
  60.                     TCWWriteOutput fh, myLine
  61.                 next vi            
  62.             End If
  63.         next i
  64.  
  65.         TCWCloseOutput fh
  66.                             
  67.     End If
  68.  
  69. End Sub
  70.