学习VB.net二次开发例程
<P> <CommandMethod("GetCircle")> Public Sub GetCircle()<BR> Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor<BR> '创建一个选择实体的选择集选项,并限制为只能选择圆(使用了AddAllowedClass函数)<BR> Dim entitySelectionOpts As PromptEntityOptions = New PromptEntityOptions("\nSelect Circle")<BR> entitySelectionOpts.SetRejectMessage("\nOnly Circles may be selected.")<BR> entitySelectionOpts.AddAllowedClass(GetType(Circle), True)<BR> '开始选择圆的过程 <BR> Dim entitySelectionResult As PromptEntityResult = ed.GetEntity(entitySelectionOpts)<BR> '如果成功选择了一个圆,就在命令行显示圆的半径 <BR> If entitySelectionResult.Status = PromptStatus.OK Then<BR> <FONT color=#ff0000>DispalyCircleRadius(entitySelectionResult.ObjectId)</FONT><BR> End If<BR> End Sub</P><P><BR> Private Sub DispalyCircleRadius(ByVal circleId As ObjectId)<BR> Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor<BR> Dim trans As Transaction<BR> <FONT color=#ff0000>trans = ed.Document.TransactionManager.StartTransaction<BR></FONT> Dim selectedCircle As Circle = CType(trans.GetObject(circleId, OpenMode.ForRead), Circle)<BR> Application.ShowAlertDialog("选择的园半径为:" + selectedCircle.Radius.ToString)<BR> trans.Commit()<BR> End Sub</P>
<P>编译的时候,红色标示部分总是提示类型不能转换,请问大家遇到过吗?该怎么解决呢?</P> <P>已经解决,呵呵</P>
<P>是由于同一个解决方案中其它项目加载了2005的库文件</P> 楼上的朋友。请问你是如何设置。NET环境的?能否教教我?谢谢
页:
[1]