[求助]集合类是否可以设置扩展数据
<p>对象都都可以设置扩展数据和获取其扩展数据</p><p>看见ACAD的帮助文档 集合类也可以设置扩展数据和获取扩展数据</p><p>代码如下:</p><p>Sub Example_GetXData()<br/> ' This example creates a line and attaches extended data to that line.<br/> <br/> ' Create the line<br/> Dim lineObj As AcadLine<br/> Dim layersobject As AcadLayers<br/> Dim startPt(0 To 2) As Double, endPt(0 To 2) As Double<br/> startPt(0) = 1#: startPt(1) = 1#: startPt(2) = 0#<br/> endPt(0) = 5#: endPt(1) = 5#: endPt(2) = 0#<br/> Set lineObj = ThisDrawing.ModelSpace.AddLine(startPt, endPt)<br/> ZoomAll</p><p> ' Initialize all the xdata values. Note that first data in the list should be<br/> ' application name and first datatype code should be 1001<br/> Dim DataType(0 To 9) As Integer<br/> Dim Data(0 To 9) As Variant<br/> Dim reals3(0 To 2) As Double<br/> Dim worldPos(0 To 2) As Double<br/> <br/> DataType(0) = 1001: Data(0) = "Test_Application"<br/> DataType(1) = 1000: Data(1) = "This is a test for xdata"</p><p> DataType(2) = 1003: Data(2) = "0" ' layer<br/> DataType(3) = 1040: Data(3) = 1.23479137438413E+40 ' real<br/> DataType(4) = 1041: Data(4) = 1237324938 ' distance<br/> DataType(5) = 1070: Data(5) = 32767 ' 16 bit Integer<br/> DataType(6) = 1071: Data(6) = 32767 ' 32 bit Integer<br/> DataType(7) = 1042: Data(7) = 10 ' scaleFactor</p><p> reals3(0) = -2.95: reals3(1) = 100: reals3(2) = -20<br/> DataType(8) = 1010: Data(8) = reals3 ' real</p><p> worldPos(0) = 4: worldPos(1) = 400.99999999: worldPos(2) = 2.798989<br/> DataType(9) = 1011: Data(9) = worldPos ' world space position</p><p> ' Attach the xdata to the line<br/> Set layersobject = ThisDrawing.Layers<br/> layersobject.SetXData DataType, Data</p><p> ' Return the xdata for the line<br/> Dim xdataOut As Variant<br/> Dim xtypeOut As Variant<br/> layersobject.GetXData "", xtypeOut, xdataOut<br/> <br/>End Sub<br/>运行程序报错,想问下SetXData GetXData 不支持集合类?</p> <p>这种情况用字典更好</p> <p> Set layersobject = ThisDrawing.Layers<br/> layersobject.SetXData DataType, Data</p>扩展数据只能赋给实体,不能赋给层吧!
页:
[1]