*Tim Riley
Message 1 of 1 (91 Views)

IronPython wrapper for AutoCAD.

91 Views, 0 Replies
10-17-2005 02:08 PM
Has anyone looked into IronPython[1] at all? I'm not much of a C#'er but
from what I understand it should be possible to create a wrapper for
IronPython.Hosting in C# and from there load it as a managed assembly into
AutoCAD. The ultimate intent of this would be the ability to use Python as a
scripting language for AutoCAD.

So far I have been able to evaluate python expressions from the command line
using the code below. However this is a far cry from anything of value, it
was more of a (lame) test.


using System;

using System.Collections;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.Runtime;

using IronPython.Hosting;

namespace PyAcadDotNet


public class AcadInterface



public void pythoneval()


PythonEngine engine = new PythonEngine();

string required = "Enter a python Expression to evaluate:";

CommandLinePrompts.GetString(out required, required, false);

char[] newline = {'\\', 'n'};

string compare = required.TrimEnd(newline);

object results = engine.Evaluate(compare);




public void pythonfile(string filename)


//add code here.






Command: pyeval

Enter a python Expression to evaluate:2+2




Does anyone think this project would be feasible or am I just a dreamer?
I'll keep trying to get something going but if anyone is interested in
helping shoot me an email to riltim___@___gmail.com. I have a SubVersion
repository for anyone interesting in coding to use.



Tim Riley
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.