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