cooltl18 发表于 2006-11-20 22:37:00

如何计算多个物体的周长总和

如何利用LISP来统计选取物体的总周长,请大侠们帮助!

tcsl9621 发表于 2006-11-20 22:49:00

先将所选的对像按类型分开分别求出周长再相加。

Andyhon 发表于 2006-11-21 07:19:00

visit Site: <A href="http://www.menziengineering.ch/Downloads/Download.htm#19" target="_blank" >http://www.menziengineering.ch/Downloads/Download.htm#19</A><BR>and search 'VxGetObjLength'

rongyifei 发表于 2006-11-21 21:32:00

分别提取图元的长度属性(如Arc为arclength;line,polyline,lightweightpolyline为length;   cirlce为Circumference等等),然后相加!

szliaolj 发表于 2006-11-23 11:09:00

<P>明总那里有一个LSP,很造合你</P>
<P>(defun c:abk ()<BR>(setvar "cmdecho" 0)<BR>(command "layer" "S" "0" "")<BR>(setq p&nbsp; (/ pi 2.0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g (+ pi p))<BR>&nbsp;&nbsp; (setq aa (ssget))<BR>&nbsp; (setq i 0)<BR>&nbsp;&nbsp; (setq ab (ssadd))<BR>&nbsp;&nbsp; (repeat (sslength aa)<BR>&nbsp;&nbsp;&nbsp; (setq aab (ssname aa i))<BR>&nbsp;&nbsp;&nbsp;&nbsp; (setq bb (cdr (assoc 0 (entget aab))))<BR>&nbsp;&nbsp;&nbsp;&nbsp; (cond ((= bb "LINE")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq pd (list aab (cdr (assoc 10 (entget aab)))))<BR>&nbsp;&nbsp;&nbsp;&nbsp; ))<BR>&nbsp;&nbsp;&nbsp;&nbsp; (cond ((= bb "CIRCLE")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq pd (list aab (cdr (assoc 10 (entget aab)))))<BR>&nbsp;&nbsp;&nbsp;&nbsp; ))<BR>&nbsp;&nbsp;&nbsp;&nbsp; (cond ((= bb "ARC")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq pd (list aab (cdr (assoc 10 (entget aab)))))<BR>&nbsp;&nbsp;&nbsp;&nbsp; ))&nbsp;&nbsp;&nbsp; <BR>(cond ((= i 0)<BR>(setq j 0)<BR>(cond ((= j 0)<BR>(cond ((/= bb "LINE")<BR>(setq aad 0)))<BR>(cond ((/= bb "CIRCLE")<BR>(setq bad 0)))<BR>(cond ((/= bb "ARC")<BR>(setq cad 0)))))))<BR>(setq j (+ j 1))<BR>(cond ((= bb "LINE")<BR>(setq st (cdr (assoc 11 (entget aab))))<BR>(setq qed (cdr (assoc 10 (entget aab))))<BR>(setq ad (distance st qed))<BR>(cond ((= i 0)<BR>(setq aad ad)))<BR>(cond ((&gt;= i 1)<BR>(setq aad (+ ad aad))))<BR>))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>(cond ((= bb "CIRCLE")<BR>&nbsp; (setq aeed (cdr (assoc 40 (entget aab))))<BR>&nbsp; (setq ad (* aeed pi 2.0))<BR>(cond ((= i 0)<BR>(setq bad ad)))<BR>(cond ((&gt;= i 1)<BR>(setq bad (+ ad bad))))<BR>))<BR>(cond ((= bb "ARC")<BR>&nbsp; (setq ast (cdr (assoc 50 (entget aab))))<BR>&nbsp; (setq sst (cdr (assoc 51 (entget aab))))<BR>&nbsp; (setq beed (cdr (assoc 40 (entget aab))))<BR>(cond ((&gt;= ast 0)<BR>(cond ((&lt; ast p)<BR>(cond ((&gt; ast sst)<BR>(cond ((&gt;= (* pi 2.0))<BR>(setq xb (- ast sst))))<BR>(cond ((&gt; sst 0)<BR>(setq xb1 (- p ast))<BR>(setq xb (+ g xb1 sst))))))<BR>(cond ((&lt; ast sst)<BR>(cond ((&gt;= sst 0)<BR>(setq xb1 (- p ast))<BR>(setq xb (+ pi xb1 sst))))<BR>(cond ((&lt; sst (* pi 2.0))<BR>(cond ((&lt; sst p)<BR>(setq xb (- sst ast))))<BR>(cond ((&lt; sst pi)<BR>(setq xb1 (- p ast))<BR>(setq xb2 (- sst p))<BR>(setq xb (+ xb1 xb2))))<BR>(cond ((&lt; sst g)<BR>(setq xb1 (- p ast))<BR>(setq xb2 (- sst pi))<BR>(setq xb (+ xb1 xb2 p))))<BR>(cond ((&lt; sst (* pi 2.0))<BR>(setq xb1 (- p ast))<BR>(setq xb2 (- sst g))<BR>(setq xb (+ xb1 xb2 pi))))<BR>))<BR>))<BR>))))<BR>(cond ((&gt;= ast p)<BR>(cond ((&lt; ast pi)<BR>(cond ((&gt; ast sst)<BR>(cond ((&lt;= sst p)<BR>(setq xb1 (- ast p))<BR>(setq xb2 (- p sst))<BR>(setq xb (- (* pi 2.0)xb1 xb2))))<BR>(cond ((&gt; sst p)<BR>(setq xb (- (* pi 2.0)(- ast sst)))))))<BR>(cond ((&lt; ast sst)<BR>(setq xb (- sst ast))))<BR>))))</P>
<P><BR>(cond ((&gt;= ast pi)<BR>(cond ((&lt; ast g)<BR>(cond ((&gt; ast sst)<BR>(cond ((&gt; sst 0)<BR>(setq xb2 sst)<BR>(setq xb1 (- g ast))<BR>(setq xb (+ xb1 xb2 p))))<BR>(cond ((&gt;= sst p)<BR>(setq xb1 (- ast pi))<BR>(setq xb2 (- pi sst))<BR>(setq xb (- (* pi 2.0) xb1 xb2))))<BR>(cond ((&gt;= sst pi)<BR>(setq xb1 (- g ast))<BR>(setq xb2 (- sst pi))<BR>(setq xb (+ g xb1 xb2))))<BR>(cond ((&gt; sst g)<BR>(setq xb1 (- sst pi))<BR>(setq xb2 (- g ast))<BR>(setq xb (+ xb1 xb2 g))))<BR>))<BR>(cond ((&lt; ast sst)<BR>(setq xb (- sst ast))))<BR>))))<BR>(cond ((&gt;= ast g)<BR>(cond ((&lt; ast (* pi 2.0))<BR>(cond ((&gt; ast sst)<BR>(cond ((&gt;= sst g)<BR>(setq xb1 sst)<BR>(setq xb2 (- (* pi 2.0)ast))<BR>(setq xb (+ xb1 xb2))))<BR>(cond ((&lt; sst g)<BR>(setq xb1 (- sst g))<BR>(setq xb2 (- (* pi 2.0)ast))<BR>(setq xb (+ g xb1 xb2))))<BR>))<BR>(cond ((&lt; ast sst)<BR>(setq xb (- sst ast))))<BR>))))<BR>(setq ad (* beed xb))<BR>(cond ((= i 0)<BR>(setq cad ad)))<BR>(cond ((&gt;= i 1)<BR>(setq cad (+ ad cad))))<BR>))<BR>&nbsp; (setq i (+ 1 i)))<BR>(setq aaad (+ aad bad cad))<BR>(setq ai aaad)<BR>(setq aai (rtos ai 2 4))<BR>(setq abi "&lt;")<BR>(setq aci "&gt;")<BR>(setq adi "线段总长为:")<BR>(princ (strcat adi abi aai aci))<BR>(command "pickbox" 3)<BR>(princ)<BR>)</P>

