佐尔格,
对这两个伟大的家伙没有冒犯之意,但来自asmi的这一个甚至更好。它也可以从动态块属性交叉匹配到常规文本。我不能从中获得任何荣誉,因为它是由ASMI创建的。
- ;; ============================================================ ;;
- ;; ;;
- ;; TTC.LSP - The program copies the text from: DText, MText, ;;
- ;; Tables, Dimensions, Attributes, Attributes, ;;
- ;; Attributes Definitions, DText, MText and inner ;;
- ;; block's DText and MText to: DText, MText, Tables, ;;
- ;; Attribures and Attributes Definitions. There are ;;
- ;; Multiple and Pair-wise modes. ;;
- ;; ;;
- ;; ============================================================ ;;
- ;; ;;
- ;; Command(s) to call: TTC ;;
- ;; ;;
- ;; ============================================================ ;;
- ;; ;;
- ;; THIS PROGRAM AND PARTS OF IT MAY REPRODUCED BY ANY METHOD ;;
- ;; ON ANY MEDIUM FOR ANY REASON. YOU CAN USE OR MODIFY THIS ;;
- ;; PROGRAM OR PARTS OF IT ABSOLUTELY FREE. ;;
- ;; ;;
- ;; THIS PROGRAM PROVIDES THIS PROGRAM 'AS IS' WITH ALL FAULTS ;;
- ;; AND SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF ;;
- ;; MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. ;;
- ;; ;;
- ;; ============================================================ ;;
- ;; ;;
- ;; V1.3, 29 November, 2005, Riga, Latvia ;;
- ;; © Aleksandr Smirnov (ASMI) ;;
- ;; For AutoCAD 2000 - 2008 (isn't tested in a next versions) ;;
- ;; ;;
- ;; http://www.asmitools.com ;;
- ;; ;;
- ;; ============================================================ ;;
- (defun c:ttc (/ actDoc vlaObj sObj sText curObj oldForm
- oType oldMode conFlag errFlag *error*)
- (vl-load-com)
- (setq actDoc(vla-get-ActiveDocument
- (vlax-get-acad-object)))
- (vla-StartUndoMark actDoc)
- (defun TTC_Paste(pasteStr / nslLst vlaObj hitPt
- hitRes Row Column)
- (setq errFlag nil)
- (if
- (setq nslLst(nentsel "\nPaste text >"))
- (progn
- (cond
- ((and
- (= 4(length nslLst))
- (= "DIMENSION"(cdr(assoc 0(entget(car(last nslLst))))))
- ); end and
- (setq vlaObj(vlax-ename->vla-object
- (cdr(assoc -1(entget(car(last nslLst)))))))
- (if
- (vl-catch-all-error-p
- (vl-catch-all-apply
- 'vla-put-TextOverride(list vlaObj pasteStr)))
- (progn
- (princ "\n<!> Can't paste. Object may be on locked layer <!> ")
- (setq errFlag T)
- ); end progn
- ); end if
- ); end condition #1
- ((and
- (= 4(length nslLst))
- (= "ACAD_TABLE"(cdr(assoc 0(entget(car(last nslLst))))))
- ); end and
- (setq vlaObj
- (vlax-ename->vla-object
- (cdr(assoc -1(entget(car(last nslLst))))))
- hitPt(vlax-3D-Point(trans(cadr nslLst)1 0))
- hitRes(vla-HitTest vlaObj hitPt
- (vlax-3D-Point '(0.0 0.0 1.0)) 'Row 'Column)
- ); end setq
- (if(= :vlax-true hitRes)
- (progn
- (if(vl-catch-all-error-p
- (vl-catch-all-apply
- 'vla-SetText(list vlaObj Row Column pasteStr)))
- (progn
- (princ "\n<!> Can't paste. Object may be on locked layer <!> ")
- (setq errFlag T)
- ); end progn
- ); end if
- ); end progn
- ); end if
- ); end condition # 2
- ((and
- (= 4(length nslLst))
- (= "INSERT"(cdr(assoc 0(entget(car(last nslLst))))))
- ); end and
- (princ "\n<!> Can't paste to block's DText or MText <!> ")
- (setq errFlag T)
- ); end condition #3
- ((and
- (= 2(length nslLst))
- (member(cdr(assoc 0(entget(car nslLst))))
- '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))
- ); end and
- (setq vlaObj(vlax-ename->vla-object(car nslLst)))
- (if(vl-catch-all-error-p
- (vl-catch-all-apply
- 'vla-put-TextString(list vlaObj pasteStr)))
- (progn
- (princ "\n<!> Error. Can't pase text <!> ")
- (setq errFlag T)
- ); end progn
- ); end if
- ); end condition #4
- (T
- (princ "\n<!> Can't paste. Invalid object <!> ")
- (setq errFlag T)
- ); end condition #5
- ); end cond
- T
|