home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / turbocad / v8trial / TurboCADv8ProfessionalNoReg.exe / Data.Cab / F40633_modSelNode.bas < prev    next >
Encoding:
BASIC Source File  |  2001-10-16  |  5.2 KB  |  143 lines

  1. Attribute VB_Name = "modSelNode"
  2. '******************************************************************'
  3. '*                                                                *'
  4. '*                      TurboCAD for Windows                      *'
  5. '*                   Copyright (c) 1993 - 2001                    *'
  6. '*             International Microcomputer Software, Inc.         *'
  7. '*                            (IMSI)                              *'
  8. '*                      All rights reserved.                      *'
  9. '*                                                                *'
  10. '******************************************************************'
  11.  
  12. Option Explicit
  13.  
  14. Sub AddDrawingNodes(ByVal tvnodes As MSComctlLib.nodes, ByVal all As Boolean)
  15.     On Error Resume Next
  16.     Dim nod As Node
  17.     Dim sel As Selection
  18.     Dim grs As Graphics
  19.     Dim gfc As Graphic
  20.     Dim nodeName As String
  21.     
  22.     If all Then
  23.         nodeName = "Drawing"
  24.     Else
  25.         nodeName = "Selection"
  26.     End If
  27.     With tvnodes
  28.         .Clear
  29.         Set nod = .Add(, , "R", nodeName)
  30.     End With
  31.     If all Then
  32.         Set grs = ActiveDrawing.Graphics
  33.         For Each gfc In grs
  34.             AddGraphicInfoToNode tvnodes, gfc, "R", 0
  35.         Next gfc
  36.     Else
  37.         Set sel = ActiveDrawing.Selection
  38.         For Each gfc In sel
  39.             AddGraphicInfoToNode tvnodes, gfc, "R", 0
  40.         Next gfc
  41.     End If
  42. End Sub
  43.  
  44. Private Sub AddGraphicInfoToNode(ByVal tvnodes As MSComctlLib.nodes, ByVal gfc As Graphic, ByVal par As String, ByVal lvl As Integer)
  45.     On Error Resume Next
  46.     Dim i, count As Integer
  47.     Dim s, n, v As String
  48.     Dim kg, kv, kb, ki, kp As String
  49.     Dim blk As IMSIGX.Block
  50.     Dim nod As Node
  51.     
  52.     With tvnodes
  53.         kg = "G" & gfc.ID
  54.         n = gfc.Name
  55.         If n = "" Then n = "<no name>"
  56.         s = "<Err>"
  57.         s = "Graphic ID " & gfc.ID & ", " & n & ": " & gfc.Type
  58.         If gfc.Cosmetic Then s = s & " [Cosmetic]"
  59.         Set nod = .Add(par, tvwChild, kg, s)
  60.         s = "<Err>"
  61.         s = gfc.RegenType
  62.         Set nod = .Add(kg, tvwChild, , "Regen " & s)
  63.         s = ""
  64.         If gfc.Builtin Then s = s & "Bilt "
  65.         If gfc.Closed Then s = s & "Clsd "
  66.         If gfc.Cosmetic Then s = s & "Cosm "
  67.         If gfc.Deleted Then s = s & "Dele "
  68.         If gfc.Editable Then s = s & "Edit "
  69.         If gfc.Unbounded Then s = s & "Ubnd "
  70.         If gfc.Visible Then s = s & "Vis  "
  71.         Set nod = .Add(kg, tvwChild, , "Flags " & s)
  72.         
  73.         count = gfc.Vertices.count
  74.         If count > 0 Then
  75.             kv = kg & "V"
  76.             Set nod = .Add(kg, tvwChild, kv, count & " Vertices")
  77.             Dim vtx As Vertex
  78.             For i = 0 To count - 1
  79.                 Set vtx = gfc.Vertices(i)
  80.                 ki = kv & i
  81.                 v = "Up"
  82.                 If vtx.PenDown Then v = "Down"
  83.                 Set nod = .Add(kv, tvwChild, ki, "V[" & i & "]: (" & vtx.x & ", " & vtx.y & ", " & vtx.z & ") [" & v & "]")
  84.                 s = ""
  85.                 If vtx.PenDown Then s = s & "Down " Else s = s & "Up   "
  86.                 If vtx.Bulge Then s = s & "Blge "
  87.                 If vtx.Calculated Then s = s & "Calc "
  88.                 If vtx.Editable Then s = s & "Edit "
  89.                 If vtx.Linkable Then s = s & "Link "
  90.                 If vtx.Selectable Then s = s & "Sel  "
  91.                 If vtx.Snappable Then s = s & "Snap "
  92.                 Set nod = .Add(ki, tvwChild, , "Flags " & s)
  93.             Next i
  94.         End If
  95.         
  96.         count = gfc.Properties.count
  97.         If count > 0 Then
  98.             kp = kg & "P"
  99.             Set nod = .Add(kg, tvwChild, kp, count & " Properties")
  100.             Dim prop As Property
  101.             For i = 0 To count - 1
  102.                 Set prop = gfc.Properties(i)
  103.                 ki = kp & i
  104.                 s = "<Err>"
  105.                 s = prop.Name & ": " & PropertyValueAsString(prop)
  106.                 Set nod = .Add(kp, tvwChild, ki, s)
  107.                 Set nod = .Add(ki, tvwChild, , "Flags " & PropertyFlagsAsString(prop))
  108.                 Set nod = .Add(ki, tvwChild, , "Type " & PropertyTypeAsString(prop))
  109.             Next i
  110.         End If
  111.         
  112.         'Sanity check
  113.         If lvl > 4 Then Exit Sub
  114.         
  115.         Set blk = gfc.Block
  116.         If Not blk Is Nothing Then
  117.             kb = kg & "B"
  118.             s = blk.Name
  119.             Set nod = .Add(kg, tvwChild, kb, "Block: " & s)
  120.             Set vtx = blk.Anchor
  121.             Set nod = .Add(kb, tvwChild, , "Anchor: (" & vtx.x & ", " & vtx.y & ", " & vtx.z & ")")
  122.             count = blk.Graphics.count
  123.             If count > 0 Then
  124.                 ki = kg & "B-"
  125.                 Set nod = .Add(kb, tvwChild, ki, count & " Children")
  126.                 For i = 0 To count - 1
  127.                     AddGraphicInfoToNode tvnodes, blk.Graphics(i), ki, lvl + 1
  128.                 Next i
  129.             End If
  130.         End If
  131.         
  132.         count = gfc.Graphics.count
  133.         If count > 0 Then
  134.             ki = kg & "-"
  135.             Set nod = .Add(kg, tvwChild, ki, count & " Children")
  136.             For i = 0 To count - 1
  137.                 AddGraphicInfoToNode tvnodes, gfc.Graphics(i), ki, lvl + 1
  138.             Next i
  139.         End If
  140.     End With
  141. End Sub
  142.  
  143.