[IronPython] Strange Embedding Questions

Tim Riley riltim at gmail.com
Tue Apr 11 21:15:59 CEST 2006

I have an application that I am working on which basically will provide
IronPython as a scripting language for AutoCAD. I have a command now that
will allow me to select an external python file and run it in AutoCAD,
manipulating objects and such. This works fine for testing purposes but in
order to release this as a tool that people will use for production purposes
I need to develop some sort of loading mechanism that will allow me to do
something like load 12 python files at once and call them as needed instead
of having an Open File Dialog box pop up every time a user wants to run a

My next issue which is somewhat coupled with the first. In AutoCAD I would
develop a custom command in C# using attributes like this:

       [CommandMethod("pyfile", CommandFlags.Transparent)]
       public void pythonfile()
           // Create a new instance of PythonEngine and set variables.
           PythonEngine engine = new PythonEngine();
           // Send Stdout and Stderr to the AutoCAD command line.
           engine.SetStdout(new AcadCommandLine());
           engine.SetVariable("null", null);

           // Display an OpenFileDialog and run the script.
       OpenFileDialog ofd = new OpenFileDialog();
       ofd.Filter = "Python files (*.py)|*.py|All files (*.*)|*.*" ;

       // Run the file selected by the open file dialog box.


Basically I need to come up with some method of defining that CommandMethod
Attribute from python file. I'm not necessarily concerned how ugly of a hack
it will be but I need a method of defining custom commands from an external

Anyone have any thoughts/ideas on this. I'm not necessarily looking for a
full code solution, however some pointer would be extremely helpful.

Thanks for reading,
Tim Riley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060411/1d8282bc/attachment.html>

More information about the Ironpython-users mailing list