明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1065|回复: 7

polyline的 StartPoint 不支持写吗?请教

[复制链接]
发表于 2016-1-18 10:55 | 显示全部楼层 |阅读模式
....
                    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





发表于 2016-1-18 12:14 来自手机 | 显示全部楼层
setpointat   
发表于 2016-1-18 15:03 | 显示全部楼层
本帖最后由 雪山飞狐_lzh 于 2016-1-18 15:04 编辑

最好多研究下C#的继承、虚函数
StartPoint属性的set在polyline中应该是没有继承,或者直接抛出异常了
 楼主| 发表于 2016-1-18 19:45 | 显示全部楼层
Public Overridable Property StartPoint As Point3d
是这样的,不是readonlly
 楼主| 发表于 2016-1-18 19:49 | 显示全部楼层
ivde 发表于 2016-1-18 12:14
setpointat

setpointat   没这个方法
发表于 2016-1-18 23:24 | 显示全部楼层
1、因为你的Curve实际上是Polyline,那么你将类型转换为Polyline时,即可调用setpointat方法;
2、Polyline应该override了StartPoint属性。将其set方法改为抛出The method or operation is not implemented异常。StartPoint属性的get还是没问题的。
发表于 2016-1-19 08:18 | 显示全部楼层
Dim myCurve As Polyline

....

myCurve.SetPointAt(0,New Point2d(0,0))
 楼主| 发表于 2016-1-19 21:46 | 显示全部楼层
ivde:
谢谢!
测试是这个原因,理解了。
        <CommandMethod("ccc")>
        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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-26 00:36 , Processed in 0.264358 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表