Export cadvba code to. net

Source: Internet
Author: User

VBA written earlierCodeIf all are rewritten with. net, it will be hard work and financial, and there is no interest in rewriting. So I used a very lazy method.
Use com to call AutoCAD 200x Type Library and AutoCAD/objectdbx common xx. X Type Library, which defines the thisdrawing object in VBA and can run normally written VBA code without any modifications.
For the form in VBA, you can export it as a VB form first, then use the Upgrade Wizard to upgrade to. net, and make necessary modifications.
Autodesk provides related video tutorials and a tool for exporting VBA to VB. VBA → Vb → VB. NET
Related videos & tools: http://download.autodesk.com/media/adn/VBA_Migration/DevTV_Recording.zip

[VB. NET]

 Code 
    1   Imports Autodesk. AutoCAD. InterOP
2
3   Public Class Class1
4
5 Readonly Property Thisdrawing () As Autodesk. AutoCAD. InterOP. acaddocument
6 Get
7 Return Autodesk. AutoCAD. applicationservices. application. documentmanager. mdiactivedocument. acaddocument
8 End Get
9 End Property
10
11 < Autodesk. AutoCAD. runtime. commandmethod ( " Test " ) > _
12 Sub Test ()
13 Thisdrawing. Utility. Prompt ( " Hello world! " )
14 End sub
15
16 End Class

 

[C #]

Code

   1   Using  System;
2 Using System. Collections. Generic;
3 Using System. text;
4 Using Autodesk. AutoCAD. InterOP;
5
6 Namespace Cstest
7 {
8 Public Class Class1
9 {
10 Public Static Acaddocument thisdrawing
11 {
12 Get
13 {
14 Return (Acaddocument) Autodesk. AutoCAD. applicationservices. application. documentmanager. mdiactivedocument. acaddocument;
15 }
16 }
17
18 [Autodesk. AutoCAD. runtime. commandmethod ( " Test " )]
19 Public Void Test ()
20 {
21 Thisdrawing. Utility. Prompt ( " Hello world! " );
22 }
23
24 }
25 }
26
27

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.