各位高手:添加一多义线并设置线型错在什么地方
<p> '绘多义线<br/> <CommandMethod("AddPL")> _<br/> Public Sub AddPL()<br/> Dim pl As New Polyline<br/> Dim DB As Database<br/> Dim trans As Transaction<br/> Dim btr As BlockTableRecord<br/> Dim bt As BlockTable<br/> 'Dim li As Object</p><p><br/> DB = HostApplicationServices.WorkingDatabase<br/> trans = DB.TransactionManager.StartTransaction<br/> bt = trans.GetObject(DB.BlockTableId, OpenMode.ForWrite)<br/> btr = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)<br/> 'Dim pLinetypeTbl As LinetypeTable = trans.GetObject(DB.LinetypeTableId, OpenMode.ForRead)</p><p> 'If pLinetypeTbl.Has("DASHDOT") Then</p><p> 'DB.LoadLineTypeFile("DASHDOT", "acadiso.lin")<br/> 'End If<br/> Dim point2D(2) As Point2d</p><p> point2D(0) = New Point2d(10, 10)<br/> point2D(1) = New Point2d(10, 5)<br/> point2D(2) = New Point2d(30, 40)</p><p> pl.AddVertexAt(0, point2D(0), 0, 1, 1)<br/> pl.AddVertexAt(1, point2D(1), 0, 1, 1)<br/> pl.AddVertexAt(2, point2D(2), 0, 1, 1)<br/> pl.LinetypeId = CreatLineType("DASHDOT")<br/> ' pl.Linetype = "DASHDOT"<br/> btr.AppendEntity(pl)<br/> trans.AddNewlyCreatedDBObject(pl, True)<br/> trans.Commit()<br/> trans.Dispose()</p><p> End Sub</p><p> Private Function CreatLineType(ByVal LineTypeName As String) As ObjectId<br/> Dim LineTypeID As ObjectId<br/> Dim db As Database = HostApplicationServices.WorkingDatabase<br/> Using trans As Transaction = db.TransactionManager.StartTransaction<br/> Dim it As LinetypeTable = trans.GetObject(db.LinetypeTableId, OpenMode.ForRead)<br/> If it.Has(LineTypeName) Then<br/> LineTypeID = it.Item(LineTypeName)<br/> Else<br/> db.LoadLineTypeFile(LineTypeName, "acadiso.lin")<br/> Dim ltr As New LinetypeTableRecord<br/> ltr.Name = LineTypeName<br/> it.UpgradeOpen()<br/> LineTypeID = it.Add(ltr)<br/> trans.AddNewlyCreatedDBObject(ltr, True)<br/> <br/> End If</p><p>trans.Commit()</p><p> End Using<br/> Return LineTypeID<br/> End Function</p> <p>Dim it As LinetypeTable = trans.GetObject(db.LinetypeTableId, OpenMode.ForRead)</p><p> OpenMode.ForRead 改为OpenMode.ForWrite</p><p>没有测试过,只是看见这个地方有问题</p>
页:
[1]