In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the AutoCAD wizard and the Editor class in C#.NET". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the AutoCAD wizard and Editor class in C#.NET".
1) start Visual Studio .NET and select "File > New > Project" (File > New > Project). In the New Project dialog box, select the project type as Visual C # Project, and then select the AutoCAD Managed CS Project Application template. Type "Lab2" in the project name box, and then select the location where the project is stored. Click the OK button and the AutoCAD Managed CSharp Application Wizard dialog box will appear. Do not select the "Enable Unmanaged Debugging" item because we do not need to use unmanaged code. "Registered Developer Symbol" will use the value you entered when you installed the ObjectARX wizard. Click the finish button to create the project.
2) Let's take a look at the project generated by the wizard. In the solution browser, you will see that acdbmgd and acmgd have been referenced. In the Class.cs file, the "Autodesk.AutoCAD.Runtime" namespace has been imported, and the project uses the name "Registered Developer Symbol" to name the default public class. The wizard also adds a CommandMethod property and a function to the class, which are used in the AutoCAD command.
3) in the previous chapter, we used an instance object of the "Autodesk.AutoCAD.EditorInput.Editor" class to output text on the AutoCAD command line. In this chapter, we will use this class to prompt the user to select a point in the AutoCAD graph, and then display the x and Z values of the point selected by the user. As in the previous chapter, import the Autodesk.AutoCAD.ApplicationServices and Autodesk.AutoCAD.EditorInput namespaces.
4) change the value of the CommandMethod property generated by the wizard to something more meaningful, such as "selectPoint" (the name of the function can not be changed). The PromptPointOptions class is used to set prompt strings and other options that control prompts. An instance of this class is passed as a parameter to the Editor.GetPoint method. At the beginning of the function, instantiate the class and set the string parameter to "Select a point". Because the Editor.GetPoint method returns an instance object of the PromptPointResult class, we will instantiate it as well.
PromptPointOptions prPointOptions = new PromptPointOptions ("Select a point"); PromptPointResult prPointRes;5) next instantiates an object of the Editor class and uses the GetPoint method whose argument is the PromptPointOptions object. Assign a value to the PromptPointResult object declared above with the return value of the GetPoint method. After the assignment, we can test the state of the PromptPointResult object and return if it is not OK.
PrPointRes = ed.GetPoint (prPointOptions); if (prPointRes.Status! = PromptStatus.OK) {ed.WriteMessage ("Error");} 6) if the PromptPointResult object returns a valid point, we can use the WriteMessage method to output the result to the command line. PromptPointResult.Value 's ToString method makes the output very easy:
Ed.WriteMessage ("You selected point" prPointRes.Value.ToString) 7) Press F5 to run a process that debugs AutoCAD. (note: the wizard has been set up to debug with acad.exe.) enter NETLOAD on the AutoCAD command line, select Lab2.dll and open it. Enter the name of your command (selectPoint) on the command line. At the prompt to select a point, click any point in the drawing. If all goes well, you can see the coordinate values of the point you selected on the command line. Add a breakpoint on the "ed.WriteMessage (" Error "); line of the Class.cs file, and then run the selectPoint command again. This time, press ESC at the prompt to select a point instead of selecting a point. The state of the PromptPointResult object is not OK, so the if statement in the above code will be executed and the "ed.WriteMessage (" Error "); statement will be called.
8) next we will add another command that can get the distance between two points. The wizard does not have the ability to add commands, so we have to add them manually. Add a new command named getDistance under the function for selecting points (getPoint) in the Class.cs file. For ways to add commands, please refer to the contents of the previous chapter or the source code of this chapter, which are not listed here. Use the CommandMethod property and make the string argument "getdistance" or something like that. Use PromptDistanceOptions instead of PromptPointOptions in the function of the command. Of course, the return value of the GetDistance method is an instance object of the PromptDoubleResult class, so use PromptDoubleResult instead of PromptPointResult:
PromptDistanceOptions prDistOptions = new PromptDistanceOptions ("Find distance, select first point:"); PromptDoubleResult prDistRes; prDistRes = ed.GetDistance (prDistOptions); 9) like the previous command, you can test the state of the PromptDoubleResult and then use the WriteMessage method to display the value on the command line.
If (prDistRes.Status! = PromptStatus.OK) {ed.WriteMessage ("Error");} else {ed.WriteMessage ("The distance is:" + prDistRes.Value.ToString ()) Thank you for reading, the above is the content of "what is the AutoCAD wizard and Editor class in C#.NET". After the study of this article, I believe you have a deeper understanding of what the AutoCAD wizard and Editor class in C#.NET are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.