Author Topic: Compare block names against external list  (Read 1632 times)

0 Members and 1 Guest are viewing this topic.


  • Seagull
  • Posts: 12955
  • I like my water diluted.
Compare block names against external list
« on: October 22, 2008, 01:08:27 PM »
I've got a list of block names and need to compare them against an external list.  I was thinking of using a TXT file since it would be easy to update.  My current train of thought is to loop through the list of blocks (stored in a dictionary) and during each loop, open the TXT file, loop through that to see if the block name matches and if so, carry on with the rest of the program.  Any thoughts/suggestions on this process?  I'm open to different suggestions.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @


  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Compare block names against external list
« Reply #1 on: October 22, 2008, 01:34:07 PM »
While searching through old programs I came across this.  It uses an Excel file as a database.  The original program looped through a selection set and searches for specific blocks with attributes.  It then compares the attribute text to a cell in the Excel file.  From there, other information from Excel is pulled and dumped into a table object in AutoCAD, creating a type of "dynamic" table.

Code: [Select]
    Dim x As Integer
    For x = 0 To UBound(objKeys)
        [color=red]GetLightInfo[/color] UCase(objKeys(x))
        objTable.InsertRows objTable.Rows, 0.59375, 1
        objTable.SetText objTable.Rows - 1, 0, objDict(objKeys(x))
        objTable.SetText objTable.Rows - 1, 1, UCase(objKeys(x))
        objTable.SetText objTable.Rows - 1, 2, strMfg
        objTable.SetText objTable.Rows - 1, 3, strDesc
        objTable.SetText objTable.Rows - 1, 4, strVolts
        objTable.SetText objTable.Rows - 1, 5, strLamps
    Next x

Code: [Select]
Option Explicit

Public cn As ADODB.Connection
Public rsT As ADODB.Recordset
Public rsC As ADODB.Recordset

Public Sub [color=red]GetLightInfo[/color](strID As String)
    Dim strQuery As String
    Dim rstQuery As New ADODB.Recordset
    rstQuery.Open strQuery, cn, adOpenKeyset, adLockReadOnly
    rstQuery.Filter = "TYPE = '" & strID & "'"
    Do While Not rstQuery.EOF
        Debug.Print rstQuery!Type
        strDesc = rstQuery!Description
        strMfg = rstQuery("MFR & SERIES")
        strVolts = rstQuery!VOLTS
        strLamps = rstQuery!LAMPS
End Sub

Private Sub OpenExcelDatabase()
    Dim intTblCnt As Integer, intTblFlds As Integer
    Dim strTbl As String
    Dim intColCnt As Integer, intColFlds As Integer
    Dim strCol As String
    Dim t As Integer, c As Integer, f As Integer
    Set cn = New ADODB.Connection
    With cn
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .ConnectionString = "Data Source=" & _
        "E:\Luminaire.xls;Extended Properties=Excel 8.0;"
        .CursorLocation = adUseClient
    End With
End Sub

Private Sub CloseExcelDatabase()
    On Error Resume Next
End Sub
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @