我已经修改了一个LISP程序从线程,面积的折线。
我想做的是:
-获取单个多段线面积的平方英尺。
-获取多段线的acad句柄。
在包含许多不同属性标记的属性块内:
-将平方英尺的值放入“NET\u SQ\u FEET”的标签中
-将acad句柄值放入“acad\U句柄”的标记中
目前,从下面的代码中,我得到一个错误“VLA-OBJECT”。代码仅尝试放置平方英尺的值。我甚至不知道从哪里开始获取多段线acad句柄的值。
- (defun c:test ( / area en nm pt )
- (while
- (progn (setvar 'ERRNO 0) (setq en (car (entsel)))
- (cond
- ( (= 7 (getvar 'ERRNO))
- (princ "\nMissed, try again.")
- )
- ( (eq 'ENAME (type en))
- (if (vl-catch-all-error-p
- (setq area (vl-catch-all-apply 'vlax-curve-getarea (list en)))
- )
- (princ "\nInvalid Object.")
- )
- )
- ( (setq area nil) )
- )
- )
- )
- (setq area (rtos (/ area 144.0) 2 2))
- (if (setq block (ssget "_:S"))
- (progn
- (setq block (ssname block 0))
- (LM:vl-SetAttributeValue (vlax-ename->vla-object block) "NET_SQ_FEET" area)
- )
- )
-
- (princ)
- )
- (vl-load-com) (princ)
- ;;----------------=={ Set Attribute Value }==-----------------;;
- ;; ;;
- ;; Populates the first attribute matching the tag specified ;;
- ;; found within the block supplied with the value specified, ;;
- ;; if present. ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; block - VLA Block Reference Object ;;
- ;; tag - Attribute TagString ;;
- ;; value - Value to which the Attribute will be set ;;
- ;;------------------------------------------------------------;;
- ;; Returns: Value the attribute was set to, else nil ;;
- ;;------------------------------------------------------------;;
- (defun LM:vl-SetAttributeValue ( block tag value )
- (setq tag (strcase tag))
- (vl-some
- (function
- (lambda ( attrib )
- (if (eq tag (strcase (vla-get-TagString attrib)))
- (progn
- (vla-put-TextString attrib value)
- value
- )
- )
- )
- )
- (vlax-invoke block 'GetAttributes)
- )
- )
|