乐筑天下

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

[编程交流] LW多段线长度(顶点到v

[复制链接]

1

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:23:50 | 显示全部楼层 |阅读模式
亲爱的朋友们
 
我需要一个lisp程序,即Lwpolyline总长度和顶点到顶点之间的长度,它应该导出为文本文件。
 
请给出解决方案
 
非常感谢。
瓦苏
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 08:31:09 | 显示全部楼层
很无聊
 
  1. (defun c:PlLen (/ i ss file ent j str)
  2. (vl-load-com)
  3. (cond ((and (setq i -1 ss (ssget '((0 . "LWPOLYLINE"))))
  4.              (setq file (getfiled "Output File" "" "txt" 1)))
  5.         (setq file (open file "w"))
  6.         
  7.         (while (setq ent (ssname ss (setq i (1+ i))))
  8.           (setq j (1- (vlax-curve-getStartParam ent)) Str "")
  9.           (while (<= (setq j (1+ j)) (vlax-curve-getEndParam ent))
  10.             (setq Str
  11.               (strcat Str
  12.                 (rtos (- (vlax-curve-getDistatParam ent j)
  13.                            (if (zerop j) 0
  14.                              (vlax-curve-getDistatParam ent (1- j)))) 2 2) (chr 9))))
  15.           (write-line (strcat Str (rtos (vlax-curve-getDistatParam ent
  16.                                           (vlax-curve-getEndParam ent)) 2 2)) file))
  17.         (close file)))
  18. (princ))
回复

使用道具 举报

1

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:36:46 | 显示全部楼层
非常感谢Stefen!
这段代码对我帮助很大!!
回复

使用道具 举报

6

主题

249

帖子

247

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 08:41:05 | 显示全部楼层
听到这个我很高兴,科菲什。不客气。
回复

使用道具 举报

1

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:47:43 | 显示全部楼层
回复

使用道具 举报

1

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:53:55 | 显示全部楼层
Sorry again i am asking is each vertex coordinates and length also
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 08:59:58 | 显示全部楼层
>> Steve,
 
You're not dense
 
I have formatted it in such a way that each entry in the file is the distance to each vertex in turn (from the start of the curve), hence the distance from the start vertex to the start vertex is always zero.. - I probably could have ignored this point, but I wanted the number of distances to equal the number of points... with the length being the last entry.
回复

使用道具 举报

6

主题

249

帖子

247

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 09:02:31 | 显示全部楼层
 
as he utters a sigh of relief !!!   thanks LM, I'm not so dizzy now.
回复

使用道具 举报

1

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 09:08:59 | 显示全部楼层
Hi friends,
This is what I wanted from ages!!
but I nneed result that means segment lengths as stored in variables as that I can assign them as values of attributes in a block!
Can we do this!
 
Thanks in advance.
 
corfish
回复

使用道具 举报

0

主题

375

帖子

385

银币

限制会员

铜币
-7
发表于 2022-7-6 09:16:20 | 显示全部楼层
Try this variant
  1. (defun C:TEST ( / SegmLen ss lst) (defun SegmLen (e / i l)   (repeat (setq i (fix (vlax-curve-GetEndParam e)))     (setq l (cons (apply '- (mapcar '(lambda (x) (vlax-curve-GetDistAtParam e x)) (list i (setq i (1- i))))) l))   ) ) (if   (setq ss (ssget ":E:S" '((0 . "*POLYLINE"))))   (progn     (setq lst (SegmLen (ssname ss 0)))     (princ lst) ;just to show result     ;do whatever you want with lst variable   ) ) (princ))
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-9 08:19 , Processed in 0.483110 second(s), 72 queries .

© 2020-2025 乐筑天下

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