这应该行得通
命令TTCB,但请随意重命名此命令
- (vl-load-com)
- ;; To copy/paste from fixed attributes, source tag: "SIGLA", destination tag: "NAME"
- ;; TTC Block
- (defun c:ttcb ( / sText)
- (defun TCC_copyAttribute (source / blk )
- (if (setq blk (entsel "\nSelect source block: "))
- (setq sText (LM:vl-getattributevalue (vlax-ename->vla-object (car blk)) source))
- )
- )
- (defun TCC_pasteAttribute (dest / blk)
- (if (setq blk (entsel "\nSelect destination block: "))
- (LM:vl-setattributevalues (vlax-ename->vla-object (car blk)) (list (cons dest sText)) )
- )
- )
-
- (while (TCC_copyAttribute "SIGLA")
- (TCC_pasteAttribute "NAME")
- )
-
- )
- ;; Get Attribute Value - Lee Mac
- ;; Returns the value held by the specified tag within the supplied block, if present.
- ;; blk - [vla] VLA Block Reference Object
- ;; tag - [str] Attribute TagString
- ;; Returns: [str] Attribute value, else nil if tag is not found.
- (defun LM:vl-getattributevalue ( blk tag )
- (setq tag (strcase tag))
- (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes))
- )
- ;; Set Attribute Values - Lee Mac
- ;; Sets attributes with tags found in the association list to their associated values.
- ;; blk - [vla] VLA Block Reference Object
- ;; lst - [lst] Association list of ((<tag> . <value>) ... )
- ;; Returns: nil
- (defun LM:vl-setattributevalues ( blk lst / itm )
- (foreach att (vlax-invoke blk 'getattributes)
- (if (setq itm (assoc (vla-get-tagstring att) lst))
- (vla-put-textstring att (cdr itm))
- )
- )
- )
-
|