gmstcn 发表于 2013-11-7 08:39:43

请教关于vlax-put-property的使用

用(vlax-get-property obj 'text 1 1)可以得到索引1,1的属性值,如果要设置属性值的话应该怎么写?
试了下(vlax-put-property obj 'text 1 1 "xxx")提示类型不匹配

zlg258369 发表于 2013-11-7 12:53:46

;; Get Attribute Value-Lee Mac
;; Returns the value held by the specified tag within the supplied block, if present.
;; blk - VLA Block Reference Object
;; tag - Attribute TagString
;; Returns: 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 Value-Lee Mac
;; Sets the value of the first attribute with the given tag found within the block, if present.
;; blk - VLA Block Reference Object
;; tag - Attribute TagString
;; val - Attribute Value
;; Returns: Attribute value if successful, else nil.

(defun LM:vl-setattributevalue ( blk tag val )
    (setq tag (strcase tag))
    (vl-some
       '(lambda ( att )
            (if (= tag (strcase (vla-get-tagstring att)))
                (progn (vla-put-textstring att val) val)
            )
      )
      (vlax-invoke blk 'getattributes)
    )
)
页: [1]
查看完整版本: 请教关于vlax-put-property的使用