明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1504|回复: 3

如何在获取选择集中多个块的插入点?

[复制链接]
发表于 2005-3-5 14:49:00 | 显示全部楼层 |阅读模式
Sub PrintModelSpace()
On Error Resume Next
Dim insert_x As Double, insert_y As Double, xscl As Single
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
Dim ii As Integer
Dim attributeobj As AcadAttribute
Dim obj As AcadBlockReference
Dim var As Variant
FilterType(0) = 2
FilterData(0) = "tk"
Dim sel As AcadSelectionSet '选择集
Set sel = ThisDrawing.SelectionSets.Add("ssel")
If Err Then
Err.Clear
ThisDrawing.SelectionSets("ssel").Delete
Set sel = ThisDrawing.SelectionSets.Add("ssel")
End If
sel.Select acSelectionSetAll, , , FilterType, FilterData
For ii = 1 To sel.Count
Set obj = sel.Item(ii)
insert_x = obj.InsertionPoint(0)
insert_y = obj.InsertionPoint(1)
xscl = obj.XScaleFactor
Next ii
End Sub 以上程序是想在图中选择块名为tk的块,然后分别获得每个块的插入点和X比例,但是只能得到第一个块名为tk的插入点和X比例,为什么?有没有人能帮帮我??
发表于 2005-3-5 17:03:00 | 显示全部楼层
你应该先用选择集选择图形上所有的图块,然后再判断块名是不是“tk”。
 楼主| 发表于 2005-3-5 18:08:00 | 显示全部楼层
能不能给些代码?还有,有很可能图块很多,这样一来会使会速度很慢,而且效率也不是很高.
发表于 2005-3-5 18:17:00 | 显示全部楼层
Sub tt3()
On Error Resume Next
Dim ss As AcadSelectionSet
Dim ft(1) As Integer, fd(1)
Dim obj As AcadBlockReference
ft(0) = 0: fd(0) = "Insert"
ft(1) = 2: fd(1) = "tk"
ThisDrawing.SelectionSets("Test").Delete
Set ss = ThisDrawing.SelectionSets.Add("Test")
ss.Select acSelectionSetAll, , , ft, fd
For Each obj In ss
insert_x = obj.InsertionPoint(0)
insert_y = obj.InsertionPoint(1)
xscl = obj.XScaleFactor
Next obj
End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-27 18:49 , Processed in 0.177729 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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