View Full Version : Invisible document
rajat126
2004-06-22, 11:11 AM
Hi,
Is it possible that I can open a file and access its data in invisible mode ?
Thanks
Rajat
Kolkata
India
Ed Jobe
2004-06-22, 04:30 PM
Using the ObjectDbx ActiveX api. Its possible to use it in lisp, but I only use it in vba. I have written a class module to make implementing it easy. Here is a link (http://64.227.78.21/empower/exchange/submissionpopup.asp?SubmissionNumber=EX001229)
whdjr
2004-06-22, 05:09 PM
Rajat,
There is a way to edit files using ObjectDBX thru VisualLisp. Below is some code I wrapped around Robert Bell's LayerFilterDelete to access all the files in a selected directory. Keep in mind the files can not be open. Robert has rewritten his tool for the newer versions of ACAD here (http://forums.augi.com/showthread.php?t=4342), my code works for ACAD2K.
HTH,
(vl-load-com)
(defun DLLRegister (dll)
(startapp "regsvr32.exe" (strcat "/s \"" dll "\""))
)
(defun ProgID->ClassID (ProgID)
(vl-registry-read
(strcat "HKEY_CLASSES_ROOT\\" progid "\\CLSID (file://CLSID/)")
)
)
(defun DBX-Register (/ classname)
(setq classname "ObjectDBX.AxDbDocument")
(cond
((ProgID->ClassID classname))
((and
(setq server (findfile "AxDb15.dll"))
(DLLRegister server)
(ProgID->ClassID classname)
)
(ProgID->ClassID classname)
)
((not (setq server (findfile "AxDb15.dll")))
(alert
"Error: Cannot locate ObjectDBX Type Library (AxDb15.dll)..."
)
)
(T
(DLLRegister "ObjectDBX.AxDbDocument")
(or
(ProgID->ClassID "ObjectDBX.AxDbDocument")
(alert
"Error: Failed to register ObjectDBX ActiveX services..."
)
)
)
)
)
(defun LayerFiltersDelete (doc)
(vl-Catch-All-Apply
'(lambda ()
(vla-Remove
(vla-GetExtensionDictionary
(vla-Get-Layers doc)
)
"ACAD_LAYERFILTERS"
)
)
)
)
(defun w:*error* (msg)
(princ "\nError: ")
(princ msg)
(princ)
(if (not (vlax-object-released-p dbxdoc))
(vlax-release-object dbxdoc)
)
(gc)
(princ)
)
(defun c:lfd_odbx (/ path folder files cnt dbxdoc of *error*)
(setq path (getfiled "Select a File" "" "dwg" (+ 4 128))
folder (vl-filename-directory path)
files (vl-directory-files folder "*.dwg" 1)
cnt 0
w:*error* *error*
)
(if (not (DBX-Register))
(*error* "Could not load the ObjectDBX Interface.")
)
(setq dbxdoc (vla-GetInterfaceObject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument"
)
)
(foreach file files
(setq of (vl-catch-all-apply
'(lambda ()
(vlax-invoke-method dbxdoc 'open (strcat folder "\\" file))
)
)
)
(if (vl-catch-all-error-p of)
(*error* (vl-catch-all-error-message of))
(progn
(LayerFiltersDelete dbxdoc)
(vla-saveas dbxdoc (strcat folder "\\" file))
)
)
(setq cnt (1+ cnt))
)
(vlax-release-object dbxdoc)
(gc)
(princ)
)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.