wz0406 发表于 2006-9-22 12:17:00

急!给CAD实体增加扩展数据

<P>各位老大:</P>
<P>我的编程环境如下:CAD2004和VB.NET2003</P>
<P>程序如下(请导入CAD的引用):</P>
<P>&nbsp;&nbsp;&nbsp; Public acadApp As AcadApplication<BR>&nbsp;&nbsp;&nbsp; Public acadDoc As AcadDocument</P>
<P>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click</P>
<P>&nbsp;&nbsp; '----------------------------------连接至 AutoCAD 应用程序<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cursor.Current = Cursors.WaitCursor<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acadApp = GetObject(, "AutoCAD.Application.16")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch ex As Exception<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acadApp = CreateObject("AutoCAD.Application.16")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acadDoc = acadApp.ActiveDocument<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Application.DoEvents()</P>
<P>&nbsp;Dim lineObj As AcadLine<BR>&nbsp;&nbsp;&nbsp; Dim startPt(2) As Double, endPt(2) As Double<BR>&nbsp;&nbsp;&nbsp; startPt(0) = 1#: startPt(1) = 1#: startPt(2) = 0#<BR>&nbsp;&nbsp;&nbsp; endPt(0) = 5#: endPt(1) = 5#: endPt(2) = 0#<BR>&nbsp;&nbsp;&nbsp; Set lineObj = acadDoc .ModelSpace.AddLine(startPt, endPt)<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; Dim DataType(1) As Integer<BR>&nbsp;&nbsp;&nbsp; Dim Data(1) As Variant<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; DataType(0) = 1001: Data(0) = "Test_Application"<BR>&nbsp;&nbsp;&nbsp; DataType(1) = 1000: Data(1) = "This is a test for xdata"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lineObj.SetXData( DataType, Data)<BR>&nbsp;&nbsp;&nbsp; End Sub</P>
<P>出现:其他信息: 参数 type (位于 SetXData method 中) 无效的错误,</P>
<P>有用同样的方法在CAD VBA环境下测试,能运行!!</P>
<P>请各位绘予帮助!!谢谢</P>

陈永锋 发表于 2006-11-9 20:40:00

我建议你多看一下VBA开发中的例子

陈永锋 发表于 2006-11-9 20:44:00

在。net中obj.SetXData( DataType, Data)函数中的两个参数应为object类型<BR>

loofs 发表于 2012-1-28 12:15:43

datatype为short数组,data为object数组
页: [1]
查看完整版本: 急!给CAD实体增加扩展数据