Externally built string to AutoCAD Command line

Externally built string to AutoCAD Command line

dennis
Advisor Advisor
722 Views
4 Replies
Message 1 of 5

Externally built string to AutoCAD Command line

dennis
Advisor
Advisor

Scenario:

I have a C Sharp WIndows App that collects a list of TXT files.

I then launch AutoCAD and I want to call another DLL command, feeding that list of TXT files to process as a delimeted string.

Calling the command via SendCommand, no problem.  But as an example, when i build:

string txtFiles = "Txt01" + "|" + "Txt02" + "|" + "Txt03"; // + etc

Then in AutoCAD,

SendCommand("_MYDLLCOMMAND txtFiles "), the command will lauch but instead of seeing the string list, it just sees the txtFiles as nil.

I know i could write out a file to the temp folder and then have the DLL command look there, but was wanting something more direct.

 

Any ideas?

 

0 Likes
Accepted solutions (1)
723 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor
Accepted solution

It would not work unless you do something inside your CommandMethod that stop the process and waiting for user to enter something at command line.

 

You can read one of Kean's articles on this topic:

 

http://through-the-interface.typepad.com/through_the_interface/2006/09/passing_argumen.html

 

If the data to be passed is not complicated, I'd simply store it is a USER variables before calling my Command Method. That is, in your external Acad-automation app, you do:

 

objAcadDoc.SetVariable("USERS1", myData)

 

then you call

 

objAcadDoc.SendCommand("myCommand")

 

And in the CommandMethod, the code would first try to get data from the user variable. If no data available in the user available, then the code would ask user input before continue. This way, your commandmethod can be used either manually in AutoCAD, or used by your external automation applicationos.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 5

SENL1362
Advisor
Advisor

you could start AutoCAD with youre own arguments.
AutoCAD skips the unknown arguments

you can find them using
foreach (string arg in Environment.GetCommandLineArgs())


0 Likes
Message 4 of 5

dennis
Advisor
Advisor

I tried your suggestions: The exe switch idea results were still not the value of the string txtlist, but just the nil value for txtlist. 

I think the USER variable will work, but I decided to go the "tried and true way" and write a temporary file because the list could potentially get very long and I wasn't sure just how many characters the USER variable could hold.

0 Likes
Message 5 of 5

SENL1362
Advisor
Advisor

I would have solved it like this:
1. Start AutoCAD with standard arguments and youre arguments appended
2. Autoload .net DLL
3. Start youre .NET command from winthin youre exe as Normal suggested
4 youre .NET command read all the AutoCAD arguments and select the ones you need.

http://through-the-interface.typepad.com/through_the_interface/2014/03/getting-autocads-command-line...

0 Likes