急!给CAD实体增加扩展数据
<P>各位老大:</P><P>我的编程环境如下:CAD2004和VB.NET2003</P>
<P>程序如下(请导入CAD的引用):</P>
<P> Public acadApp As AcadApplication<BR> 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> '----------------------------------连接至 AutoCAD 应用程序<BR> Try<BR> Cursor.Current = Cursors.WaitCursor<BR> acadApp = GetObject(, "AutoCAD.Application.16")<BR> Catch ex As Exception<BR> acadApp = CreateObject("AutoCAD.Application.16")<BR> End Try<BR> acadDoc = acadApp.ActiveDocument<BR> Application.DoEvents()</P>
<P> Dim lineObj As AcadLine<BR> Dim startPt(2) As Double, endPt(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 = acadDoc .ModelSpace.AddLine(startPt, endPt)<BR> <BR> Dim DataType(1) As Integer<BR> Dim Data(1) As Variant<BR> <BR> DataType(0) = 1001: Data(0) = "Test_Application"<BR> DataType(1) = 1000: Data(1) = "This is a test for xdata"<BR> lineObj.SetXData( DataType, Data)<BR> End Sub</P>
<P>出现:其他信息: 参数 type (位于 SetXData method 中) 无效的错误,</P>
<P>有用同样的方法在CAD VBA环境下测试,能运行!!</P>
<P>请各位绘予帮助!!谢谢</P> 我建议你多看一下VBA开发中的例子 在。net中obj.SetXData( DataType, Data)函数中的两个参数应为object类型<BR> datatype为short数组,data为object数组
页:
[1]