weekendor 发表于 2005-11-5 15:30:00

VBA中如何使用扩展数据?

<P>  需要在VBA程序设计中,为程序在AUTOCAD模型空间中增加的图形元素添加上额外的数据作为记认或记录,听说VBA中可以通过“扩展数据”类型来实现这一功能,但我不是很懂, 想请问有没有高手能指点一下如何使用呢?? 谢谢!!</P>

wmz 发表于 2005-11-5 16:30:00

本站置顶的"对象模型"有实例

weekendor 发表于 2005-11-7 21:02:00

wmz发表于2005-11-5 16:30:00static/image/common/back.gif本站置顶的\"对象模型\"有实例


<P><BR>谢谢这位高手,置顶的“对象模型”的确不错、很多东西学!</P>
<P>但我在那里面还是找不到有关于扩展数据的实例,能再指点一下吗? 谢!</P>

wmz 发表于 2005-11-8 12:42:00

<PRE class=Code>Sub Example_SetXdata()
    ' This example creates a line and attaches extended data to that line.
   
    ' Create the line
    Dim lineObj As AcadLine
    Dim startPt(0 To 2) As Double, endPt(0 To 2) As Double
    startPt(0) = 1#: startPt(1) = 1#: startPt(2) = 0#
    endPt(0) = 5#: endPt(1) = 5#: endPt(2) = 0#
    Set lineObj = ThisDrawing.ModelSpace.AddLine(startPt, endPt)
    ZoomAll

    ' Initialize all the xdata values. Note that first data in the list should be
    ' application name and first datatype code should be 1001
    Dim DataType(0 To 9) As Integer
    Dim Data(0 To 9) As Variant
    Dim reals3(0 To 2) As Double
    Dim worldPos(0 To 2) As Double
   
    DataType(0) = 1001: Data(0) = "Test_Application"
    DataType(1) = 1000: Data(1) = "This is a test for xdata"

    DataType(2) = 1003: Data(2) = "0"                   ' layer
    DataType(3) = 1040: Data(3) = 1.23479137438413E+40' real
    DataType(4) = 1041: Data(4) = 1237324938            ' distance
    DataType(5) = 1070: Data(5) = 32767               ' 16 bit Integer
    DataType(6) = 1071: Data(6) = 32767               ' 32 bit Integer
    DataType(7) = 1042: Data(7) = 10                  ' scaleFactor

    reals3(0) = -2.95: reals3(1) = 100: reals3(2) = -20
    DataType(8) = 1010: Data(8) = reals3                ' real
   
    worldPos(0) = 4: worldPos(1) = 400.99999999: worldPos(2) = 2.798989
    DataType(9) = 1011: Data(9) = worldPos            ' world space position
   
    ' Attach the xdata to the line
    lineObj.SetXData DataType, Data
   
    ' Return the xdata for the line
    Dim xdataOut As Variant
    Dim xtypeOut As Variant
    lineObj.GetXData "", xtypeOut, xdataOut
   
End Sub</PRE>

雪山飞狐_lzh 发表于 2005-11-8 19:34:00

你从来没有看过Cad的VBA帮助么?哪就是帮助的汉化版:)

weekendor 发表于 2005-11-9 20:29:00

<P>感谢<A name=67007><FONT color=#000066><B>wmz</B></FONT></A>了!</P>
<P>惭愧了,对于CAD的VBA帮助我比较弱。 感谢赐教! :)</P>
页: [1]
查看完整版本: VBA中如何使用扩展数据?