home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2002 March
/
PCWMAR02.iso
/
software
/
turbocad
/
V4
/
tcw.z
/
Expoint.bas
< prev
next >
Wrap
BASIC Source File
|
1997-10-28
|
2KB
|
79 lines
' This sample program is an example of how to do custom file IO from TurboCAD. All vertices of selected graphics are output to a table.
'
' Author : Mike Cartwright, Tamara Cartwright, Natalia Karaseva (updated to TurboCAD 4.0 interface)
' Date : 01/08/96, 3/8/97, 09/30/97
'
'Constants
Global Const GK_GRAPHIC = 11
Sub Main ()
Dim FileName As String
Dim myLine As String
Dim myInf As String
Dim g As Long
Dim v As Long
Dim vi As Long
Dim vCount As Long
Dim gCount As Long
Dim i As Long
Dim fh As Long
Dim dActive As Long
' Check for valid drawing
dActive = TCWDrawingActive ()
If dActive = 0 Then
MsgBox "Program requires active drawing. Open any drawing and try again."
' Terminate the program
Stop
End If
gCount = TCWSelectionCount()
If (gCount = 0) Then
MsgBox "Need to have at least one graphic selected"
Stop
End If
' Get the name of the output file.
FileName = InputBox("Type in the filename to export to","TurboCAD")
if FileName<>"" Then
' Open the output text file.
fh = TCWOpenOutput(FileName)
' Walk through the selected graphics and pick only
' GK_GRAPHICS.
for i = 0 to gCount - 1
g= TCWSelectionAt(i)
result=TCWGraphicPropertyGet(g, "Kind")
myInf=TCWGraphicPropertyGet(g, "Info")
if (result= GK_GRAPHIC) and (myInf="") Then
if vi > 0 then
' Place a blank line after the previous graphic
TCWWriteOutput fh, ""
End If
vCount = TCWVertexCount(g)
' Iterate through the vertices of the graphic g.
for vi = 0 to vCount - 1
v = TCWVertexAt(g, vi)
' Write the coordinates of vertex v into the string Line.
' The delimeter for numeric fields is chr(9) character.
myLine = Str$(vi) & chr$(9) & Str$(TCWGetX(v)) & chr$(9) & _
Str$(TCWGetY(v)) & chr$(9) & Str$(TCWGetZ(v))
TCWWriteOutput fh, myLine
next vi
End If
next i
TCWCloseOutput fh
End If
result=TCWDeselectAll()
MsgBox "Finished"
End Sub