dailysc 发表于 2007-8-23 11:32:00

有什么办法可以将量取的直线求和呢(一一量取在确认求和)

<p>有什么办法可以将量取的直线求和呢(一一量取在确认求和)</p><p>在进行工程统计的时候好蹩脚。算量头都大了。如果能解决可是太妙了。</p><p>就是将直线一段段的量出距离。中间不返回任何结果,到确认(空格,回车或右键)时,计算先前量取的直线长度之和。</p>

Andyhon 发表于 2007-8-23 20:58:00


;; LENGTH.LSPCopyright 2003,Tony Tanzillo
;;
;; Provided for private use only, reproduction or
;; redistribution expressly prohibited.
;;
;; Adds LENGTH command to AutoCAD which when used, will report
;; the total length of all selected 2D curves (including lines,
;; polylines, arcs, splines, and elliptical curves).
;;
;; Does not add length of CIRCLES.
(defun C:LENGTH ( / ss len i)
   (vl-load-com)
   (setq ss (ssget '((0 .
       "LINE,ARC,SPLINE,ELLIPSE,POLYLINE,LWPOLYLINE")))
      len 0.0
   )
   (repeat (setq i (sslength ss))
      (setq len (+ len (getlength (ssname ss (setq i (1- i))))))
   )
   (write-line (strcat "\nTotal length = " (rtos len)))
   (princ)
)

(defun getLength (ename / acurve len)
   (setq ACurve (vlax-ename->vla-object ename))
   (setq len 0.0)
   (vl-catch-all-apply
   '(lambda ()
         (setq len
            (vlax-curve-getDistAtParam
               ACurve
            (vlax-curve-getEndParam ACurve)
            )
         )
      )
   )
   len
)
or
http://forums.cadalyst.com/showthread.php?t=4005

天龙八部 发表于 2007-9-6 16:08:00

<p>只是直线吧!</p><p>private sub ppcountline()</p><p>&nbsp;&nbsp; dim pppt1 as variant</p><p>&nbsp;&nbsp; dim pppt2 as acadentity</p><p>dim pppsetpp as acadselectionset</p><p>if pppsetpp.count&gt;0 then</p><p>&nbsp;&nbsp; pppsetpp.delete</p><p>end if</p><p>else</p><p>&nbsp;pppset=ppthisdrawing.selectionsets.add("line11")</p><p>pppset.selectonscreen</p><p>dim j as double</p><p>j=0</p><p></p><p>dim aaa as acadentity</p><p>dim bbb as acadline</p><p>for each aaa&nbsp;in pppset</p><p>if aaa.objectname="acadline" then</p><p>set bbb=aaa</p><p>j=j+aaa.length</p><p>msgbox "total line length:" &amp; j</p><p>end sub</p>
页: [1]
查看完整版本: 有什么办法可以将量取的直线求和呢(一一量取在确认求和)