乐筑天下

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

[求助]关于刷新实现动态效果的求救!

[复制链接]

5

主题

13

帖子

2

银币

初来乍到

Rank: 1

铜币
33
发表于 2010-5-28 11:02:00 | 显示全部楼层 |阅读模式
第一次执行命令,圆可以动态显示,第二次执行命令的时候,圆就不能动态显示了,这段代码有什么问题呢,请大家指点迷津。
  1. Imports Autodesk..ApplicationServices
  2. Imports Autodesk.AutoCAD.Colors
  3. Imports Autodesk.AutoCAD.DatabaseServices
  4. Imports Autodesk.AutoCAD.EditorInput
  5. Imports Autodesk.AutoCAD.Geometry
  6. Imports Autodesk.AutoCAD.Runtime
  7. Imports Autodesk.AutoCAD.GraphicsSystem
  8. Imports Autodesk.AutoCAD.GraphicsInterface
  9. Imports Autodesk.AutoCAD.Windows
  10. Imports Autodesk.AutoCAD.Publishing
  11. Imports Autodesk.AutoCAD.PlottingServices
  12. Imports Autodesk.AutoCAD.ComponentModel
  13. Imports Autodesk.AutoCAD.LayerManager
  14. Public Class Class1
  15.     Private MousePoint As Point3d = New Point3d(0, 0, 0) '保存当前鼠标位置
  16.     Shared Cr As Circle
  17.      Public Sub test()
  18.         Dim Db As Database = HostApplicationServices.WorkingDatabase
  19.         Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
  20.         Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
  21.         Using LckDoc As DocumentLock = Doc.LockDocument
  22.             Using Trans As Transaction = Db.TransactionManager.StartTransaction()
  23.                 Try
  24.                     Dim Bt As BlockTable = Trans.GetObject(Db.BlockTableId, OpenMode.ForRead)
  25.                     Dim Btr As BlockTableRecord = Trans.GetObject(Bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
  26.                     
  27.                     Cr = New Circle
  28.                     Cr.SetDatabaseDefaults()
  29.                     Cr.Radius = 10
  30.                     Cr.Center = New Point3d(0, 0, 0)
  31.                     Btr.AppendEntity(Cr)
  32.                     Trans.AddNewlyCreatedDBObject(Cr, True)
  33.                     ed.WriteMessage("new后圆id:" + Cr.ObjectId.ToString)
  34.                     Dim pro As PromptPointOptions = New PromptPointOptions("按左键退出...")
  35.                     AddHandler ed.PointFilter, AddressOf GetMousePoint
  36.                     Dim res As PromptPointResult = ed.GetPoint(pro)
  37.                     Dim Po1 As Point3d = res.Value
  38.                     RemoveHandler ed.PointFilter, AddressOf GetMousePoint
  39.                     Cr.ColorIndex = 1
  40.                     Trans.Commit()
  41.                 Catch ex As System.Exception
  42.                     MsgBox("Error : " + ex.Message)
  43.                 Finally
  44.                 End Try
  45.             End Using
  46.         End Using
  47.     End Sub    ''动态获取鼠标位置  
  48.     Private Sub GetMousePoint(ByVal sender As Object, ByVal e As PointFilterEventArgs)
  49.         MousePoint = e.Context.ComputedPoint
  50.         Dim Db As Database = HostApplicationServices.WorkingDatabase
  51.         Dim Ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
  52.         Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
  53.         Using LckDoc As DocumentLock = Doc.LockDocument
  54.             Using Trans As Transaction = Db.TransactionManager.StartTransaction()
  55.                 Try
  56.                     Dim Pt1 As Point3d = New Point3d(0, 0, 0)
  57.                     Cr.Radius = New Line(MousePoint, Pt1).Length / 2
  58.                     Cr.Center = MousePoint
  59.                     Doc.Editor.Regen()
  60.                     Ed.WriteMessage("圆id:" + Cr.ObjectId.ToString)
  61.                     Trans.Commit()
  62.                 Catch ex As System.Exception
  63.                     MsgBox("Error : " + ex.Message)
  64.                 Finally
  65.                 End Try
  66.             End Using
  67.         End Using
  68.     End Sub
  69. End Class
回复

使用道具 举报

72

主题

2726

帖子

9

银币

社区元老

Rank: 75Rank: 75Rank: 75

铜币
3014
发表于 2010-5-28 19:30:00 | 显示全部楼层
用Jig实现,看看Kean专题中关于Jig的部分
回复

举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-15 03:25 , Processed in 2.324775 second(s), 56 queries .

© 2020-2025 乐筑天下

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