• λ我爱Aspx >> Asp.Net >> Autodesk官方最新的.NET教程(二)(VB.NET版)
  • Autodesk官方最新的.NET教程(二)(VB.NET版)

  • :未知  Դ:internet  :2007-5-5 13:30:50  ؼ:.net
  • 把向导生成的CommandMethod属性的值改为有意义一些的名字如“selectPoint”(函数的名字可以不用修改)。PromptPointOptions类用来设置提示字符串和其它的一些控制提示的选项。这个类的一个实例作为参数被传入到Editor.GetPoint方法。在函数的开始,实例化这个类,设置字符串参数为“Select a point”。因为 Editor.GetPoint方法会返回一个PromptPointResult类的实例对象,所以我们也要把它实例化。
Dim prPointOptions As PromptPointOptions =
New PromptPointOptions("Select a point")
Dim prPointRes As PromptPointResult
5) 接下来实例化一个Editor类的对象并使用参数为PromptPointOptions对象的GetPoint方法。用GetPoint方法的返回值来给上面声明的PromptPointResult对象赋值。赋值好以后,我们可以测试PromptPointResult对象的状态,如果不是OK就返回。
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
prPointRes = ed.GetPoint(prPointOptions)
If prPointRes.Status <> PromptStatus.OK Then
Return Nothing
End If
6) 如果PromptPointResult对象返回了一个有效的点,我们就可以使用WriteMessage方法把结果输出到命令行。PromptPointResult.Value的ToString方法使输出非常容易:
ed.WriteMessage("You selected point " & prPointRes.Value.ToString())
7) 按F5来运行一个调试AutoCAD的进程。(注意:向导已经设置好用acad.exe来调试)在AutoCAD命令行中输入NETLOAD,选择Lab2.dll并打开。在命令行中输入你起的命令名字(selectPoint)。在选择点的提示下,单击图形中的任一点。如果一切正常的话,你可以在命令行中看到你所选的点的坐标值。在Class.vb文件的“Return Nothing”行加入断点,然后再次运行selectPoint命令。这一次,在选择点的提示下按ESC键而不是选择一个点。PromptPointResult对象的状态就不是OK了,所以上面代码中的if语句就会被执行,“Return Nothing”语句就会被调用。
Ҷƪл˵?
  • һƪ用ImessageFilter接口实现截获键盘消息
    һƪ从注册表读取程序的版本