即时显示绘制多义线
本帖最后由 作者 于 2010-2-25 15:09:52 编辑 <br /><br /> <p>我用.NET写绘制多义线的过程,但是用AddVertexAt方法添加定点后,不能即使显示刚才所添加的多义线段,而是在</p><p>acBlkTblRec.AppendEntity(acPoly)<br/>acTrans.AddNewlyCreatedDBObject(acPoly, True)</p><p>后一次显示出来,不知道设置多义线或者别的什么属性获得即时图形?代码如下</p><p> <CommandMethod("AddLightweightPolyline")> _<br/> Public Sub AddLightweightPolyline()<br/> '' Get the current document and database<br/> Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument<br/> Dim acCurDb As Database = acDoc.Database<br/> Dim ed As Editor = acDoc.Editor<br/> '' Start a transaction<br/> Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()</p><p> '' Open the Block table for read<br/> Dim acBlkTbl As BlockTable<br/> acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)</p><p> '' Open the Block table record Model space for write<br/> Dim acBlkTblRec As BlockTableRecord<br/> acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _<br/> OpenMode.ForWrite)</p><p> '' Create a polyline with two segments (3 points)<br/> Dim acPoly As Polyline = New Polyline()<br/> acPoly.SetDatabaseDefaults()<br/> ' acPoly. <br/> Dim i As Integer = 0<br/> Dim PointPrompt As PromptPointOptions = New PromptPointOptions("")<br/> PointPrompt.Message = vbLf & "选择起点:"<br/> PointPrompt.AppendKeywordsToMessage = False<br/> PointPrompt.AllowNone = False<br/> PointPrompt.UseDashedLine = True '设置橡皮筋的线型为虚线<br/> Dim P3ddResult As PromptPointResult<br/> Do<br/> P3ddResult = ed.GetPoint(PointPrompt)<br/> '中断结束画线<br/> If P3ddResult.Status = PromptStatus.Cancel Or P3ddResult.StringResult = "e" Then<br/> Exit Do<br/> End If</p><p> If P3ddResult.StringResult = "c" Or P3ddResult.StringResult = "C" Then<br/> acPoly.Closed = True'设置多义线为闭合<br/> Exit Do<br/> End If<br/> If P3ddResult.StringResult = "U" Or P3ddResult.StringResult = "u" Then</p><p>'没写出来,那位大大能帮忙些下Undo部分啊,呵呵</p><p> End If</p><p><br/> acPoly.AddVertexAt(i, New Point2d(P3ddResult.Value.X, P3ddResult.Value.Y), 0, 0, 0) '添加多义线顶点,想在添加完这个定点后即时绘制线,如何做到?难道要另外绘制一条线段,然后在选择下个点的时候删除?<br/> <br/> ed.Regen()<br/> If i = 0 Then<br/> PointPrompt.Message = vbLf & "下一点或[\结束(E)\撤销(U)"<br/> PointPrompt.Keywords.Add("U")<br/> PointPrompt.Keywords.Add("u")<br/> PointPrompt.Keywords.Add("e")<br/> PointPrompt.Keywords.Default = "e"<br/> End If<br/> If i = 1 And PointPrompt.Keywords.Count = 3 Then<br/> PointPrompt.Message = vbLf & "下一点或[结束(E)\闭合(C)\撤销(U)]:"<br/> PointPrompt.Keywords.Add("c")<br/> PointPrompt.Keywords.Add("C")<br/> End If </p><p> i = i + 1<br/> PointPrompt.BasePoint = P3ddResult.Value<br/> PointPrompt.UseBasePoint = True</p><p><br/> Loop<br/> '' Add the new object to the block table record and the transaction<br/> acBlkTblRec.AppendEntity(acPoly)<br/> acTrans.AddNewlyCreatedDBObject(acPoly, True)</p><p>'到这里才一次显示完所绘制的线好郁闷</p><p> '' Save the new object to the database<br/> acTrans.Commit()<br/> End Using<br/> End Sub</p> <p>继承Jig类</p><p><a href="http://www.mjtd.com/bbs/dispbbs.asp?BoardID=33&replyID=12429&id=76535&skin=0">http://www.mjtd.com/bbs/dispbbs.asp?BoardID=33&replyID=12429&id=76535&skin=0</a></p>
页:
[1]