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