Gile这能行吗?
- (defun c:test (/ Copy_obj ss path app docs doc)
- (vl-load-com)
- (defun Copy_Obj (ss blk / ObjLst)
- (vl-load-com)
- (setq ObjLst
- (mapcar 'vlax-ename->vla-object
- (vl-remove-if 'listp
- (mapcar 'cadr (ssnamex ss)))))
- (cond ( (vl-every '= (mapcar 'vla-get-OwnerId ObjLst))
- (vla-copyobjects
- (vla-get-ActiveDocument
- (vlax-get-acad-object))
- (vlax-make-variant
- (vlax-safearray-fill
- (vlax-make-safearray
- vlax-vbObject
- (cons 0 (1- (length ObjLst)))) ObjLst)) blk))))
- (if (and (setq ss (ssget))
- (setq path (getfiled "File" "" "dwg" 16)))
- (progn
- (setq app (vlax-create-object
- (strcat "AutoCAD.Application."
- (itoa (fix (atof (getvar 'ACADVER)))))))
- (vlax-put-property app 'Visible :vlax-true)
- (vlax-put-property
- (vla-get-Display
- (vla-get-preferences app)) 'maxautocadwindow :vlax-true)
-
- (setq docs (vla-get-documents app) doc (vla-open docs path :vlax-false))
- (Copy_obj ss doc)
- (vla-save doc)
- (vla-close doc)
- (vlax-invoke-method app 'quit)
- (mapcar
- (function
- (lambda (x)
- (vlax-release-object x))) (list app docs doc))))
- (princ))
|