明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 940|回复: 5

求CAD下VBA代码

[复制链接]
发表于 2016-4-21 17:32 | 显示全部楼层 |阅读模式
有一些坐标值,怎样通过比较求出X和Y坐标的最大最小值,谢谢,求大神们帮忙
 楼主| 发表于 2016-4-21 20:49 | 显示全部楼层
有没有大神啊

发表于 2016-4-21 21:34 | 显示全部楼层
可用快速排序
 楼主| 发表于 2016-4-21 21:56 | 显示全部楼层
gzxl 发表于 2016-4-21 21:34
可用快速排序

能具体点说吗,如果有代码最好了,谢谢
发表于 2016-4-21 22:27 | 显示全部楼层
本帖最后由 gzxl 于 2016-4-21 22:31 编辑
馨馨 发表于 2016-4-21 21:56
能具体点说吗,如果有代码最好了,谢谢

按X最小或最大排序,用快速排序法(经典高效)
然后取第一个元素或最后一个元素就是想要的
VBA不太懂了,百度吧

这个是arx的
  1. void SortPointsOnX(AcGePoint2dArray &points, int left, int right)
  2. {
  3.     AcGePoint2d firtPt, lastPt;
  4.     int rtemp, ltemp;
  5.     ltemp = left;
  6.     rtemp = right;
  7.     firtPt = points[(left + right) / 2]; // 分界值
  8.     while (ltemp < rtemp)
  9.     {
  10.         while (points[ltemp].x < firtPt.x)
  11.         {
  12.             ++ltemp;
  13.         }
  14.         while (points[rtemp].x > firtPt.x)
  15.         {
  16.             --rtemp;
  17.         }
  18.         if (ltemp <= rtemp)
  19.         {
  20.             lastPt = points[ltemp];
  21.             points[ltemp] = points[rtemp];
  22.             points[rtemp] = lastPt;
  23.             --rtemp;
  24.             ++ltemp;
  25.         }
  26.     }
  27.     if (ltemp == rtemp)
  28.     {
  29.         ltemp++;
  30.     }
  31.     if (left < rtemp)
  32.     {
  33.         SortPointsOnX(points, left, ltemp - 1); // 递归调用
  34.     }
  35.     if (ltemp < right)
  36.     {
  37.         SortPointsOnX(points, rtemp + 1, right);
  38.     }
  39. }
复制代码

评分

参与人数 1金钱 +10 收起 理由
馨馨 + 10

查看全部评分

发表于 2017-10-15 10:40 | 显示全部楼层

大哥  您那有横断面自动提取的lsp源码吗 能提供一份吗   麻烦了  有的话 请发到1141235788@qq.com
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-27 04:04 , Processed in 0.229050 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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