乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 60|回复: 3

(用户选择的)折线的总长度

[复制链接]

1

主题

1

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2016-8-17 09:38:24 | 显示全部楼层 |阅读模式
嘿,大家好!
我已经处理这个问题很长一段时间了,似乎无法解决它。我想过也许让Lisp接收用户选择的折线,然后转储它们的信息并将其发送到DIESEL并从DIESEL中检索计算出的数字并在警报中吐出给用户,但我似乎无法让它工作,因为我无法运行任何VLAX代码。
那么,有没有什么方法可以代替下面代码中的VLAX...(从旧帖子复制并粘贴)

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2016-8-17 09:50:48 | 显示全部楼层
也许是这个?顺便说一句...欢迎来到TheSwamp
  1. ;   Length/Area of Polyline by Layer
  2. ;   David Bethel May 2004 from an original idea by David Watson
  3. ;   This command will give a total area or length for all polylines on a specified layer.
  4. ;
  5. (defun c:zone ( / ss la rv i tv op en)
  6.    (while (not ss)
  7.           (princ "\nPick any object on the required layer")
  8.           (setq ss (ssget)))
  9.    (initget "Length Area")
  10.    (setq rv (getkword "\nWould you like to measure Length/ : "))
  11.    (and (not rv)
  12.         (setq rv "Area"))
  13.    (setq la (cdr (assoc 8 (entget (ssname ss 0))))
  14.          ss (ssget "X" (list (cons 0 "*POLYLINE")
  15.                              (cons 8 la)))
  16.           i (sslength ss)
  17.          tv 0
  18.          op 0)
  19.    (while (not (minusp (setq i (1- i))))
  20.           (setq en (ssname ss i))
  21.           (command "_.AREA" "_E" en)
  22.           (cond ((= rv "Length")
  23.                  (setq tv (+ tv (getvar "PERIMETER"))))
  24.                 (T
  25.                  (setq tv (+ tv (getvar "AREA")))
  26.                  (if (/= (logand (cdr (assoc 70 (entget en))) 1) 1)
  27.                      (setq op (1+ op))))))
  28.    (princ (strcat "\nTotal " rv
  29.                   " for layer " la
  30.                   " = " (rtos tv 2 2)
  31.                   " in " (itoa (sslength ss)) " polylines\n"
  32.                   (if (/= rv "Length")
  33.                       (strcat (itoa op) " with open polylines") "")))
  34.    (prin1))
回复

使用道具 举报

51

主题

613

帖子

9

银币

中流砥柱

Rank: 25

铜币
815
发表于 2016-8-17 10:10:52 | 显示全部楼层
确定是因为没有用(vl-load-com)初始化VLAX吗?
尝试此例程
http://www . lee-MAC . com/totallengthndarea . html
  1. ;;--------------------=={ Total Length }==--------------------;;
  2. ;;                                                            ;;
  3. ;;  Displays the total length of selected objects at the      ;;
  4. ;;  command line. The units and precision format of the       ;;
  5. ;;  printed result is dependent upon the settings of the      ;;
  6. ;;  LUNITS & LUPREC system variables respectively.            ;;
  7. ;;------------------------------------------------------------;;
  8. ;;  Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;
  9. ;;------------------------------------------------------------;;
  10. (defun c:tlen ( / e i l s )
  11.     (if (setq s
  12.             (ssget
  13.                '(   (0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")
  14.                     (-4 . "
  15.                         (-4 . "
  16.                             (0 . "POLYLINE") (-4 . "&") (70 . 80)
  17.                         (-4 . "AND>")
  18.                     (-4 . "NOT>")
  19.                 )
  20.             )
  21.         )
  22.         (progn
  23.             (setq l 0.0)
  24.             (repeat (setq i (sslength s))
  25.                 (setq e (ssname s (setq i (1- i)))
  26.                       l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)))
  27.                 )
  28.             )
  29.             (princ "\nTotal Length: ")
  30.             (princ (rtos l))
  31.         )
  32.     )
  33.     (princ)
  34. )
  35. (vl-load-com) (princ)
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2016-8-17 11:15:32 | 显示全部楼层
我在土木设计工作,所以我最终需要更详细级别。
Cheers
AddLlong-支持圆弧、线条、折线和土木3D管道:
  1. (defun c:AddLength (/ *error* ss l p)
  2.   
  3.   (defun *error* (msg)
  4.     (if ss (vla-delete ss))
  5.     (cond ((not msg))                                                   ; Normal exit
  6.           ((member msg '("Function cancelled" "quit / exit abort")))    ;  or (quit)
  7.           ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
  8.     )
  9.     (princ)
  10.   )
  11.   
  12.   (if (ssget "_:L" '((0 . "AECC_PIPE,ARC,LINE,*POLYLINE")))
  13.     (progn
  14.       (vlax-for x (setq ss (vla-get-activeselectionset acDoc))
  15.         (cond
  16.           ((= "AeccDbPipe" (vla-get-objectname x))
  17.            ;;
  18.            (setq p (cons (vlax-get x 'length2d) p))
  19.           )
  20.           ((setq l
  21.                   (cons
  22.                     (vlax-get x
  23.                               (if (= "AcDbArc" (vla-get-objectname x))
  24.                                 'arclength
  25.                                 'length
  26.                               )
  27.                     )
  28.                     l
  29.                   )
  30.            )
  31.           )
  32.         )
  33.       )
  34.       (if p
  35.         (prompt (strcat "\nTotal pipe length: "
  36.                         (rtos (setq p (apply '+ p)) 2 2)
  37.                         " LF | "
  38.                         (rtos (/ p 3.0) 2 2)
  39.                         " LY | "
  40.                         (rtos (/ p 5280.0) 2 2)
  41.                         " MI "
  42.                 )
  43.         )
  44.       )
  45.       (if l
  46.         (prompt (strcat "\nTotal length: "
  47.                         (rtos (setq l (apply '+ l)) 2 2)
  48.                         " LF | "
  49.                         (rtos (/ l 3.0) 2 2)
  50.                         " LY | "
  51.                         (rtos (/ l 5280.0) 2 2)
  52.                         " MI "
  53.                 )
  54.         )
  55.       )
  56.     )
  57.   )
  58.   (*error* nil)
  59. )

AddArea-支持圆圈、阴影和折线:
  1. (defun c:AddArea (/ *error* ss area)
  2.   (defun *error* (msg)
  3.     (if ss (vla-delete ss))
  4.     (cond ((not msg))                                                   ; Normal exit
  5.           ((member msg '("Function cancelled" "quit / exit abort")))    ;  or (quit)
  6.           ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
  7.     )
  8.     (princ)
  9.   )
  10.   
  11.   (if (ssget '((0 . "CIRCLE,HATCH,*POLYLINE")))
  12.     (progn
  13.       (vlax-for x (setq ss (vla-get-activeselectionset acDoc))
  14.         (setq area (cons (vla-get-area x) area))
  15.       )
  16.       (prompt (strcat "\nTotal area: "
  17.                       (rtos (setq area (apply '+ area)) 2 2)
  18.                       " SF | "
  19.                       (rtos (/ area 9.0) 2 2)
  20.                       " SY | "
  21.                       (rtos (/ area 43560.0) 2 2)
  22.                       " AC "
  23.               )
  24.       )
  25.     )
  26.   )
  27.   (*error* nil)
  28. )
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 21:10 , Processed in 0.597158 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表