有什么办法可以将量取的直线求和呢(一一量取在确认求和)
<p>有什么办法可以将量取的直线求和呢(一一量取在确认求和)</p><p>在进行工程统计的时候好蹩脚。算量头都大了。如果能解决可是太妙了。</p><p>就是将直线一段段的量出距离。中间不返回任何结果,到确认(空格,回车或右键)时,计算先前量取的直线长度之和。</p>;; 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
<p>只是直线吧!</p><p>private sub ppcountline()</p><p> dim pppt1 as variant</p><p> dim pppt2 as acadentity</p><p>dim pppsetpp as acadselectionset</p><p>if pppsetpp.count>0 then</p><p> pppsetpp.delete</p><p>end if</p><p>else</p><p> 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 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:" & j</p><p>end sub</p>
页:
[1]