明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1761|回复: 4

[求助]blockref 与 getboundingbox 的问题

[复制链接]
发表于 2007-1-7 21:51:00 | 显示全部楼层 |阅读模式

代码如下:
Dim BlkRef As AcadBlockReference
Dim SelSet As AcadSelectionSet
Set SelSet = AcadDoc.SelectionSets.Add("SelSet1")
Dim aaa(0) As Integer   'Select 条件1:选择类型
Dim aaa1(0) As Variant  'select 条件2:选择图元
Dim maxPoint As Variant
Dim minPoint As Variant
aaa(0) = 0     '图元类型
aaa1(0) = "INSERT"    '图块
SelSet.Select acSelectionSetAll, , , aaa, aaa1       '选择所有图块
For Each BlkRef In SelSet
  Debug.Print BlkRef.Name
  BlkRef.GetBoundingBox minPoint, maxPoint
Next

这段程序用来得到所有块的BoundingBox的,但是,得到的minPoint和maxPoint 都是Empty。 怎么回事呢?

程序确确实实能够选择所有的块,而且名字也都是正常的,但是只要调用getboundingbox方法,要么为空,要么

就直接退出当前函数了,

请大侠们指教

发表于 2007-1-8 09:08:00 | 显示全部楼层
该程序正常的啊,不知你是否有SelSet.Delete语句
发表于 2007-1-8 10:21:00 | 显示全部楼层
在我这里可以得到的
  1. Dim BlkRef As AcadBlockReference
  2. Dim SelSet As AcadSelectionSet
  3. Set SelSet = ThisDrawing.SelectionSets.Add("SelSet1")
  4. Dim aaa(0) As Integer   'Select 条件1:选择类型
  5. Dim aaa1(0) As Variant  'select 条件2:选择图元
  6. Dim maxPoint As Variant
  7. Dim minPoint As Variant
  8. aaa(0) = 0     '图元类型
  9. aaa1(0) = "INSERT"    '图块
  10. SelSet.Select acSelectionSetAll, , , aaa, aaa1       '选择所有图块
  11. For Each BlkRef In SelSet
  12.   MsgBox BlkRef.Name
  13.   BlkRef.GetBoundingBox minPoint, maxPoint
  14. Next
  15. If Not SelSet Is Nothing Then SelSet.Delete
 楼主| 发表于 2007-1-8 16:52:00 | 显示全部楼层
我把我的图纸上传下,大侠们棒棒忙看下,谢谢

本帖子中包含更多资源

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

x
发表于 2007-1-8 17:09:00 | 显示全部楼层
对的啊
  1. Sub test()
  2. Dim BlkRef As AcadBlockReference
  3. Dim SelSet As AcadSelectionSet
  4. Set SelSet = ThisDrawing.SelectionSets.Add("SelSet0")
  5. Dim aaa(0) As Integer   'Select 条件1:选择类型
  6. Dim aaa1(0) As Variant  'select 条件2:选择图元
  7. Dim maxPoint As Variant
  8. Dim minPoint As Variant
  9. aaa(0) = 0     '图元类型
  10. aaa1(0) = "INSERT"    '图块
  11. SelSet.Select acSelectionSetAll, , , aaa, aaa1       '选择所有图块
  12. For Each BlkRef In SelSet
  13.    BlkRef.GetBoundingBox minPoint, maxPoint
  14.    MsgBox maxPoint(0)
  15. Next
  16. SelSet.Delete
  17. End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 20:25 , Processed in 0.174072 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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