乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 29|回复: 1

即时显示绘制多义线

[复制链接]

2

主题

3

帖子

1

银币

初来乍到

Rank: 1

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

使用道具 举报

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2010-2-25 18:59:00 | 显示全部楼层
继承Jig类
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-6-28 23:09 , Processed in 3.212251 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表