|
想绘制一个矩形框,然后给这个矩形框添加一个名称和标记的扩展数据。然后返回这个矩形框的ObjectId。在绘制以后在通过这个矩形的ObjectId重新获得这个矩形的名称和标记。如何做到?下面是我写的一部分代码,没有完成,请大家帮忙了。
- <ol style="margin-left: 10px !important; color: rgb(102, 102, 102); font-family: 'Microsoft Yahei', Simsun; "><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; ">
- '通过用户指定点后再绘制这个矩形,矩形的长和宽也作为参数
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; ">Public Shared Function AddRectangle(ByVal cenPt As Point3d, ByVal Height As Double, _
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> ByVal Length As Double) As ObjectId
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim Pt(4) As Point3d
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Pt(0) = New Point3d(cenPt.X - Length * 0.5, cenPt.Y - Height * 0.5, 0)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Pt(1) = New Point3d(cenPt.X + Length * 0.5, cenPt.Y - Height * 0.5, 0)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Pt(2) = New Point3d(cenPt.X + Length * 0.5, cenPt.Y + Height * 0.5, 0)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Pt(3) = New Point3d(cenPt.X - Length * 0.5, cenPt.Y + Height * 0.5, 0)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Pt(4) = New Point3d(cenPt.X - Length * 0.5, cenPt.Y - Height * 0.5, 0)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim Pts As New Point3dCollection(Pt)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> ' 在内存中创建一个未经拟合的标准三维多段线对象.
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim ent As New Polyline3d(Poly3dType.SimplePoly, Pts, False)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; ">
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> 'Add the rectangle polyline entity to model space
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim acEntId As ObjectId = AppendEntity(ent)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; ">
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim dt As DataTable = New DataTable()
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> dt.TableName = "属性表"
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> dt.AppendColumn(CellType.CharPtr, "Name")
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> dt.AppendColumn(CellType.CharPtr, "Tag")
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim row As DataCellCollection = New DataCellCollection()
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim Name As DataCell = New DataCell()
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim Tag As DataCell = New DataCell()
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Name.SetString("矩形框")
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Tag.SetString("矩形标记")
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> row.Add(Name)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> row.Add(Tag)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> dt.AppendRow(row, True)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; ">
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> ent.CreateExtensionDictionary()
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim exDic As DBDictionary = New DBDictionary() '如何将扩展数据记录下来啊?
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> exDic.SetAt("属性表", dt)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; ">
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; ">
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> '返回ObjectId
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Return acEntId
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> End Function
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; ">
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; ">' 将图形对象加入到模型空间的函数.
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Public Shared Function AppendEntity(ByVal ent As Entity) As ObjectId
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> ' 得到当前文档图形数据库.
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim db As Database = HostApplicationServices.WorkingDatabase
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim entId As ObjectId
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Using trans As Transaction = db.TransactionManager.StartTransaction
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> ' 以读方式打开块表.
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> ' 以写方式打开模型空间块表记录.
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> Dim btr As BlockTableRecord = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> ' 将图形对象的信息添加到块表记录中,并返回ObjectId对象.
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> entId = btr.AppendEntity(ent)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> ' 把图形对象添加到事务处理中.
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> trans.AddNewlyCreatedDBObject(ent, True)
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> ' 提交事务处理.
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> trans.Commit()
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> End Using
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; background-color: rgb(255, 255, 255); color: rgb(51, 102, 153); "> Return entId
- </li><li style="padding-left: 10px; list-style-type: decimal-leading-zero; font-family: Monaco, Consolas, 'Lucida Console', 'Courier New', serif; font-size: 12px; line-height: 1.8em; "> End Function</li></ol>
复制代码 |
|