- ;桩轴力求和
- (defun c:dd (/ ss ss1 ss2 n i sum1 sum2)
- (defun wmg-ssgetp (ss filter)
- (sssetfirst nil ss)
- (ssget "p" (list (cons 8 filter)))
- ) ;wmg-ssgetp 子函数
- (setq ss1 nil)
- (setq ss2 nil )
- (setq ss (ssget '((0 . "TEXT")(8 . "81,82"))));选择对象
- (setq ss1(wmg-ssgetp ss "82") );调用子函数,创建ss1选择集
- (setq ss2(wmg-ssgetp ss "81") );调用子函数,ss2选择集
- ;下面对ss1操作
- (setq n (sslength ss1))
- (setq i 0 sum1 0)
- (repeat n
- (setq string (cdr (assoc 1 (entget (ssname ss1 i)))))
- (setq a1 (vl-string-search "," string))
- (setq string (substr string 3 (- a1 2)))
- (setq sum1 (+ sum1 (atof string)))
- (setq i (+ i 1))
- )
- ;下面对ss2操作
- (setq i 0 sum2 0 )
- (setq n (sslength ss2))
- (repeat n
- (setq string (cdr (assoc 1 (entget (ssname ss2 i)))))
- (setq sum2 (+ sum2 (atof string)))
- (setq i (+ i 1))
- )
- (setq sum1 (+ sum1 sum2))
- (setq p1 (getpoint "\n计算结果基点: "))
- (command "text" "ml" p1 "150" "0" (strcat "\n 轴力和:"(rtos sum1 2 0) "") ""); 轴力结果
- )
参考上面的讨论,我写了个轴力求和的代码。轴力的数值分别在81 82 图层,下面的代码两个图层一起选择的时候,就没有问题,但是如果只选其中一个图层时,就出错了 “*error* 函数中出错no function definition: &TSTY”。请问是怎么回事呢? |