明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: kele99kele

[已解答] 点表连线求最优算法

[复制链接]
发表于 2015-8-26 10:26 | 显示全部楼层
(foreach x lst
==>(foreach x (cdr lsts)
难道你没发现??? ,这句改了,就没重线了。

点评

实测有效,我脑子里还转不过这个弯,感谢指导,万分感激。  发表于 2015-8-26 16:53
恩,等下我调试下,我还没改码,前面的帖子提到了一个犀牛,以前没接触过,我看上手快不快,如果快的话就放弃自己编了  发表于 2015-8-26 15:06
发表于 2015-8-26 13:17 | 显示全部楼层
陨落 发表于 2015-8-30 05:16
犀牛里面有很多插件,可以直接划分三维网格,结合其三维投影等强大的三维功能,是为做网架之必备神器

陨落兄,你说的犀牛插件,是grasshopper里的?还是犀牛的插件,能提供下插件的名称吗?
发表于 2015-8-26 15:31 | 显示全部楼层
vlisp2012 发表于 2015-8-26 13:17
陨落兄,你说的犀牛插件,是grasshopper里的?还是犀牛的插件,能提供下插件的名称吗?

最常用 的是paneling tools。 其他还有很多专门做网架用的
发表于 2015-8-30 14:06 | 显示全部楼层
犀牛的教程很多,百度即可,我最近太忙了,实在抽不出时间来做教程

点评

还是谢谢你  发表于 2015-8-30 14:09
发表于 2015-11-12 20:17 | 显示全部楼层
这个楼主自己解决了吗?

点评

没有完美解决,用的笨办法  发表于 2015-11-13 09:49
发表于 2015-11-13 09:55 | 显示全部楼层
  1. (defun AYL-Points (myFunction / PntLst ss)
  2.   (if (setq ss (ssget))
  3.     (progn
  4.       (setq PntLst (AYL-ss->PntLst ss))
  5.       (setq ss nil)
  6.       (cond
  7.         ((caddr PntLst)
  8.          (foreach x (myFunction PntLst)
  9.            (entmake (list '(0 . "Line") (cons 10 (car x)) (cons 11 (cadr x))))
  10.          )
  11.         )
  12.         ((cadr PntLst)
  13.          (entmake (list '(0 . "Line") (cons 10 (car PntLst)) (cons 11 (cadr PntLst))))
  14.         )
  15.         (t nil)
  16.       )
  17.     )
  18.     (princ "\n选择了0个对象")
  19.   )
  20.   (princ)
  21. )
  22. (defun AYL-ss->PntLst (ss / PntLst n)
  23.   (setq PntLst nil)
  24.   (repeat (setq n (sslength ss))
  25.     (setq PntLst (cons (cdr (assoc 10 (entget (ssname ss (setq n (1- n)))))) PntLst))
  26.   )
  27. )
  28. (defun AYL-Points-Mesh2 (PntLst / TmpLst tttLst Point RetLst CuLine Points bbbLst tt0Lst *Bcde*)
  29.   (setq TmpLst (AYL-Points->Lines PntLst))
  30.   (setq Point (caar TmpLst))
  31.   (setq PntLst (vl-remove Point PntLst))
  32.   (setq RetLst nil
  33.         tttLst nil
  34.         Points (list Point)
  35.   )
  36.   (while TmpLst
  37.     (setq CuLine (car TmpLst))
  38.     (if (AYL-isInters CuLine RetLst)
  39.       nil
  40.       (progn
  41.         (setq RetLst (cons CuLine RetLst)
  42.               tttLst (cons CuLine tttLst)
  43.               bbbLst nil
  44.         )
  45.         (while Points
  46.           (setq Point (car Points))
  47.           (setq Points (cdr Points))
  48.           (setq tt0Lst nil)
  49.           (foreach x tttLst
  50.             (if (member Point x)
  51.               (progn
  52.                 (setq tttLst (vl-remove x tttLst))
  53.                 (setq tt0Lst (cons (car (vl-remove Point x)) tt0Lst))
  54.               )
  55.             )
  56.           )
  57.           (if tt0Lst
  58.             (progn
  59.               (foreach x tt0Lst (setq PntLst (vl-remove x PntLst)))
  60.               (setq Points (append Points tt0Lst))
  61.             )
  62.           )
  63.           (setq bbbLst (cons Point bbbLst))
  64.         )
  65.         (setq Points bbbLst)
  66.         (if (and (not PntLst) (= Integ0 Number))
  67.           (setq *Bcde* TmpLst TmpLst nil)
  68.         )
  69.       )
  70.     )
  71.     (setq TmpLst (cdr TmpLst))
  72.   )
  73.   (while (and (setq CuLine (car *Bcde*))
  74.               (equal (apply 'distance (car RetLst)) (apply 'distance CuLine) 0.000001)
  75.          )
  76.     (if (AYL-isInters CuLine RetLst)
  77.       nil
  78.       (setq RetLst (cons CuLine RetLst))
  79.     )
  80.     (setq *Bcde* (cdr *Bcde*))
  81.   )
  82.   RetLst
  83. )
  84. (defun AYL-isInters (CuLine tttLst / TorNil Point0 Point1 Point2 Point3 *Bcde*)
  85.   (setq TorNil nil)
  86.   (setq Point0 (car CuLine))
  87.   (setq Point1 (cadr CuLine))
  88.   (while tttLst
  89.     (setq Point2 (caar tttLst))
  90.     (setq Point3 (cadar tttLst))
  91.     ;;两直线相交,但不是首尾相连
  92.     (if (and (inters Point0 Point1 Point2 Point3)
  93.              (not (equal (distance Point0 Point2) 0 0.000001))
  94.              (not (equal (distance Point0 Point3) 0 0.000001))
  95.              (not (equal (distance Point1 Point2) 0 0.000001))
  96.              (not (equal (distance Point1 Point3) 0 0.000001))
  97.         )
  98.       (setq TorNil t tttLst nil)
  99.       (setq tttLst (cdr tttLst))
  100.     )
  101.   )
  102.   TorNil
  103. )
  104. (defun AYL-Points->Lines (PntLst / RetLst Point)
  105.   (setq RetLst nil)
  106.   (while (cadr PntLst)
  107.     (setq Point (car PntLst))
  108.     (foreach x (setq PntLst (cdr PntLst))
  109.       (setq RetLst (cons (list Point x) RetLst))
  110.     )
  111.   )
  112.   (vl-sort RetLst (function (lambda (x y) (< (apply 'distance x) (apply 'distance y)))))
  113. )
  114. (defun c:ttt3 ()
  115.   (AYL-Points AYL-Points-Mesh2)
  116. )

点评

能简述下“AYL-Points-Mesh2”函数的计算思路么  发表于 2015-11-13 11:53
感谢帮助,我测试下  发表于 2015-11-13 11:41

评分

参与人数 1明经币 +1 收起 理由
lucas_3333 + 1 乐于助人!

查看全部评分

发表于 2015-11-13 12:18 | 显示全部楼层
就是从最小长度开始连,然后不断增加这个长度,一直到所有的点都连在一起为止。

点评

思路很新颖,感谢  发表于 2015-11-13 12:39
发表于 2015-11-13 15:39 | 显示全部楼层
已解决,请问怎么解决的?

点评

我的解决方法在3楼,笨办法  发表于 2015-11-13 17:34
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-21 08:22 , Processed in 0.198761 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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