主要代码再贴一下:
Dim pg As MyPropertyGrid.CustomClass = PropertyGrid1.SelectedObject Dim ed As Editor = AcadApp.DocumentManager.MdiActiveDocument.Editor Dim db As Database = AcadApp.DocumentManager.MdiActiveDocument.Database Dim lock As DocumentLock = AcadApp.DocumentManager.MdiActiveDocument.LockDocument() Using trans As Transaction = db.TransactionManager.StartTransaction() Dim attref As AttributeDefinition = trans.GetObject(selID, OpenMode.ForWrite) 'attref.TextString = pg.Item("属性值").ToString Dim mCustomer As CustomerFilter = pg.Item("属性值") attref.TextString = mCustomer.path Dim s As String = pg.Item("显示否").ToString If String.Compare(s, "True") = 0 Then attref.Visible = True Else attref.Visible = False End If Dim c As Color = pg.Item("颜色") Dim cc As Autodesk.AutoCAD.Colors.Color = Autodesk.AutoCAD.Colors.Color.FromColor(c) attref.Color = cc s = pg.Item("大小").ToString attref.Height = Int(Val(s)) s = pg.Item("旋转角").ToString attref.Rotation = Double.Parse(s)
''''''''''''''''''''''''''''''''''''''''''''''''上面的属性全部改掉了 Dim p As Point = pg.Item("相对位置") attref.Position = New Point3d(p.X, p.Y, 0)
''''''''''''''''''''''''''''''''''''''''''''''''''''''此时跟踪得到也改掉了 trans.Commit()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''跟踪又改回去了Position的值,而其他属性已经改掉,没有变回去 ed.Regen() End Using lock.Dispose() |