明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2507|回复: 2

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

[复制链接]
发表于 2007-8-23 11:32:00 | 显示全部楼层 |阅读模式

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

在进行工程统计的时候好蹩脚。算量头都大了。如果能解决可是太妙了。

就是将直线一段段的量出距离。中间不返回任何结果,到确认(空格,回车或右键)时,计算先前量取的直线长度之和。

发表于 2007-8-23 20:58:00 | 显示全部楼层
  1. ;; LENGTH.LSP  Copyright 2003,  Tony Tanzillo
  2. ;;
  3. ;; Provided for private use only, reproduction or
  4. ;; redistribution expressly prohibited.
  5. ;;
  6. ;; Adds LENGTH command to AutoCAD which when used, will report
  7. ;; the total length of all selected 2D curves (including lines,
  8. ;; polylines, arcs, splines, and elliptical curves).
  9. ;;
  10. ;; Does not add length of CIRCLES.
  11. (defun C:LENGTH ( / ss len i)
  12.    (vl-load-com)
  13.    (setq ss (ssget '((0 .
  14.        "LINE,ARC,SPLINE,ELLIPSE,POLYLINE,LWPOLYLINE")))
  15.         len 0.0
  16.    )
  17.    (repeat (setq i (sslength ss))
  18.       (setq len (+ len (getlength (ssname ss (setq i (1- i))))))
  19.    )
  20.    (write-line (strcat "\nTotal length = " (rtos len)))
  21.    (princ)
  22. )
  23. (defun getLength (ename / acurve len)
  24.    (setq ACurve (vlax-ename->vla-object ename))
  25.    (setq len 0.0)
  26.    (vl-catch-all-apply
  27.      '(lambda ()
  28.          (setq len
  29.             (vlax-curve-getDistAtParam
  30.                ACurve
  31.               (vlax-curve-getEndParam ACurve)
  32.             )
  33.          )
  34.       )
  35.    )
  36.    len
  37. )
or
http://forums.cadalyst.com/showthread.php?t=4005

发表于 2007-9-6 16:08:00 | 显示全部楼层

只是直线吧!

private sub ppcountline()

   dim pppt1 as variant

   dim pppt2 as acadentity

dim pppsetpp as acadselectionset

if pppsetpp.count>0 then

   pppsetpp.delete

end if

else

 pppset=ppthisdrawing.selectionsets.add("line11")

pppset.selectonscreen

dim j as double

j=0

dim aaa as acadentity

dim bbb as acadline

for each aaa in pppset

if aaa.objectname="acadline" then

set bbb=aaa

j=j+aaa.length

msgbox "total line length:" & j

end sub

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-27 23:27 , Processed in 0.177396 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表