<p><font face="Verdana">Dim pg As MyPropertyGrid.CustomClass = PropertyGrid1.SelectedObject<br/> Dim ed As Editor = AcadApp.DocumentManager.MdiActiveDocument.Editor<br/> Dim db As Database = AcadApp.DocumentManager.MdiActiveDocument.Database<br/> Dim lock As DocumentLock = AcadApp.DocumentManager.MdiActiveDocument.LockDocument()<br/> Using trans As Transaction = db.TransactionManager.StartTransaction()<br/> Dim attref As AttributeDefinition = trans.GetObject(selID, OpenMode.ForWrite)<br/> 'attref.TextString = pg.Item("属性值").ToString<br/> Dim mCustomer As CustomerFilter = pg.Item("属性值")<br/> attref.TextString = mCustomer.path<br/> Dim s As String = pg.Item("显示否").ToString<br/> If String.Compare(s, "True") = 0 Then<br/> attref.Visible = True<br/> Else<br/> attref.Visible = False<br/> End If<br/> Dim c As Color = pg.Item("颜色")<br/> Dim cc As Autodesk.AutoCAD.Colors.Color = Autodesk.AutoCAD.Colors.Color.FromColor(c)<br/> attref.Color = cc<br/> s = pg.Item("大小").ToString<br/> attref.Height = Int(Val(s))<br/> s = pg.Item("旋转角").ToString<br/> attref.Rotation = Double.Parse(s)</font></p>
<p><font face="Verdana"> ''''''''''''''''''''''''''''''''''''''''''''''''上面的属性全部改掉了<br/> Dim p As Point = pg.Item("相对位置")<br/> attref.Position = New Point3d(p.X, p.Y, 0)</font></p>
<p><font face="Verdana">''''''''''''''''''''''''''''''''''''''''''''''''''''''此时跟踪得到也改掉了<br/> trans.Commit()</font></p>
<p>''''''''''''''''''''''''''''''''''''''''''''''''''''''''跟踪又改回去了Position的值,而其他属性已经改掉,没有变回去<font face="Verdana"><br/> ed.Regen()<br/> End Using<br/> lock.Dispose()</font></p> ??anyone help? <p>用7楼的代码测试下</p> <p align="left">原因就是你的属性定义的对齐点没有更新。</p>
<p align="left">加入下面的代码试一试吧。</p>
<p align="left"> </p>
<p align="left"> If attdef.HorizontalMode <> TextHorizontalMode.TextLeft Then</p>
<p align="left"> attdef.AlignmentPoint = attdef.Position</p>
<p align="left"> End If</p> <p><font face="Verdana" color="#61b713"><b>cobalt</b></font>说的没错</p>
<p>如果dbtext、attdef、attref的式样不是左下或调整</p>
<p>Position是无效的</p> 果然好主意,可是新问题出现了,这样我采取了不使用任何对齐方式的方式,结果AttributeDefinition 可以改变任何属性了,但是她的块参照属性<font face="Verdana">AttributeReference</font>却改不了<font face="Verdana">TextString</font>了,现象差不多,只不过变成了<font face="Verdana">TextString</font>属性,以前是可以的 所有属性都不能改,晕 o了,搞错了, 现在发现都能改了,但是文字却不能显示了,实际位置没错,显示状态没错,就是没看到,点击属性也发现名称是有的,就是显示不出来
页:
1
[2]