hb_xiaofen 发表于 2006-11-23 13:02:00

本帖最后由 作者 于 2008-2-13 17:59:22 编辑

命令名称gl

hb_xiaofen 发表于 2006-11-23 13:05:00

本帖最后由 作者 于 2008-2-13 18:02:07 编辑 <br /><br /> <p>只要你选择的物体有长度,就能计算,PLINE,ARC CIRCLE 椭圆,SPLINE可以一起选,</p><p>修改了好了,程序只选择有以上几种对象,如果选择了其它对象自动过滤掉)</p>

rongyifei 发表于 2006-11-23 21:11:00

<P>六楼的程序写得很简洁,也符合要求,支持!</P>

TANER 发表于 2006-12-3 20:00:00

(defun th-curveslength-ss (ss / ss ssv lens)
(if (= nil ss)
    (setq ss (ssget '((0 . "*LINE,ARC,CIRCLE,ELLIPSE"))))
)
(setq ssv (vla-get-activeselectionset (vla-get-activedocument
      (vlax-get-acad-object)
   )
   )
lens 0
)
(vlax-for obj ssv (setq lens (+ lens (vlax-curve-getdistatparam obj
          (vlax-curve-getendparam obj)
         )
          )
      )
)
)

cqlangzi 发表于 2007-8-6 20:08:00

<p>请问大哥呀&nbsp; 这个GL程序放到哪个启动组呀?</p>
页: [1]
查看完整版本: 如何计算多个物体的周长总和