Hello,
Sorry I don't have a solution, I think there are others on this forum who will hopefully help you out more, I can just tell you what I've learnt from using Lee's ObjectDBX template if you want to edit it there are two area's that you should concerntrate on (Highlighted in Blue). The rest is just concerned with the drawings:
- ;; ObjectDBX Example, by Lee McDonnell;; Credit to Tony Tanzillo, Tim Willey (defun c:blkdel (/ *error* bNme *acad Shell fDir Dir dwLst dbx) (vl-load-com) ;; Error Handler (defun *error* (e) (ObjRel (list Shell dbx *acad)) (if (not (wcmatch (strcase e) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\n>"))) (princ)) ;; Get Block Name[color=Blue] (while (progn (setq bNme (getstring t "\nSpecify Block Name: ")) (cond ((not (snvalid bNme)) (princ "\n** Invalid Block Name **")) (t (setq bNme (strcase bNme)) nil)))) [/color] ;; Get Directory (setq *acad (vlax-get-acad-object) Shell (vla-getInterfaceObject *acad "Shell.Application") fDir (vlax-invoke-method Shell 'BrowseForFolder (vla-get-HWND *acad) "Select Directory: " 80)) (and (eq (type Shell) 'VLA-OBJECT) (not (vlax-object-released-p Shell)) (vl-catch-all-apply 'vlax-release-object (list Shell))) (if fDir (progn (setq Dir (vlax-get-property (vlax-get-property fDir 'Self) 'Path)) (if (not (eq "\" (substr Dir (strlen Dir)))) (setq Dir (strcat Dir "\"))) (princ "\nProcessing...") ;; Iterate Drawings (foreach dwg (setq dwLst (mapcar (function (lambda (x) (strcat Dir x))) (vl-directory-files Dir "*.dwg" 1))) (vlax-for doc (vla-get-Documents *acad) (and (eq (strcase (vla-get-fullname doc)) (strcase dwg)) (setq dbx doc))) (and (not dbx) (setq dbx (vlax-create-object (if (< (setq acVer (atoi (getvar "ACADVER"))) 16) "ObjectDBX.AxDbDocument" (strcat "ObjectDBX.AxDbDocument." (itoa acVer)))))) (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list dbx dwg)))) (progn[color=Blue] (vlax-for lay (vla-get-Layouts dbx) (vlax-for Obj (vla-get-Block lay) (if (and (eq (vla-get-ObjectName Obj) "AcDbBlockReference") (eq (strcase (vla-get-Name Obj)) BNme)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list Obj))) (princ (strcat "\n** Error Deleting Block in: " (vl-filename-base dwg) " **"))))))[/color] (vla-saveas dbx dwg)) (princ (strcat "\n** Error Opening File: " (vl-filename-base dwg) " **"))) (princ (chr 46))) ;; Ending Messages (princ (strcat "\n>"))) (princ "*Cancel*")) ;; Garbage Collection (gc) (ObjRel (list Shell dbx *acad)) (princ));; Release Objects ~ Requires List of Variables (defun ObjRel (lst) (mapcar (function (lambda (x) (if (and (eq (type x) 'VLA-OBJECT) (not (vlax-object-released-p x))) (vl-catch-all-apply 'vlax-release-object (list x))))) lst))
As you can see it uses the blocks table. Now the problem with ObjectDBX is you can't use ssget function, therefore it is great for blocks, attributes, layers, any tables, but not for individual objects like text. Because how can you search the drawing without the ssget function? I'm not sure if entnext will work but if it does it's guaranteed to take a looong time.
But yeah, hopefully others can shed light on this... |