AutoCAD2006 .net开发之二-用鼠标从屏幕点和长度
1using System ;
2using Autodesk.AutoCAD.Runtime ;
3using Autodesk.AutoCAD.ApplicationServices;
4using Autodesk.AutoCAD.EditorInput;
5
6
7[assembly: CommandClass(typeof(ClassLibrary.Class))]
8
9namespace ClassLibrary
10{
11 /// <summary>
12 /// Summary description for Class.
13 /// </summary>
14 public class Class
15 {
16 public Class()
17 {
18 //
19 // TODO: Add constructor logic here
20 //
21 }
22
23 // Define Command "AsdkCmd1"
24 [CommandMethod("AsdkCmd1")]
25 static public void test() // This method can have any name
26 {
27 PromptPointOptions ppo = new PromptPointOptions("Select a point:");
28 Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
29 PromptPointResult ppr = ed.GetPoint(ppo);
30 if(ppr.Status != PromptStatus.OK)
31 {
32 ed.WriteMessage("error");
33 }
34 else
35 {
36 ed.WriteMessage(ppr.Value.ToString());
37 ed.WriteMessage(ppr.Value.ToArray().ToString());
38 ed.WriteMessage("X="+ppr.Value.X+"Y="+ppr.Value.Y+"Z="+ppr.Value.Z);
39
40 }
41 }
42
43 [CommandMethod("AsdkCmd2")]
44 static public void test2() // This method can have any name
45 {
46 PromptDistanceOptions pdo = new PromptDistanceOptions("Find distance, select first point:");
47
48
49 Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
50 PromptDoubleResult pdr = ed.GetDistance(pdo);
51 if(pdr.Status != PromptStatus.OK)
52 {
53 ed.WriteMessage("error");
54 }
55 else
56 {
57 ed.WriteMessage("\n");
58 ed.WriteMessage(pdr.Value.ToString());
59 }
60 }
61
62 }
63}
2using Autodesk.AutoCAD.Runtime ;
3using Autodesk.AutoCAD.ApplicationServices;
4using Autodesk.AutoCAD.EditorInput;
5
6
7[assembly: CommandClass(typeof(ClassLibrary.Class))]
8
9namespace ClassLibrary
10{
11 /// <summary>
12 /// Summary description for Class.
13 /// </summary>
14 public class Class
15 {
16 public Class()
17 {
18 //
19 // TODO: Add constructor logic here
20 //
21 }
22
23 // Define Command "AsdkCmd1"
24 [CommandMethod("AsdkCmd1")]
25 static public void test() // This method can have any name
26 {
27 PromptPointOptions ppo = new PromptPointOptions("Select a point:");
28 Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
29 PromptPointResult ppr = ed.GetPoint(ppo);
30 if(ppr.Status != PromptStatus.OK)
31 {
32 ed.WriteMessage("error");
33 }
34 else
35 {
36 ed.WriteMessage(ppr.Value.ToString());
37 ed.WriteMessage(ppr.Value.ToArray().ToString());
38 ed.WriteMessage("X="+ppr.Value.X+"Y="+ppr.Value.Y+"Z="+ppr.Value.Z);
39
40 }
41 }
42
43 [CommandMethod("AsdkCmd2")]
44 static public void test2() // This method can have any name
45 {
46 PromptDistanceOptions pdo = new PromptDistanceOptions("Find distance, select first point:");
47
48
49 Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
50 PromptDoubleResult pdr = ed.GetDistance(pdo);
51 if(pdr.Status != PromptStatus.OK)
52 {
53 ed.WriteMessage("error");
54 }
55 else
56 {
57 ed.WriteMessage("\n");
58 ed.WriteMessage(pdr.Value.ToString());
59 }
60 }
61
62 }
63}