明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 131|回复: 0

[函数] block:get-clip-boundary 取剪裁块参照的边界线点WCS坐标

[复制链接]
发表于 2024-4-12 20:13 | 显示全部楼层 |阅读模式
本帖最后由 vitalgg 于 2024-4-12 20:18 编辑



  1. (defun block:get-clip-boundary (blkref / ent-sf boundary-in-blk mt ms mr)
  2.   "取剪裁块参照的边界线点WCS坐标"
  3.   "list"
  4.   "(block:get-clip-boundary (car(ensel)))"
  5.   ;; ent-sf 为剪裁边界线图元
  6.   (if (setq ent-sf (entity:getdxf (entity:getdxf (entity:getdxf blkref 360) 360)360))
  7.       (progn
  8.   (setq matrixs (list:split (entity:getdxf ent-sf 40)  12)) ;; 取WCS到OCS(块内)坐标变换矩阵
  9.   ;; 取边界顶点坐标
  10.   (setq pts (entity:getdxf ent-sf 10))
  11.   ;; 处理矩形两点变四点
  12.   (if (= 2 (length pts))
  13.       (setq pts  (apply 'point:rec-2pt->4pt pts)))
  14.   ;; 进行 WCS到OCS(块内)坐标变换,得到边界顶点在块内的坐标。
  15.   (setq boundary-in-blk
  16.         (mapcar'(lambda(x)(matrix:mxp (list:split (car matrixs) 4) x)) pts))
  17.   ;; 构造块参照的平移变换矩阵
  18.   (setq mt (apply 'matrix:translation (entity:getdxf blkref 10)))
  19.   ;; 构造块参照的缩放变换矩阵
  20.   (setq ms (matrix:scale (entity:getdxf  blkref 41)
  21.              (entity:getdxf  blkref 42)
  22.              (entity:getdxf  blkref 43)))
  23.   ;; 构造块参照的旋转变换矩阵
  24.   (setq mr (matrix:rotation-z (- (*  2 pi)(entity:getdxf blkref 50))))
  25.   ;; OCS到块参照的WCS坐标变换
  26.   (mapcar '(lambda(x)
  27.       (matrix:transform
  28.        mt ms mr x))
  29.     boundary-in-blk)
  30.   )))




代码中相关函数见 @lisp函数库。代码仅供相互探讨学习实现原理。不能直接复制使用。

可以使用以下代码直接从网络加载 @lisp 函数库到CAD中,然后直接调用该函数。

  1. (progn(vl-load-com)(setq s strcat h"http"o(vlax-create-object (s"win"h".win"h"request.5.1"))v vlax-invoke e eval r read)(v o'open "get" (s h"://""atlisp.""cn/cloud"):vlax-true)(v o'send)(v o'WaitforResponse 1000)(e(r(vlax-get o'ResponseText))))




更多函数功能说明请至:  https://atlisp.cn/functionlib.html


也可以在 VScode 中安装 @lisp扩展,直接查看和使用 @lisp函数。 https://marketplace.visualstudio ... talGG.atlisp-funlib




本帖子中包含更多资源

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

x
"觉得好,就打赏"
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-2 07:01 , Processed in 5.240055 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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