The autocad.net plug-in obtains the parameters of the AutoCAD startup command line.

Source: Internet
Author: User

Today, a kids shoes asks how to obtain the parameters at AutoCAD startup in the AutoCAD plug-in. The user story is like this. Before AutoCAD is started, a winform first written by itselfProgramPerform user verification. If the verification succeeds, start AutoCAD through process. Start and pass a token to it as the parameter. Of course, this token is the best encrypted. Then obtain the token in your plug-in. If you can obtain the token, this user is a legal user and the following functions can be normally executed. If you have not obtained the token, this user directly uses the plug-in function without user verification. Most of them are illegal users or pirated users. Sorry, you should stop using the plug-in first. The idea is good. The key is to obtain the parameters of AutoCAD at startup.

 

This can be achieved through environment. getcommandlineargs (). Below is a testCode:

 [commandmethod ( "ARGs" )]  Public   void  getacadarguments () {document DWG = application. documentmanager. mdiactivedocument; Editor ED = DWG. editor;  int  I = 0;  foreach  ( string  Arg  in  environment. getcommandlineargs () {ed. writemessage ( "\ n Arg {0 }=\" {1} \ "" , I ++, ARG );}} 

Add several parameters for testing at startup debugging, for example, I added/myarg1 and nologo:

 

Let's take a look at the output:

This answer is from the AutoCAD Forum. If you have any questions, check it out on the Forum. Someone else may have asked me. If not, post a post on the Forum. n more cool help :)

Http://forums.autodesk.com/t5/NET/Getting-command-line-parameters/td-p/3534742

 

Let's continue with the discussion. The above mentioned method for starting AutoCAD is through process. start to start the process. If you want to start AutoCAD by calling COM, this method will not work, but it will become a problem of inter-process communication. There are many ways to search for this. You can also refer to Kean's blog to introduce a method with sample code:

Http://through-the-interface.typepad.com/through_the_interface/2009/05/interfacing-an-external-com-application-with-a-net-module-in-process-to-autocad-redux.html

 

 

In addition, the user verification problem of the plug-in mentioned above can also be viewed on this blog, using the Windows azure cloud platform for user verification is more reliable than obtaining a token locally.

Http://adndevblog.typepad.com/autocad/2012/10/trial-licensing-and-usage-metrics-gathering-for-autocad-plugin-using-azure-cloud.html

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.