C # operations cad-call WinForm

Source: Internet
Author: User

Personally, it is convenient to use the command to operate CAD, but given how many people prefer to operate CAD by mouse click, here's how to call WinForm. Pre-Preparation please see article.

1. Create a new WinForm or user control under the premise of creating a new project and referencing the interface DLL.

Calling WinForm directly generates a CAD-independent form on your computer and I feel uncomfortable, so I'll go directly to the process of generating paletteset (embedded in the CAD window).

2, the call process is actually executing a function, and the call of the function requires the user Input command (of course, you can also let the call automatically), after designing the user control, we write the following code in any of the classes:

 Publicclassmain:iextensionapplication {[Commandmethod ("Show")]         PublicvoidInitialize () {UserControl1 control1=NewUserControl1 (); Paletteset PS=NewPaletteset ("Panel 1"); Ps. Size=NewSystem.Drawing.Size ( -, -); Ps. Style=Palettesetstyles.showclosebutton; Ps. ADD ("User Controls", Control1); Ps. Visible=true; }         PublicvoidTerminate () {}}

3, and the execution of a common command, in the CAD Command window, enter show will be on the left side of the CAD window to generate a panel embedded in the CAD, the above buttons can be used normally.

Attach a button event:

PrivatevoidMi1_click (Objectsender, EventArgs e) {Document doc=Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Doc. Sendstringtoexecute (" Line",true,false,true);//There is a space behind line to determine}

The above code is exactly the same as the command line input, which calls the CAD internal name.

C # operations cad-call WinForm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.