.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Automating the "open - select file" command

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
dustin.schouster
1243 Views, 7 Replies

Automating the "open - select file" command

I am using the Visual Studio 2015 - .net framework in C#.  I am a new to C# but fairly experienced in C++, so programming in general I would consider myself a novice, not a complete newb.

 

I am new to the AutoCAD customization world, just finished my first "Hello World" plug-in.  Please keep this in mind when reading the nature of my question :).  I plan to go through more tutorials but I would like to start taking bite size chunks of what I am trying to accomplish.

 

Right now we have a custom application that is loaded automatically when starting AutoCAD.  This is corporate wide and I don't want to modify this  (though I could simply replace it eventually if need be).  For now let's just assume I want to interface with this using my own script.

 

This application can be ran typing in a simple command.  Let's just call it simpCommand.

 

When I type in "simpCommand", a window pops up and it wants me to select a file in my local directory.

 

is it possible to type "simpCommand" and something right after it to automatically locate the file I want it to pick.  Or is it possible to have my C# .net interface to type in "simpCommand" and select the file for me.

 

7 REPLIES 7
Message 2 of 8

You can set the FILEDIA system variable to 0 to disable the file selection dialog, and you will be prompted for files on the command line, which you can reply to via scripting.  Be sure to set FILEDIA back to its previous value afterwards.

 


@dustin.schouster wrote:

I am using the Visual Studio 2015 - .net framework in C#.  I am a new to C# but fairly experienced in C++, so programming in general I would consider myself a novice, not a complete newb.

 

I am new to the AutoCAD customization world, just finished my first "Hello World" plug-in.  Please keep this in mind when reading the nature of my question :).  I plan to go through more tutorials but I would like to start taking bite size chunks of what I am trying to accomplish.

 

Right now we have a custom application that is loaded automatically when starting AutoCAD.  This is corporate wide and I don't want to modify this  (though I could simply replace it eventually if need be).  For now let's just assume I want to interface with this using my own script.

 

This application can be ran typing in a simple command.  Let's just call it simpCommand.

 

When I type in "simpCommand", a window pops up and it wants me to select a file in my local directory.

 

is it possible to type "simpCommand" and something right after it to automatically locate the file I want it to pick.  Or is it possible to have my C# .net interface to type in "simpCommand" and select the file for me.

 


 

Message 3 of 8

If the custom application uses the standard autocad file dialog then as previously mentioned setting the FILEDIA parameter will allow you to control it.  However, I believe if the custom application uses a custom solution for the file dialog then the FILEDIA might not have an effect.  This can happen if the original programmer did not implement it.  Most custom applications use the standard autocad file open dialog but some do not.  In my custom applications I use a custom file dialog that will allow me to theme it accordingly.  I also do not implement the FILEDIA system variable as most of my file open dialogs are embeded into other user dialogs and the payoff to implement is just not that high.

 

That being said, I have had automated other 3rd party dialogs in AutoCAD using AutoIt.  When a dialog pops up, say the filedialog, you can automatically fill in the filename and close out the dialog.   Please note it is easier to use the FILEDIA if it will work with your individual application.  I use this alot when automating drawings that use CADWorx.  They always pop up a dialog when a drawing opens.  This allows me to choose the appropriate options of the dialog and then automatically close it and continue on with my operation.

Message 4 of 8

Looks like you called it, setting the FILEDIA to 0 had no impact on this custom process.

 

It looks like they did not utilize the FILADIA command when selecting this file.

Message 5 of 8

Thanks for the help, your solution would have worked but it doesn't seem to impact the custom application.

 

When setting FILEDIA to 0, the custom application still puts me in the windows open form and I cannot simply type in the filename location in the command line.

Message 6 of 8

I am going to check out this Autoit tool and see if I can handle what I need completely using Autoit.

 

What I want to accomplish isn't necessarily fancy or requiring deep invokes into AutoCAD itself.

 

All I really want to do is take 47 files, replace the borders using the custom application that is loaded on start-up, and modify the border parameters depending on which sheet it is.

 

Not sure the full capabilities of AutoIt regarding this but I will see what it can accomplish.

 

The most important thing is.

It opens up File #1, types in parameters...one parameter will keep incrementing as the file # increases (Sheet 1, Sheet 2, Sheet 3) etc.

Message 7 of 8

If the application you're trying to script is an in-house developed app, and/or you have the source for it, it might be easier to modify the app to honor FILEDIA.  I've never been fond of kludges that automate dialogs, but if there's no better way, then you might try using the SendKeys class which comes in the box.

 

 

 


@dustin.schouster wrote:

Thanks for the help, your solution would have worked but it doesn't seem to impact the custom application.

 

When setting FILEDIA to 0, the custom application still puts me in the windows open form and I cannot simply type in the filename location in the command line.


 

Message 8 of 8

The custom app was designed by a third party.  In order to do any modifications or get support we have to pay them.

 

I do have the source code but this was already deployed company wide (many users) so I'd rather leave it alone if possible.

The source code is out of date as well, so I would have to request them to give me the new source code.  I am also a newb to AutoCAD programming.  Keep in mind the only plug-in I have ever created was a "Hello World" example :).

 

I looked through the source code and would have to re-write a small portion of it which may get me down a rabbit hole.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost