乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: sanju2323

[编程交流] 修剪对象外部的矩形

[复制链接]

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 20:29:32 | 显示全部楼层
如果你先跑得过火,那么Extrim就可以了。但它只会修剪与矩形相交的线。它不会删除外部的所有内容。
回复

使用道具 举报

7

主题

80

帖子

73

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 20:31:48 | 显示全部楼层
 
当然会,但他需要将系统变量peditacept编辑为0,然后运行overkill。
现在给他写一些noob代码。
 
编辑:
 
不需要代码,只要。
1.将Peditacept值更改为0
2.user Overkill命令,选择all(在我的例子中,只是为了清理整个图形)
3.正确放置矩形,因为图形中似乎有两个矩形。也许加入他们吧。
4、使用EXTRIM命令。
5、一些清理
6、完成。
回复

使用道具 举报

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 20:37:47 | 显示全部楼层
 
我没有得到系统变量Peditaccept,Overkill在现有多段线上运行得很好。
 
但不要让我在你友善的Lisp程序时阻止你。
回复

使用道具 举报

17

主题

1274

帖子

25

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
260
发表于 2022-7-5 20:40:30 | 显示全部楼层
我使用SSX选择“SURVEY NO BOUNDARY”层上的所有对象。只要选中“优化多段线内的线段”,Overkill将修复现有多段线。正如埃尔登所说:“如果你先运行Overkill,那么Extrim就可以了。但它只会修剪穿过矩形的线。”这是修剪而不是擦除的常规。我使用擦除外部边界来修剪和擦除外部:
  1. ;| Function to trim objects inside selected boundaries (allows for multiple boundaries)
  2.    Boundaries can be "Circle, Ellipse, LWPolyline and Polyline" Entities
  3.    Written By: Peter Jamtgaard Copyright 2015 All Rights Reserved
  4.    ^C^C^P(or C:BoundaryTrim (load "BoundaryTrim.lsp"));BoundaryTrim
  5.    EraseOutsideBoundary added by Tom Beauford
  6.    ^C^C^P(or C:EraseOutsideBoundary (load "BoundaryTrim.lsp"));EraseOutsideBoundary
  7. ==============================================================================|;
  8. ;(defun C:BT ()(c:BoundaryTrim))
  9. (defun C:BoundaryTrim (/ acDoc intCount ssBoundaries)
  10.    (if (setq ssBoundaries    (ssget (list (cons 0 "Circle,Ellipse,LWPolyline,Polyline"))))
  11.      (progn
  12.   (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))))
  13.   (repeat (setq intCount (sslength ssBoundaries))
  14.    (setq intCount     (1- intCount))
  15.    (BoundaryTrim        (ssname ssBoundaries intCount))
  16.    (BoundaryWindowErase (ssname ssBoundaries intCount)); <-Erase objects inside boundary optional
  17.   )
  18.      )
  19.    )
  20. (if        acDoc (vla-endundomark acDoc))
  21. )
  22. ; Command line function to select objects that are windowed by a selected circle.
  23. (defun C:BoundarySelect (/ lstPoints objBoundary ssBoundary)
  24. (if (and
  25. (setq ssBoundary  (ssget ":E:S" (list (cons 0 "Circle,Ellipse,LWPolyline,Polyline"))))
  26. (setq objBoundary (vlax-ename->vla-object (ssname ssBoundary 0)))
  27. (setq lstPoints   (SegmentPoints objBoundary 360))
  28.       )
  29.    (and
  30.     (setq ssSelections (ssget "_WP" lstPoints))
  31.    )
  32. )
  33. )
  34. ; Function to trim linework inside a boundary entity
  35. (defun BoundaryTrim (entBoundary1 / lstPoints entBoundary1 entBoundary2 lstCenter
  36.                     lstPoints1 lstPoints2 objBoundary1 objBoundary2 ssBoundary *Error*)
  37. (defun *Error* ()
  38.    (setvar "cmdecho" intCMDEcho)
  39. )
  40. (setq intCMDEcho (getvar "cmdecho"))
  41. (setvar "cmdecho" 0)
  42. (if (and
  43. (setq objBoundary1  (vlax-ename->vla-object entBoundary1))
  44. (setq lstPoints1    (SegmentPoints objBoundary1 360))
  45. (setq lstCenter     (mapcar '(lambda (X)(/ (apply '+ X) (length lstPoints1)))(transposematrix lstPoints1)))
  46. (vl-cmdf "offset"   (/ (distance (car lstPoints1) lstCenter) 36.0) entBoundary1 lstCenter "")
  47. (setq entBoundary2  (entlast))
  48. (setq objBoundary2  (vlax-ename->vla-object entBoundary2))
  49. (setq lstPoints2   (SegmentPoints objBoundary2 360))
  50.       )
  51.    (progn
  52.     (vl-cmdf "trim" entBoundary1 "" "f")
  53.     (foreach lstPoint lstPoints2 (vl-cmdf lstPoint))
  54.     (vl-cmdf "" "")
  55.     (entdel entBoundary2)
  56.     (vl-cmdf "redraw")
  57.     (setvar "cmdecho" intCMDEcho)
  58.    )
  59. )
  60. )
  61. ; Function to trim linework outside a boundary entity
  62. (defun TrimOutsideBoundary (entBoundary1 / lstPoints entBoundary1 entBoundary2 lstCenter
  63.                     maxpt lstPoints1 lstPoints2 objBoundary1 objBoundary2 ssBoundary *Error*)
  64. (defun *Error* ()
  65.    (setvar "cmdecho" intCMDEcho)
  66. )
  67. (setq intCMDEcho (getvar "cmdecho"))
  68. (setvar "cmdecho" 0)
  69. (if (and
  70. (setq objBoundary1  (vlax-ename->vla-object entBoundary1))
  71. (setq lstPoints1    (SegmentPoints objBoundary1 360))
  72. (setq lstCenter     (mapcar '(lambda (X)(/ (apply '+ X) (length lstPoints1)))(transposematrix lstPoints1)))
  73. (setq maxpt (list (1+ (car (getvar 'extmax)))(1+ (cadr (getvar 'extmax)))(1+ (caddr (getvar 'extmax)))))
  74. (vl-cmdf "offset"   (/ (distance (car lstPoints1) lstCenter) 200.0) entBoundary1 maxpt "")
  75. (setq entBoundary2  (entlast))
  76. (setq objBoundary2  (vlax-ename->vla-object entBoundary2))
  77. (setq lstPoints2   (SegmentPoints objBoundary2 360))
  78.       )
  79.    (progn
  80.     (vl-cmdf "trim" entBoundary1 "" "f")
  81.     (foreach lstPoint lstPoints2 (vl-cmdf lstPoint))
  82.     (vl-cmdf "" "")
  83.     (entdel entBoundary2)
  84.     (vl-cmdf "redraw")
  85.     (setvar "cmdecho" intCMDEcho)
  86.    )
  87. )
  88. )
  89. ; Function to erase linework inside a boundary entity
  90. (defun BoundaryWindowErase (entBoundary / lstPoints objBoundary ssSelections)
  91. (if (and
  92. (setq objBoundary  (vlax-ename->vla-object entBoundary))
  93. (setq lstPoints    (SegmentPoints objBoundary 360))
  94. (setq ssSelections (ssget "_WP" lstPoints))
  95.       )
  96.    (and
  97.     (setq ssSelections (ssget "_WP" lstPoints))
  98.     (vl-cmdf "erase" ssSelections "")
  99.    )
  100. )
  101. )
  102. ; Function to determine the points along a curve dividing it intSegments number of times
  103. (defun SegmentPoints (objCurve intSegments /  sngSegment intCount lstPoint lstPoints sngLength sngSegment)
  104. (if (and
  105. (setq sngLength   (vlax-curve-getdistatparam objCurve (vlax-curve-getendparam objCurve)))
  106. (setq sngSegment  (/ sngLength intSegments))
  107. (setq intCount    0)
  108.       )
  109.    (progn
  110.     (repeat (1+ intSegments)
  111.      (setq lstPoint   (vlax-curve-getpointatdist objCurve (* intCount sngSegment)))
  112.      (setq lstPoints  (cons lstPoint lstPoints))
  113.      (setq intCount   (1+ intCount))
  114.     )
  115.     lstPoints
  116.    )
  117. )
  118. )
  119. ; Function to Transpose a matrix
  120. (defun TransposeMatrix (lstMatrix)
  121. (if (car lstMatrix)
  122.    (cons (mapcar 'car lstMatrix)
  123.   (TransposeMatrix (mapcar 'cdr lstMatrix))
  124.   )
  125. )
  126. )
  127. ; Function to erase linework outside a boundary entity
  128. (defun C:EraseOutsideBoundary ( / ss1 n ssBoundary objBoundary lstPoints ssSelections entSelection)
  129. (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))))
  130. (setq ss1 (ssget "_X" '((67 . 0)))  n   -1)
  131. (if (and
  132. (setq ssBoundary  (ssget ":E:S" (list (cons 0 "Circle,Ellipse,LWPolyline,Polyline"))))
  133. (setq entBoundary  (ssname ssBoundary 0))
  134. (ssdel entBoundary ss1)
  135. (TrimOutsideBoundary entBoundary)
  136. (setq objBoundary (vlax-ename->vla-object entBoundary))
  137. (setq lstPoints   (SegmentPoints objBoundary 360))
  138.       )
  139.    (and
  140.     (setq ssSelections (ssget "_CP" lstPoints))
  141.     (repeat (sslength ssSelections)
  142.       (setq entSelection (ssname ssSelections (setq n (1+ n))))
  143.       (if(ssmemb entSelection ssSelections)(ssdel entSelection ss1))
  144.     )
  145.     (command "erase" ss1 "")
  146.    )
  147. )
  148. (if        acDoc (vla-endundomark acDoc))
  149. )
回复

使用道具 举报

VVA

1

主题

308

帖子

308

银币

初来乍到

Rank: 1

铜币
8
发表于 2022-7-5 20:44:39 | 显示全部楼层
CookieCutter2-ET extrim带来更多乐趣
外部轮廓删除
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-12 01:10 , Processed in 0.770980 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表