明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[求助]怎样选择闭合线多线段外5m范围内的地物元素?

  [复制链接]
发表于 2010-6-10 23:22:00 | 显示全部楼层
不知道是否合你意,只是LISP的程序  Function.fas 文件为一些通用函数,部分来源于网络,把此文件放于CAD搜索路径加载test.lsp,运行命令test
  1. (defun c:test (/     MINZB  OBJ       OBJ_ALL
  2.         OBJ_CP     OBJ_DATA  OBJ_DEL      OBJ_MIN_MAX
  3.         OBJ_NAME     OBJ_OFFSET_NAME       OBJ_PLIST
  4.         OFFSET_DIST  PYPOINT
  5.        )
  6.   (if (findfile "Function.fas")
  7.     (progn
  8.       (load "Function.fas") ;_加载常用函数
  9.       (while (not (setq obj (entsel "\n选择闭合多线段:"))))
  10.       (setq obj_name (car obj))
  11.       (setq obj_data (entget obj_name))
  12.       (if (= (cdr (assoc 0 obj_data)) "LWPOLYLINE") ;_如果类型是 LWPOLYLINE
  13. (progn
  14.    (setq offset_dist 0.25) ;_偏移的距离,根据自己要求定义
  15.    (setq obj_plist (PL_plist obj_name)) ;_取得多段线的坐标表
  16.    (setq obj_min_max (GE_Extents obj_plist)) ;_求多边形的包围框最左下角点与最右上角点
  17.    (setq minzb (car obj_min_max)) ;_左下角点
  18.    (setq pypoint (polar minzb pi 0.1)) ;_求得向外的偏移点
  19.    (command "_offset" offset_dist obj_name pypoint "") ;_偏移对象
  20.    (setq obj_offset_name (entlast)) ;_取得偏移对象的图元名
  21.    (if (equal obj_name obj_offset_name) ;_如果没有产生偏移
  22.      (progn
  23.        (princ
  24.   "\n选择的对象不能偏移,是否在锁定的图层或者图元就是不能偏移"
  25.        )
  26.      )
  27.      (progn
  28.        (command "..zoom" (car obj_min_max) (last obj_min_max)) ;_缩放
  29.        (setq obj_plist (PL_plist obj_offset_name)) ;_取得多段线的坐标表
  30.        (setq obj_cp (ssget "cp" obj_plist)) ;_使用CP的窗口选择
  31.        (setq obj_all (ssget "x"
  32.        (list
  33.          (cons -4 "<not")
  34.          (cons -4 "<and")
  35.          (cons 0 "text")
  36.          (cons 8 "TK")
  37.          (cons -4 "and>")
  38.          (cons -4 "not>")
  39.        )
  40.        )
  41.        ) ;_所有选择集,排除TK层上的文字
  42.        (setq obj_del (yad-ssdiff obj_all obj_cp)) ;_删除的选择集 所有选择集与CP选择到的差集
  43.        (if (and obj_del (not (yad-comp-ss obj_del obj_cp))) ;_如果obj_del不为空 and obj_del不等于obj_cp
  44.   (command ".erase" obj_del "") ;_删除与选择对象不相交和在选择对象外的所有图元
  45.        )
  46.        (command ".erase" obj_offset_name "") ;_删除偏移的对象
  47.      )
  48.    )
  49. )
  50. (progn
  51.    (princ "\n选择的线非 LWPOLYLINE")
  52. )
  53.       )
  54.     )
  55.     (progn
  56.       (princ "\n不能加载常用函数文件 Function.fas")
  57.     )
  58.   )
  59.   (princ)
  60. )

本帖子中包含更多资源

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

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

本版积分规则

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

GMT+8, 2025-4-16 16:05 , Processed in 0.152820 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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