明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 575|回复: 8

[函数] 【函数】curve:rectanglep 测试一个多段线是否为矩形

[复制链接]
发表于 2023-1-11 23:42 | 显示全部楼层 |阅读模式
本帖最后由 vitalgg 于 2023-1-12 14:59 编辑

【函数】curve:rectanglep 测试一个多段线是否为矩形


本函数源码:
https://gitee.com/atlisp/atlisp- ... urve/rectanglep.lsp

@lisp函数库
https://gitee.com/atlisp/atlisp-lib


函数库问题讨论,建议及意见交流区
https://gitee.com/atlisp/atlisp-lib/issues

@lisp开源项目
https://gitee.com/atlisp

  1. (defun curve:rectanglep (ent)
  2.   "测试一个多段线是否为矩形"
  3.   "T or nil"
  4.   (and
  5.    (= 'ename (type ent))
  6.    (wcmatch (entity:getdxf ent 0) "*POLYLINE") ;; 是多段线
  7.    (or ;; 4点且闭合 或 5点首尾点相同
  8.     (and (= (entity:getdxf ent 90) 4)
  9.    (= (entity:getdxf ent 70) 1))
  10.     (and (= (entity:getdxf ent 90) 5)
  11.    (= (entity:getdxf ent 70) 0)))
  12.    (apply '= (entity:getdxf ent 42))
  13.    (progn
  14.      (setq pts (curve:get-points ent))
  15.      (setq ang
  16.      (abs
  17.       (- (angle (nth 0 pts)(nth 1 pts))
  18.          (angle (nth 1 pts)(nth 2 pts)))))
  19.      (if (> ang pi)(setq ang (- ang pi)))
  20.      ;; 邻边垂直且对角长度相等
  21.      (and
  22.       (equal ang (* pi 0.5) 1e-6)

  23.       (equal (distance (nth 0 pts)(nth 1 pts))
  24.              (distance (nth 2 pts)(nth 3 pts))
  25.              1e-6)
  26.       (equal (distance (nth 0 pts)(nth 2 pts))
  27.        (distance (nth 1 pts)(nth 3 pts))
  28.     1e-6)
  29.       (if (nth 4 pts) ;; 存在第5点时,第5点同第1点
  30.     (< (distance (nth 0 pts)(nth 4 pts)) 1e-6)
  31.   t)
  32.       ))))

公众号:CAD应用云 中寻求帮助



CAD命令行中寻求帮助



CAD命令行中聊天寻求帮助






VScode 中寻求帮助








本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2023-1-12 09:53 | 显示全部楼层
本帖最后由 77077 于 2023-1-12 09:55 编辑


我有强迫症,我认为顶点数不为4的不能算矩形,不闭合的不能算矩形,带凸度的不能算矩形。

不知道对不对?
  1. (and
  2.         (setq curve(car(entsel "\n选择对象:")))
  3.         (= (vlax-curve-getEndParam curve) 4)
  4.         (vlax-curve-isClosed curve)
  5.         (setq d1 (vlax-curve-getDistAtParam curve 1))
  6.         (setq d2 (- (vlax-curve-getDistAtParam curve 2) d1))
  7.         (equal (vlax-curve-getArea curve) (* d1 d2) 1e-6)
  8. )
 楼主| 发表于 2023-1-12 14:53 | 显示全部楼层
77077 发表于 2023-1-12 09:53
我有强迫症,我认为顶点数不为4的不能算矩形,不闭合的不能算矩形,带凸度的不能算矩形。

不知道对不 ...


你说的对。




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2023-1-12 22:34 | 显示全部楼层
万一超过一个点有重合呢?
 楼主| 发表于 2023-1-13 02:34 | 显示全部楼层
kozmosovia 发表于 2023-1-12 22:34
万一超过一个点有重合呢?

先用 killover 处理一下

点评

还清理毛线呀。连基本的几何常识都不懂,谁画的图,把他拉来操一顿。  发表于 2023-1-13 11:58
发表于 2023-2-10 23:15 | 显示全部楼层
"contributes.grammars.language" 中包含未知语言。提供的值: autolisp-injection
命令“autolisp.loadActiveFile”在 `commands` 部分重复出现。

看看用@lisp函数库经常用不了,出现这个是怎么回事。
 楼主| 发表于 2023-2-11 09:20 | 显示全部楼层
本帖最后由 vitalgg 于 2023-2-11 09:23 编辑
哆啦A梦_oELxg 发表于 2023-2-10 23:15
"contributes.grammars.language" 中包含未知语言。提供的值: autolisp-injection
命令“autolisp.loadAct ...

应该是需要安装 markdown 相关扩展才行。
我把这段删了吧。请更新扩展版本到 1.4.18 试一下。

{
                                "language": "autolisp-injection",
                                "scopeName": "markdown.autolisp.codeblock",
                                "path": "./syntaxes/cl_codeblock.tmLanguage.json",
                                "injectTo": [
                                        "text.html.markdown"
                                ],
                                "embeddedLanguages": {
                                        "meta.embedded.block.autolisp": "autolisp"
                                }
                        }

发表于 2023-2-11 11:50 | 显示全部楼层
vitalgg 发表于 2023-2-11 09:20
应该是需要安装 markdown 相关扩展才行。
我把这段删了吧。请更新扩展版本到 1.4.18 试一下。

给力,安装markdown all in one扩展后,没问题了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-12 04:48 , Processed in 0.158578 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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