polyline的 StartPoint 不支持写吗?请教
....Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim myCurve As Curve
myCurve = TryCast(trans.GetObject(resEnt.ObjectId, OpenMode.ForWrite), Curve)
myCurve.StartPoint = New Point3d(0, 0, 0)
......
最后一句报错 :The method or operation is not implemented setpointat
最好多研究下C#的继承、虚函数
StartPoint属性的set在polyline中应该是没有继承,或者直接抛出异常了 Public Overridable Property StartPoint As Point3d
是这样的,不是readonlly
setpointat 没这个方法 1、因为你的Curve实际上是Polyline,那么你将类型转换为Polyline时,即可调用setpointat方法;
2、Polyline应该override了StartPoint属性。将其set方法改为抛出The method or operation is not implemented异常。StartPoint属性的get还是没问题的。 Dim myCurve As Polyline
....
myCurve.SetPointAt(0,New Point2d(0,0)) ivde:
谢谢!
测试是这个原因,理解了。
Public Sub ccc()
Dim myCurve As Curve
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim optEnt As New PromptEntityOptions(vbLf & "选择曲线:")
Dim resEnt As PromptEntityResult = ed.GetEntity(optEnt)
If (resEnt.Status = PromptStatus.OK) Then
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = CType(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = CType(trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
myCurve = TryCast(trans.GetObject(resEnt.ObjectId, OpenMode.ForWrite), Curve)
If Not myCurve Is Nothing And TypeOf myCurve Is Polyline Then
CType(myCurve, Polyline).SetPointAt(0, New Point2d(0, 0))
trans.Commit()
End If
End Using
End If
End Sub
页:
[1]