合力位置定位
求助:自己编了一个小程序,就是根据各个力的作用点求出他们合力的作用点,但是编写while循环的时候出现了小问题,就是不晓得怎么退出while循环,请高人指点(setvar "cmdecho" 0)
(if (= (tblsearch "layer" "合力点") nil)
(command "-layer" "m" "合力点" "c" "3" "" "")
)
(setvar "clayer" "合力点")
(setq pi90 (/ pi 2) )
(setq pi270 (* 3 (/ pi 2)) )
(setq txt_li '())
(setq p1 (getpoint "选取点位置:"))
(while t
(setq xx1 (car p1))
(setq yy1 (cadr p1))
(setq sstext1 (car (entsel "\n选择文本:")))
(setq N1 (atof (cdr (assoc 1 (entget sstext1)))))
(setq Mx1 (* N1 yy1))
(setq My1 (* N1 xx1))
(setq aa1 (list N1 Mx1 My1))
(setq txt_li (cons aa1 txt_li))
(setq p1 (getpoint "选取点位置:"))
) ;_ 结束while
(setq nn (vl-list-length txt_li))
;;存储力矩
(setq sum_li '())
(setq j 0)
(repeat 3
(setq sum_j 0)
(setq i 0)
(repeat nn
(setq list_i (nth i txt_li))
(setq list_i_j (nth j list_i))
(setq sum_j (+ sum_j list_i_j))
(setq i (1+ i))
)
(setq sum_li (cons sum_j sum_li))
(setq j (1+ j))
)
(setq My1_sum (nth 0 sum_li))
(setq Mx1_sum (nth 1 sum_li))
(setq N1_sum (nth 2 sum_li))
(setq node_x (/ My1_sumN1_sum ))
(setq node_y (/ Mx1_sumN1_sum ))
(setq node_xy (list node_xnode_y))
;;画中心点
(setq p1 (polar node_xy pi 250))
(setq p2 (polar node_xy 0 250))
(setq p3 (polar node_xy pi90 250))
(setq p4 (polar node_xy pi270 250))
(command "line" p1 p2 "")
(command "line" p3 p4 "")
这是测试的dwg文件 (while T ....)
这是无限循环的架势
(setq loop T)
(while loop
...
(if (...)
(setq loop nil)
)
)
这样才可以退出循环 (while t
换成
(while (and (setq p1 (getpoint "选取点位置:"))
(setq sstext1 (car (entsel "\n选择文本:"))))
即可
第一个(setq p1 (getpoint "选取点位置:"))和最后一个 (setq p1 (getpoint "选取点位置:"))去掉
(setq sstext1 (car (entsel "\n选择文本:"))) 去掉 edata 发表于 2014-7-24 20:00 static/image/common/back.gif
换成
可以了,有些逻辑自己百思不得其解,但是一经点拨茅塞顿开,只能说佩服,在此感谢 masterlong 发表于 2014-7-24 18:26 static/image/common/back.gif
(while T ....)
这是无限循环的架势
已经解决了,谢谢
页:
[1]