Reading extended data on all Groups in drawing using VBA
Hi, I have a drawing with two Group objects. I have assigned extended data to both of them trough obj.setXdata. When I use obj.getXdata it works as expected but I want to go trough all groups on my drawing and collect extended data. Therefore I defined Gp and Gps in example below and going trough all Groups in drawing this way. It returns 'Empty' array. I expected to see values I am assigning trough setXdata. I must be missing something fundamental. Please advise.
Best regards
Jiri
Sub test_xproperties()
Dim pt(0 To 2) As Double
Dim mark As String
Dim num As Integer
Dim i As Integer
mark = "test999"
num = 999
For i = 1 To 2
ThisDrawing.Utility.GetEntity obj, pt, "select entity...."
Dim TypArray(0 To 2) As Integer
Dim ValueArray(0 To 2) As Variant
TypArray(0) = 1001 'application name
ValueArray(0) = "Item"
TypArray(1) = 1000 'string
ValueArray(1) = mark
TypArray(2) = 1070 'integer
ValueArray(2) = num
obj.SetXData TypArray, ValueArray
mark = "test888"
num = 888
Next
'This works fine, displays xdata of last selected group object
Dim getTypA As Variant
Dim getValueA As Variant
obj.GetXData "Item", getTypA, getValueA
'This does not work
'I want to gotrough all groups in my drawing and test xdata
Dim Gp As AcadGroup
Dim Gps As AcadGroups
Set Gps = ThisDrawing.Groups
Dim k As Integer
k = 0
For Each Gp In Gps
Set Gp = ThisDrawing.Groups.Item(k)
Dim getTypB As Variant
Dim getValueB As Variant
Gp.GetXData "Item", getTypB, getValueB 'getValueB is
'empty, I expected it will show arrays with
'test888, 888 and test999, 999
k = k + 1
Next
End Sub
0
Comments
-
I think you should query the entity data on the entities within the group (not directly on the group). Remember a group is really a named SelectionSet object. Below steps through the entities within a group.
Dim Gp As AcadGroup
Dim Gps As AcadGroups
Set Gps = ThisDrawing.Groups
Dim k As Integer
For Each Gp In Gps
Dim getTypB As Variant
Dim getValueB As Variant
Dim thisEnt As AcadEntity
For k = 0 To Gp.Count - 1
Set thisEnt = Gp.Item(k)
thisEnt.GetXData "Item", getTypB, getValueB
Next
Next0 -
Many thanks,
it works!
Best regards
Jiri
0
This discussion has been closed.