我不知道这个错误是从哪里来的。 我唯一补充的是
(princ(strcat“\n STATION“s”)
在最后一个普林斯之前。 这就是导致错误的原因,因为“s”不是字符串。 在使用我的“GetDynamicProperties”函数从这里查询附加的示例块后,我注意到它甚至没有一个名为“STA”的属性,这可能是没有赋值的原因。 啊,我现在明白了。我补充说,只是为了看到价值的视觉验证。抱歉给你带来了困惑。
现在它仍然回到了最初的问题,因为没有为STA属性标记输入值,即使有更新的代码。 是的,这是一个属性标签。。。我认为动态属性适用于任何属性,而不仅仅是动态对象,即使标记位于动态块中。
不,属性完全是另一回事。 试试这个:
(defun c:test ( / blocks i l o s ss ) (vl-load-com)
(setq blocks
'(
"ANCHOR-STA"
"CATCH BASIN-STA"
"CONC. POLE-STA"
"ELEC TRANSFORMER-STA"
"FIBER MARKER TUBE-STA"
"FIRE HYDRANT-STA"
"GRATE INLET-STA"
"HANDHOLE-STA"
"HANDHOLE PROP-STA"
"MAILBOX-STA"
"MANHOLE-STA"
"PARKING METER-STA"
"POLE-STA"
"PROPERTY PIN-STA"
"SIGN-STA"
"STEEL POLE-STA"
"STEEL POST-STA"
"STREET LIGHT-STA"
"TEL PED-STA"
"TEST PIT-STA"
"TRAFFIC CONTROL BOX-STA"
"TRAFFIC POLE-STA"
"TRAFFIC SIGNAL-STA"
"TREE-STA"
"VERIZON MH-STA"
"VALVE-STA"
"WATER METER-STA"
)
)
(if
(and
(setq l
(LM:Select "\nSelect Running Line: "
'(lambda ( x )
(not
(vl-catch-all-error-p
(vl-catch-all-apply 'vlax-curve-getendparam (list x))
)
)
)
entsel
)
)
(princ "\nSelect Dynamic Blocks: ")
(setq ss
(ssget "_:L"
(list '(0 . "INSERT") '(66 . 1)
(cons 2
(apply 'strcat (cons "`*U*" (mapcar '(lambda ( s ) (strcat "," s)) blocks)))
)
)
)
)
)
(repeat (setq i (sslength ss))
(if
(and
(member
(strcase
(vlax-get-property (setq o (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(if (vlax-property-available-p o 'EffectiveName) 'EffectiveName 'Name)
)
)
blocks
)
(setq s
(vlax-curve-getdistatpoint l
(vlax-curve-getclosestpointto l (vlax-get o 'insertionpoint))
)
)
)
(LM:SetAttributeValue o "STA" (vl-string-subst "+" "." (rtos (/ s 100.) 2 2)))
)
)
)
(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: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)
)
)
;;---------------------=={ Select if }==----------------------;;
;; ;;
;;Continuous selection prompts until a predicate function ;;
;;is validated ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;msg- prompt string ;;
;;pred - optional predicate function taking ename argument;;
;;func - selection function to invoke ;;
;;------------------------------------------------------------;;
;;Returns:selected entity ename if successful, else nil ;;
;;------------------------------------------------------------;;
(defun LM:Select ( msg pred func / e ) (setq pred (eval pred))
(while
(progn (setvar 'ERRNO 0) (setq e (car (func msg)))
(cond
( (= 7 (getvar 'ERRNO))
(princ "\n** Missed, Try again **")
)
( (eq 'ENAME (type e))
(if (and pred (not (pred e)))
(princ "\n** Invalid Object Selected **")
)
)
)
)
)
e
) 关哦,太近了。。。
对于77.5725的值,定位将为0+78,但它将值设为77+57。
再举一个例子,如果进尺是1058.4878,则驻扎将是10+58,105687.4578将是1056+87。 李,把sta值除以100
页:
1
[2]