乐筑天下

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

如何得到图元的最大外形?

[复制链接]

12

主题

228

帖子

8

银币

后起之秀

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

铜币
276
发表于 2008-7-20 17:02:00 | 显示全部楼层 |阅读模式

ujx251wet4d.jpg

ujx251wet4d.jpg


       请问各位大侠我选择左边所示的图元(可能为多段线,也可能为单个的简单图元),通过VBA如何得到如右图红线所示的所有图元的最大外形?
回复

使用道具 举报

120

主题

326

帖子

7

银币

中流砥柱

Rank: 25

铜币
806
发表于 2008-11-1 20:20:00 | 显示全部楼层

通过选择集,对选择集再进行GetBoundingBox
回复

使用道具 举报

14

主题

52

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
108
发表于 2008-7-20 22:27:00 | 显示全部楼层
1、遍历判断
2、做成块或者是组合成多段线用getbound来获得
回复

使用道具 举报

20

主题

105

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
185
发表于 2008-7-20 23:00:00 | 显示全部楼层
lz的意思非常难以实现。
getboundingbox 只是一个矩形区域的坐标点。
回复

使用道具 举报

32

主题

651

帖子

8

银币

中流砥柱

Rank: 25

铜币
779
发表于 2008-7-21 09:38:00 | 显示全部楼层


cpbiuhgeygc.JPG

cpbiuhgeygc.JPG


1,获取全部实体选择集,要求外围是封闭的 2,获取选择集的矩形绿色轮廓,使用getboundingbox函数可以实现 3,将绿色轮廓再向外偏移一定距离得到黄色轮廓 4,取一绿色黄色轮廓间的点,使用Boundary命令可以得到5两个紫色轮廓 5,干掉第5步中外面的轮廓,即可得到第6轮廓
回复

使用道具 举报

15

主题

70

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
130
发表于 2008-7-21 20:45:00 | 显示全部楼层
通过面积能判断吗?
回复

使用道具 举报

12

主题

228

帖子

8

银币

后起之秀

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

铜币
276
发表于 2008-7-22 19:05:00 | 显示全部楼层
谢谢楼上各位的回复,特别是sieben的详细解答!
回复

使用道具 举报

2

主题

7

帖子

2

银币

初来乍到

Rank: 1

铜币
15
发表于 2008-10-17 12:07:00 | 显示全部楼层
有代码吗?可以给我留个不·谢谢
回复

使用道具 举报

17

主题

96

帖子

