好的,请说慢点,用小词
你能带我看一下这段代码,告诉我它实际上是如何设置属性值的吗?我想我还是不太明白它在做什么
用绳子。
这一切的原因是我试图用它在代码的修订版本中设置2个属性(标记ID和植物学)。
我想我已经用以下变量设置了各种值:
- (while (setq LINE (car *lst*))
-
- (setq
- x (atof (nth 0 line))
- y (atof (nth 1 line))
- z (atof (nth 2 line))
- bNme (nth 3 line)
- ;;rot (dtr (atof (nth 4 line)))
- ; xscale (atof (nth 4 line))
- ; yscale (atof (nth 5 line))
- tnum (nth 4 line)
- species (nth 5 line)
- canopy (atof (nth 6 line))
- );end setq
-
-
- (if (vl-catch-all-error-p
- (setq OBJ
- (vl-catch-all-apply (function vla-InsertBlock)
- (list spc (vlax-3D-point (list x y z)) bNme 1. 1. 1. *ROT*))))
-
- (princ "\n** Error Inserting Block **")
- (progn
- (vla-put-layer OBJ Lname)
- (vla-put-TextString
- (vl-remove-if-not
- (function
- (lambda (tnum) (eq "ID" (strcase (vla-get-TagString tnum)))))
- (vlax-invoke Obj 'GetAttributes)) tnum)
-
- (vla-put-TextString
- (vl-remove-if-not
- (function
- (lambda (botanical) (eq "botanical" (strcase (vla-get-TagString botanical)))))
- (vlax-invoke Obj 'GetAttributes)) botanical)
-
- (if (eq :vlax-true (vla-get-isDynamicBlock obj))
- (progn
- (setq ValLst (mapcar 'cons '("CANOPY")
- (mapcar
- (function
- (lambda (i)
- (if (equal 0.0 (distof i) 0.0001) "1" i)))
- (list (cadr LINE) (caddr x) (cadddr x)))))
-
- (foreach dAtt (vlax-safearray->list
- (vlax-variant-value
- (vla-GetDynamicBlockProperties obj)))
- (if (setq tag (assoc (strcase (vla-get-propertyName dAtt)) ValLst))
- (vla-put-value dAtt
- (vlax-make-variant (cdr tag)
- (vlax-variant-type (vla-get-value dAtt))))))))))
-
- ;;(princ (strcat "Tree# " (car x)))
- (setq *lst* (cdr *lst*)))
我不确定是否正确设置了第二个属性(因为我真的不知道它是如何做到的…)
谢谢 |