I would try a dxb module.
It is a way to open and query a drawing file without opening it in AutoCAD.
It comes from the old (really old) days when AutoCAD only had a single drawing interface.
Code:
;___________________________________________________________________________________________________________|
;
; Written By: Peter Jamtgaard copyright 2024 All Rights Reserved
;___________________________________________________________________________________________________________|
;
; Any use by unauthorized person or business is strictly prohibited.
;___________________________________________________________________________________________________________|
;
; Abstract: This routine uses the DBX module (interface object) to read unopen drawing files.
;___________________________________________________________________________________________________________|
;
; Command Line Function Header List
;___________________________________________________________________________________________________________|
;* C:DBXModule
;* Command Line Function to call the DBX Module function for each member of list of drawings
;___________________________________________________________________________________________________________|
;
; General Function Header List
;___________________________________________________________________________________________________________|
;
; Function List Argument1 Argument2 Arguement3
;* (DBXModule strFileName)
;* Function to read a drawing file (all layouts) and search for text and print the textstring to command line
;$ End Header
;___________________________________________________________________________________________________________|
;
; Command Line Function to call the DBX Module function for each member of list of drawings
;___________________________________________________________________________________________________________|
(defun C:DBXModule (/ strFileName strInterfaceString strVersionNumber )
(if (and (setq strVersionNumber (substr (getvar "ACADVER") 1 2))
(setq strInterfaceString (strcat "ObjectDBX.AxDbDocument." strVersionNumber))
)
(progn
(setq objDBXInterface (vla-GetInterfaceObject
(vlax-get-acad-object)
strInterfaceString
)
)
(foreach strFileName (list "HelloWorld1.dwg" "HelloWorld2.dwg")
(DBXModule objDBXInterface strFileName)
)
(vlax-release-object objDBXInterface)
)
)
)
;___________________________________________________________________________________________________________|
;
; Function to read a drawing file (all layouts) and search for text and print the textstring to command line
;___________________________________________________________________________________________________________|
(defun DBXModule (objDBXInterface strFileName / DBXOBJ DBXFILE DWGNAME LOOBJ OBJ)
(if (setq strFullName (findfile strFileName))
(progn
(vla-open objDBXInterface strFullName)
(vlax-for objLayout (vla-get-layouts objDBXInterface)
(vlax-for objItem (vla-get-block objLayout)
(if (wcmatch (vla-get-objectname objItem) "AcDbText")
(print (vla-get-textstring objItem))
)
)
)
; (vla-saveas objDBXInterface strFullName); <- Can also make changes to a drawing file
)
(princ (strcat "\nError finding: " strFileName))
)
)
(princ "!")
(vl-load-com)