如何在获取选择集中多个块的插入点?
Sub PrintModelSpace() <BR> On Error Resume Next<BR> Dim insert_x As Double, insert_y As Double, xscl As Single<BR> Dim FilterType(0) As Integer<BR> Dim FilterData(0) As Variant<BR> Dim ii As Integer<BR> Dim attributeobj As AcadAttribute<BR> Dim obj As AcadBlockReference<BR> Dim var As Variant<BR> FilterType(0) = 2<BR> FilterData(0) = "tk"<BR> Dim sel As AcadSelectionSet '选择集<BR> Set sel = ThisDrawing.SelectionSets.Add("ssel")<BR> If Err Then<BR> Err.Clear<BR> ThisDrawing.SelectionSets("ssel").Delete<BR> Set sel = ThisDrawing.SelectionSets.Add("ssel")<BR> End If<BR> sel.Select acSelectionSetAll, , , FilterType, FilterData<BR> For ii = 1 To sel.Count<BR> Set obj = sel.Item(ii)<BR> insert_x = obj.InsertionPoint(0)<BR> insert_y = obj.InsertionPoint(1)<BR> xscl = obj.XScaleFactor<BR> Next ii<BR>End Sub以上程序是想在图中选择块名为tk的块,然后分别获得每个块的插入点和X比例,但是只能得到第一个块名为tk的插入点和X比例,为什么?有没有人能帮帮我??<BR> 你应该先用选择集选择图形上所有的图块,然后再判断块名是不是“tk”。 能不能给些代码?还有,有很可能图块很多,这样一来会使会速度很慢,而且效率也不是很高. Sub tt3()<BR>On Error Resume Next<BR>Dim ss As AcadSelectionSet<BR>Dim ft(1) As Integer, fd(1)<BR>Dim obj As AcadBlockReference<BR>ft(0) = 0: fd(0) = "Insert"<BR>ft(1) = 2: fd(1) = "tk"<BR>ThisDrawing.SelectionSets("Test").Delete<BR>Set ss = ThisDrawing.SelectionSets.Add("Test")<BR>ss.Select acSelectionSetAll, , , ft, fd<BR>For Each obj In ss<BR> insert_x = obj.InsertionPoint(0)<BR> insert_y = obj.InsertionPoint(1)<BR> xscl = obj.XScaleFactor<BR>Next obj<BR>End Sub
页:
[1]