例如:
- ;; ObjectDBX Example, by Lee McDonnell
-
- (defun ODBX (fname / doc dbx lst flag)
- (vl-load-com)
- (vlax-for doc (vla-get-Documents (vlax-get-acad-object))
- (and (eq (strcase (vla-get-fullname doc)) (strcase fname))
- (setq dbx doc)))
- (and (not dbx) (setq flag t)
- (setq dbx
- (vlax-create-object
- (if (< (setq acVer (atoi (getvar "ACADVER"))) 16)
- "ObjectDBX.AxDbDocument"
- (strcat "ObjectDBX.AxDbDocument." (itoa acVer))))))
- (cond ((and flag
- (vl-catch-all-error-p
- (vl-catch-all-apply 'vla-open
- (list dbx fname))))
- (princ (strcat "\n** Error Opening: " (vl-filename-base fname) " **")))
- (t
- (vlax-for lay (vla-get-Layouts dbx)
- (setq lst (cons (vla-get-name lay) lst)))))
- (ObjRel (list dbx)) (gc) (gc)
- lst)
- ;; 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))
- (defun c:test ( )
- (odbx (getfiled "select" "" "dwg" 16)))
|