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

  1. 'Program that shows how to use TCWGetPoint, TCWVertexFindVertex
  2. 'The program will create a dimension
  3. sub main()
  4. Dim v1 As Long
  5. Dim v2 As Long
  6. Dim v3 As Long
  7. Dim res as long
  8. Dim s as String
  9. Dim g As Long
  10. Dim vd As Long
  11.  
  12. 'Create three vertices with 0 XYZ values
  13. v1 = TCWVertexCreate(0,0,0) 
  14. v2 = TCWVertexCreate(0,0,0)
  15. v3 = TCWVertexCreate(0,0,0)
  16.  
  17. 'Get user to input first end point
  18. 'we are using snap mode SNAP_ANYPOINT, and a cross cursor
  19. res = tcwgetpoint(v1, "Dimension : First End Point", NULL, NULL, &h00FC, 2)
  20.  
  21. 'if success then continue
  22. if (res = 0) Then
  23.    ' snap to the nearest point
  24.    res = TCWVertexFindVertex(v1, &h00FC)
  25.  
  26.    ' create a line for dragging
  27.    g = TCWLineSingle(TCWGetX(v1), TCWGetY(v1), TCWGetZ(v1), _ 
  28.                      TCWGetX(v1), TCWGetY(v1), TCWGetZ(v1))
  29.  
  30.    ' flush the redraw que to force the above line to draw
  31.  
  32.    vd = TCWVertexAt(g, 1)
  33.  
  34.    res = tcwgetpoint(v2, "Dimension : Second End Point", g, vd, &h00FC, 2)
  35.  
  36.    ' remove the TCWLineSingle
  37.    TCWUndo 1
  38.  
  39.    if (res = 0) Then        
  40.       ' snap to the nearest point
  41.     res = TCWVertexFindVertex(v2, &h00FC)
  42.  
  43.       TCWSetXYZ v3, TCWGetX(v2), TCWGetY(v2), TCWGetZ(v2)
  44.             
  45.     g = TCWDimensionHorizontal(TCWGetX(v1), TCWGetY(v1), TCWGetZ(v1), _ 
  46.                                  TCWGetX(v2), TCWGetY(v2), TCWGetZ(v2), _ 
  47.                                  TCWGetX(v3), TCWGetY(v3), TCWGetZ(v3))
  48.  
  49.     ' the fourth vertex in a linear dimension is the one which 
  50.       ' defines the position of the dimension line
  51.     vd = TCWVertexAt(g, 3)
  52.  
  53.     res = tcwgetpoint(v3, "Dimension : Dimension Line Point", g, vd, 2)
  54.     if (res = 0) Then
  55.        TCWGraphicDraw g, 0
  56.     Else
  57.        TCWGraphicDispose g
  58.     End If
  59.    end if
  60. end if
  61.  
  62. 'Delete the vertices that didn't get added to any graphics or drawing
  63. TCWVertexDispose v1
  64. TCWVertexDispose v2
  65. TCWVertexDispose v3
  66.  
  67. end sub
  68.