也许:
- (defun c:ins (/ *error* bNme doc spc ent uflag mpt ang)
- (vl-load-com)
- (setq bNme "test" ) ;; Block Name
- (defun *error* (msg)
- (and uflag (vla-EndUndoMark doc))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ))
- (setq doc (vla-get-ActiveDocument
- (vlax-get-Acad-Object))
-
- spc (if (zerop
- (vla-get-activespace doc))
- (if (= (vla-get-mspace doc) :vlax-true)
- (vla-get-modelspace doc)
- (vla-get-paperspace doc))
- (vla-get-modelspace doc)))
- (if (or (tblsearch "BLOCK" bNme)
- (setq bNme (findfile (strcat bNme ".dwg"))))
- (while
- (progn
- (setq ent (entsel "\nPick Line for insertion: "))
- (cond ( (eq 'ENAME (type (car ent)))
- (if (vl-catch-all-error-p
- (vl-catch-all-apply 'vlax-curve-getEndParam (list (car ent))))
- (princ "\n** Invalid Object Selected **")
- (progn
- (setq uflag (not (vla-StartUndoMark doc)))
- (setq mpt (vlax-curve-getPointatParam (car ent)
- (/ (vlax-curve-getEndParam (car ent)) 2.))
-
- ang (angle '(0 0 0) (vlax-curve-getFirstDeriv (car ent)
- (vlax-curve-getParamatPoint (car ent) mpt))))
- (vla-InsertBlock spc (vlax-3D-point mpt) bNme 1. 1. 1. ang)
- (setq uflag (vla-EndUndoMark doc)) t))))))
- (princ "\n** Block Definition not Found **"))
- (princ))
|