[求助]选择集的问题?
Public elem as object<br>Public subelem as object<br>
For Each elem in ThisDrawing.blocks<br>
label1.caption = elem.name<br>
next<br>
在上面的程序中,我可以得到全部块名,但在<br>
label2.caption.caption=ThisDrawing.SelectionSets.count中却显示块为零,这是为什么呢?<br>
另外,如果我已知块名为“XXX”,要得到其中的属性,用一下程序行吗?<br>
Dim blockRefObj As AcadBlockReference<br>
Dim varAttributes As Variant<br>
Dim con(26) as string
'
块中总数已知<br>
Dim don(26) as string<br>
Dim I as integer<br>
varAttributes = blockRefObj.GetAttributes<br>
Set blockRefObj = ThisDrawing.SelectionSets.Item("XXX")<br>
For I = LBound(varAttributes) To UBound(varAttributes)<br>
con(26) = varAttributes(I).TagString<br>
don(26) = varAttributes(I).textString<br>
next<br>
1.块为什么写成选择集,所以显示为零并不奇怪。<BR>2.你选择集的概念还不情况,需要多从这方面下功夫。 mlyd发表于2005-5-31 18:49:00static/image/common/back.gif回复:(mlyd)选择集的问题? Public elem as objectPublic subelem as objectFor Each elem in ThisDrawing.blocks label1.caption = elem.namenext在上面...
Set blockRefObj = ThisDrawing.SelectionSets.Item("XXX")//很怀疑你到底写了这个程序没有?ThisDrawing.SelectionSets.Item得到的是SelectionSet对象,而不是 AcadBlockReference对象.<BR> 如果我已知块名,该用什么方法得到块的属性呢?<br>
<br> 临时插入一个块,得到属性然后删掉。 Private Sub CommandButton6_Click()<BR> ' Begin the selection<BR> <BR> Dim basePnt As Variant<BR> Dim objatts As Variant<BR> Dim i As Integer<BR> On Error Resume Next<BR> <BR> '隐藏对话框<BR> Me.Hide<BR> '以点选方式获取图元<BR> ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an object"<BR> <BR> If returnObj.ObjectName = "AcDbBlockReference" Then<BR> 'returnObj.color = acRed<BR> 'returnObj.Update<BR> 'returnObj.color = acByLayer<BR> 'returnObj.Update<BR> <BR> ComboBox5.Clear<BR> ComboBox6.Clear<BR> ComboBox7.Clear<BR> ComboBox5.AddItem returnObj.Name<BR> ComboBox5.ListIndex = 0<BR> objatts = returnObj.GetAttributes<BR> For i = LBound(objatts) To UBound(objatts)<BR> ComboBox6.AddItem objatts(i).TagString<BR> 'ComboBox5.AddItem objatts(i).PromptString<BR> ComboBox7.AddItem objatts(i).TextString<BR> Next i<BR> Else<BR> x = MsgBox("你选择的不是图块,请从新选择", vbOKOnly, "提示")<BR> <BR> End If<BR> <BR> Me.Show<BR>End Sub 谢谢!
程序已经试过了,可以得到块属性!
但如果已知块名,是否能不用选择得到属性呢? mlyd发表于2005-6-10 10:13:00static/image/common/back.gif谢谢!
程序已经试过了,可以得到块属性!
但如果已知块名,是否能不用选择得到属性呢?
<BR>不能.
页:
[1]