version 6.0
DR ATTRIBUTE TO ARRAY (area; scope; attribute; array)
| Parameter | Type | Description | |
| area | Longint | 4D Draw area | |
| scope | Longint | -1=All | |
| 0=Selected | |||
| >0=Group ID | |||
| attribute | Longint | Attribute code | |
| array | Array | Array to fill |
Description
The command DR ATTRIBUTE TO ARRAY returns into array the value of attribute for each object in area described by scope.
If scope equals -1, the command returns attribute for each object in the document that is not in a group.
If scope equals 0, the command returns attribute for each selected object that is not in a group. Groups appear as a single object.
If scope is greater than 0, it must be the ID for a group; the command returns attribute for all objects inside the group. This syntax lets you get information about objects in a group without ungrouping. Nested groups can be traversed by using subsequent calls to DR ATTRIBUTE TO ARRAY. See the example for this command.
If attribute is not applicable for a specified object, DR ATTRIBUTE TO ARRAY returns -32000 or "*****" depending on the type of the array.
For example, if you fill an array with attribute 24 (corner rounding) and one of the objects is a line, the element that corresponds to the line will contain 32000. Likewise, if the object is a group and attribute is not the same for all objects inside of the group, DR ATTRIBUTE TO ARRAY returns 32000 or "*****".
The values returned by DR ATTRIBUTE TO ARRAY are based on the attribute code used. To determine the meaning of the corresponding element, see the command affecting that attribute. For example, to determine how to interpret a fill pattern, see DR SET FILL ATTRIBUTES.
DR ATTRIBUTE TO ARRAY returns information on only one "level" of objects. For example, if scope is 0, and several of the selected objects are groups, each group is included in the resulting array as one element. You can then "look into" each group by passing its ID as the scope.
Coordinate and size attributes are returned in base units. Use the DR ARRAY BASE TO SCALE command to convert an array of base units to scale units.
See Appendix A, Attribute Codes for a complete list of attribute codes and corresponding array types.
Example
The following example shows how to fill an array of object ID's and an array of object types for all objects in the document, regardless of whether the objects are in groups.
C_LONGINT ($i;$j)
`Used as loop counters
ARRAY LONGINT (aID;0)
`Will store the complete ID list
ARRAY LONGINT (aType;0)
`Will store the complete Type list
ARRAY LONGINT (aGrpID;0)
`Get the ID's inside of a group
ARRAY LONGINT (aGrpType;0)
`Used to get Types inside of a group
$i := 0
`Initialize loop counter
DR ATTRIBUTE TO ARRAY (Area;-1;0;aID)
`Fill array with ID's of objects not in groups
DR ATTRIBUTE TO ARRAY(Area;-1;1;aType)
`Fill array with types of objects not in groups
Repeat
`Repeat until all groups have been "looked into"
$i := $i + 1
`Increment counter. Tells which object to work on.
If(aType{$i} = 10)
`If the object is a group
DR ATTRIBUTE TO ARRAY (Area;aID{$i};0;aGrpID)
`Fill array with ID's of objects in group
DR ATTRIBUTE TO ARRAY (Area;aID{$i};1;aGrpType)
`Fill array with Types of objects in group
INSERT ELEMENT (aID;$i + 1;Size of array (aGrpID))
`Insert into ID array, elements to hold this group
INSERT ELEMENT(aType;$i + 1;Size of array (aGrpType))
`Insert into Type array, elements to hold this group
For($j;1;Size of array (aGrpID))
`Loop through the group array
aID{$i + $j} := aGrpID{$}j
`copy ID in group array into main array
aType{$i + $j} := aGrpType{$j}
`same for types
End for
End if
Until ($i = Size of array (aID))
`Continue until objects are explored
See Also
DR ARRAY TO ATTRIBUTE, DR Get ID.