|
Public Sub GetCircle()
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
'创建一个选择实体的选择集选项,并限制为只能选择圆(使用了AddAllowedClass函数)
Dim entitySelectionOpts As PromptEntityOptions = New PromptEntityOptions("\nSelect Circle")
entitySelectionOpts.SetRejectMessage("\nOnly Circles may be selected.")
entitySelectionOpts.AddAllowedClass(GetType(Circle), True)
'开始选择圆的过程
Dim entitySelectionResult As PromptEntityResult = ed.GetEntity(entitySelectionOpts)
'如果成功选择了一个圆,就在命令行显示圆的半径
If entitySelectionResult.Status = PromptStatus.OK Then
DispalyCircleRadius(entitySelectionResult.ObjectId)
End If
End Sub
Private Sub DispalyCircleRadius(ByVal circleId As ObjectId)
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim trans As Transaction
trans = ed.Document.TransactionManager.StartTransaction
Dim selectedCircle As Circle = CType(trans.GetObject(circleId, OpenMode.ForRead), Circle)
Application.ShowAlertDialog("选择的园半径为:" + selectedCircle.Radius.ToString)
trans.Commit()
End Sub
编译的时候,红色标示部分总是提示类型不能转换,请问大家遇到过吗?该怎么解决呢?
|
|