TC Database first created 27/09/05 - last modified xx/xx/xx Page Author: Ty Harness
Unfinished work

Each graphic element of TC has properties such as "PenColor" and "Layer" and you can define new properties (or fields) using the TC DataBase tools. TC has a report generator which is good so you may never need to programmatically tackle the Database at all with VBA. but it is possible to use and manipulate the data using VBA. The Database and VBA features are only available in the Professional versions. You could use the fields for costing or project management data.

It's possible to define your fields manually:

Practice on a test drawing
  • Draw a few graphics
  • Tools
  • Database and define a field called "cost" as a currency type and visible


  • All graphics and all new graphics with have a cost field.
  • Select a graphic
  • Tools - Database
  • edit object data
  • and give each graphic a cost value.

    If you're programmatically creating graphics you can add the field and value.


    Sub defineNewField() Dim g As Graphic Dim p As Property Set g = ActiveDrawing.Graphics.AddLineSingle(0, 0, 0, 100, 0, 0) 'example graphic Set p = g.Properties.Add("Cost", CCur(0), False) Set p = Nothing Set g = Nothing End Sub



    The following functions shows how to iterate through all graphics and sum up the field value called cost. Also how to sum up the cost within the selection set.

    Sub SumTotalCost() MsgBox FindTotalCost End Sub
    Sub SumSelectionCost() On Error Resume Next Dim s As Selection Dim Totcost As Currency Totcost = 0 Set s = ActiveDrawing.Selection For i = 0 To s.Count - 1 Totcost = Totcost + CCur(s.Item(i).Properties("Cost").Value) Next i Set s = Nothing MsgBox Totcost End Sub
    Sub makeCSVfile() Dim s As String On Error Resume Next Open Application.Path & "\testCSV.txt" For Output As #1 Dim g As Graphic For Each g In ActiveDrawing.Graphics s = "Test," & g.Properties("DatabaseID").Value & "," & CStr(g.Properties("Cost").Value) Print #1, s Set g = Nothing Next g Print #1, "Total Cost," & CStr(FindTotalCost) Close #1 MsgBox "Exported:" & Application.Path & "\testCSV.txt" End Sub
    Private Function FindTotalCost() As Currency On Error Resume Next Dim Totcost As Currency Totcost = 0 Dim g As Graphic For Each g In ActiveDrawing.Graphics Totcost = Totcost + CCur(g.Properties("Cost").Value) Set g = Nothing Next g FindTotalCost = Totcost End Function



    and finally you may need to export data to file (say) and comma separated variable (CSV) file for import into a spread sheet or an SQL Database. All the functions are contained in this .bas file (which is just a text file) Start you VBA editor and Import File.

    [Home] [Mechanics] [Welding] [Software] [CAD] [Math]

    Tested in Firefox 1.07: FireFox homepage