Is it possible to preserve xdata . I have a number of procedures that write xdata to an object, Example the first one assigns xdata as the object is drawn, others perform additional calcs and set the results as xdata. the issue is when additional set xdata is written the old xdata is cleared.
Example first procedure sets values xdata(0) and xdata(1)
second procedure calculation sets xdata(2)
RESULT: xdata (0) and xdata(1) are set to 0
thanks mikeC
#2
MikeC,
What you need to do is to collect the xdata that might be already stored in the object into arrays, add new data into that arrays (you will need to redimension the arrays before in order to be able to add new data to them) and then set the xdata to the object using those arrays.
Here is an example extracted from the program's help (with a few changes):
Then, if you need to add several xdata values to an object just do the following:
Hope this helps!
Regards,
JCAMPOS
What you need to do is to collect the xdata that might be already stored in the object into arrays, add new data into that arrays (you will need to redimension the arrays before in order to be able to add new data to them) and then set the xdata to the object using those arrays.
Here is an example extracted from the program's help (with a few changes):
Code: Select all
Sub AppendXData(ByVal AppName As String, ByVal DataType As Variant, ByVal DataToAppend As Variant)
'Get the entity:
Dim anObj As Object
Dim pt As IntelliCAD.Point
ActiveDocument.Utility.GetEntity anObj, pt, "Select an entity: "
'Get its xdata:
Dim xdataType As Variant
Dim xdataValue As Variant
anObj.GetXData AppName, xdataType, xdataValue
If (vbEmpty = VarType(xdataType)) Then
Dim tmp(0 To 0) As Integer
xdataType = tmp
ReDim xdataValue(0 To 0)
'The first item in the XData should be a 1001
'Code giving the app's name:
xdataType(0) = 1001
xdataValue(0) = AppName
End If
'Redimension the XData arrays, preserving their contents:
ReDim Preserve xdataType(LBound(xdataType) _
To (UBound(xdataType) + 1))
ReDim Preserve xdataValue(LBound(xdataValue) _
To (UBound(xdataValue) + 1))
'Set some new data:
xdataType(UBound(xdataType)) = DataType
xdataValue(UBound(xdataValue)) = DataToAppend
'Store the data:
anObj.SetXData xdataType, xdataValue
Set anObj = Nothing
End Sub
Code: Select all
Call AppendXData("MIKEC", 1000, "First value!")
Call AppendXData("MIKEC", 1000, "Second value!")
Call AppendXData("MIKEC", 1000, "And so on...")
Regards,
JCAMPOS