xwjljh 发表于 2009-5-5 17:33:00

<p>下面是我的代码,望大侠帮帮我呀,谢谢了</p><p>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;AddEntXData()<br/>&nbsp; &nbsp; End Sub<br/><br/>&nbsp; &nbsp; Public Sub AddEntXData()<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Dim ent As Autodesk.AutoCAD.Interop.Common.AcadEntity<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Dim pickPoint As Object<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;' ThisDrawing.Utility.GetEntity(ent, pickPoint)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;ThisDrawing.ActiveDocument.Utility.GetEntity(ent, pickPoint)<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Dim point(0 To 2) As Double<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;'SetPoint3d(point, 100, 100, 0)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;point(0) = 100 : point(1) = 100 : point(2) = 0<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Dim xRecord As New ClassXRecord<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Dim dataType As Object<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Dim data As Object<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;xRecord.CreateXRecord(dataType, data, _<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;1, "道路", _<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 8, ent.Layer, _<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;40, pickPoint(0), _<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;10, point)<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;If xRecord.HasXRecord(ent, "EX02") Then<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;ThisDrawing.ActiveDocument.Utility.Prompt(vbNewLine &amp; "实体已经包含指定名称的扩展记录.")<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Else<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;xRecord.AddXRecord(ent, "EX02", dataType, data)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;ThisDrawing.ActiveDocument.Utility.Prompt(vbNewLine &amp; "成功为实体添加扩展记录.")<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;End If<br/>&nbsp; &nbsp; End Sub<br/>&nbsp; &nbsp; ' 向实体追加扩展记录<br/>&nbsp; &nbsp; Public Sub AddXRecord1(ByVal ent As Autodesk.AutoCAD.Interop.Common.AcadEntity, ByVal key As String, ByVal xDataType As Object, ByVal xData As Object)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Dim objDict As Autodesk.AutoCAD.Interop.Common.AcadDictionary<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Dim objXRecord As Autodesk.AutoCAD.Interop.Common.AcadXRecord<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;objDict = ent.GetExtensionDictionary()<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;objXRecord = objDict.AddXRecord(key)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;objXRecord.SetXRecordData(xDataType, xData)<br/>&nbsp; &nbsp; End Sub</p>

xwjljh 发表于 2009-5-7 14:59:00

<p>高手帮帮了</p><p></p>

雪山飞狐_lzh 发表于 2009-5-7 15:29:00

<p>xDataType, xData分别是short数组和object数组</p><p></p>

xwjljh 发表于 2009-5-7 21:37:00

<p>谢谢 <strong><font color="#da2549" face="Verdana">lzh741206</font></strong>的大力帮助</p><p>时隔将近半年的 问题终于解决了</p><p>也解除了困扰我4个多月的问题</p><p>谢谢了</p><p>向你表示崇高的敬意!!</p>

河外之星 发表于 2015-12-15 08:45:54

果然xDataType, xData分别是short数组和object数组 integer都不行,还必须是short
页: 1 [2]
查看完整版本: VB.NET CAD扩展数据问题