9

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
163
发表于 2008-10-19 09:57:00 | 显示全部楼层
  1. ;;;包裹描边
  2. ; getArea subRoutine
  3. (defun getArea ( entName / )
  4.    (command "_.AREA" "O" entName)
  5.    (setq objArea (getvar "AREA"))
  6. ) ;defun
  7. (defun c:wq(/ oldEcho objsToWrap extMin extMax minX minY maxX maxY
  8.                    diagDist boxOffset boxLL boxLR boxUR boxUL
  9.                    boundPoint boxObj newObjs lastEntName entName
  10.                    newObjsLen maxArea counter thisArea wrapOption
  11.                )
  12.    (setq oldEcho (getvar "CMDECHO"))
  13.    (setvar "CMDECHO" 0)
  14.    (prompt "\nWrap Objects (w/Polyline(s)):")
  15.    ;|
  16.        Swap commenting with (setq) line below...
  17.        If you want ELLIPSE and SPLINE objects to be selectable
  18.    |;
  19.    ;(setq objsToWrap (ssget))
  20.    (setq objsToWrap
  21.        (ssget '(
  22.            (-4 . "")
  23.            (-4 . "NOT>"))
  24.        ) ;ssget
  25.    ) ;setq
  26.    
  27.    (if (/= objsToWrap nil)
  28.        (progn
  29.            (command "_.UNDO" "BEGIN")
  30.            (setq wrapOption "Single") ;default to single
  31.            (initget "Single Multiple")
  32.            (prompt "\nWrap Options:")
  33.            (prompt "\n   Single: Only the largest outer profile will be created.")
  34.            (prompt "\n   Multiple: Nested, or detatched profiles will also be created.")
  35.            (setq wrapOption (getkword "\nWrap option [Single/Multiple] : "))
  36.            (if (= wrapOption "Multiple")
  37.                (setq wrapOption "Multiple")
  38.                (setq wrapOption "Single")
  39.            ) ;if
  40.            
  41.            ; Create bounding box, larger than existing drawing...
  42.            (setq extMin (getvar "EXTMIN"))
  43.            (setq extMax (getvar "EXTMAX"))
  44.            (setq minX (car extMin))
  45.            (setq minY (cadr extMin))
  46.            (setq maxX (car extMax))
  47.            (setq maxY (cadr extMax))
  48.            
  49.            (setq diagDist (distance extMin extMax))
  50.            (setq boxOffset (* diagDist 0.1))
  51.            
  52.            (setq boxLL (list (- minX boxOffset) (- minY boxOffset) 0))
  53.            (setq boxLR (list (+ maxX boxOffset) (- minY boxOffset) 0))
  54.            (setq boxUR (list (+ maxX boxOffset) (+ maxY boxOffset) 0))
  55.            (setq boxUL (list (- minX boxOffset) (+ maxY boxOffset) 0))
  56.            (setq boundPoint (list (- minX (/ boxOffset 2)) (- minY (/ boxOffset 2)) 0))
  57.            (command "_.PLINE" boxLL boxLR boxUR boxUL "C")
  58.            (setq boxObj (entlast))
  59.            (command "_.-BOUNDARY" "A" "O" "P" "I" "Y" "B" "N" boxObj objsToWrap "" "" boundPoint "")
  60.            
  61.            ; Get a list of the entities created by the boundary command...
  62.            (setq lastEntName boxObj)
  63.            (while (setq entName (entnext lastEntName))
  64.                (setq newObjs (append newObjs (list entName)))
  65.                (setq lastEntName entName)
  66.            ) ;while
  67.            ;Get the greatest object area, of the new objects (the duplicate polyline, of our temp box)
  68.            (setq newObjsLen (length newObjs))
  69.            (setq maxArea 0)
  70.            
  71.            (setq counter 0)
  72.            (while (= thisArea maxArea)
  73.                    (setq maxArea thisArea)
  74.                ) ;if
  75.                (setq counter (1+ counter))
  76.            ) ;while
  77.            
  78.            ; Delete the Object, that matches the maxArea (the duplicate polyline)
  79.            (setq counter 0)
  80.            (while (= thisArea maxArea)
  81.                            (setq maxArea thisArea)
  82.                        ) ;if
  83.                        (setq counter (1+ counter))
  84.                    ) ;while
  85.                    ; Delete the Object, UNLESS it matches the maxArea (the one we want to keep!)...
  86.                    (setq counter 0)
  87.                    (while (< counter newObjsLen)
  88.                        (setq thisArea (getArea (nth counter newObjs)))
  89.                        (if (/= thisArea maxArea)
  90.                            (progn
  91.                                (entdel (nth counter newObjs))
  92.                            ) ;progn
  93.                        ) ;if
  94.                        (setq counter (1+ counter))
  95.                    ) ;while
  96.                ) ;progn
  97.            ) ;if
  98.            
  99.            ;Erase the original box...
  100.            (command "_.ERASE" boxObj "")
  101.            (command "_.UNDO" "END")
  102.        ) ;progn
  103.    ) ;if
  104.    (setvar "CMDECHO" oldEcho)
  105.    (princ)
  106. ) ;defun
  107. ;(prompt "\nWrapObjects.lsp...Loaded!")
  108. (prompt "\nPCB模具设计:a 外形-0.075单边 内槽+0.075单 1.6T IF 1.0T 0.05单边 线路+绿油+正字符+阻焊+反字符+碳油 先想清楚再下手做,磨刀不误砍柴工! ")
  109. (princ)
回复

使用道具 举报

2

主题

7

帖子

2

银币

初来乍到

Rank: 1

铜币
15
发表于 2008-10-20 11:46:00 | 显示全部楼层
谢谢,真是个好东西,貌似不怎么看的懂,慢慢研究中···
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-3 17:35 , Processed in 1.922736 second(s), 75 queries .

© 2020-2025 乐筑天下

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