Code Red => VB(A) => Topic started by: TR on April 11, 2005, 09:47:40 PM

Title: C# Help
Post by: TR on April 11, 2005, 09:47:40 PM
Well there isn't a C# forum so I figured this would be the closest related forum. I'm working on my latest project and I'm having a hell of a time debugging C# (of course it might help if I knew what I was doing). Here's the code I'm using and as far as I know it should work. I can enter my custom command in AutoCAD and it will prompt me to "Enter a Python Expression:", however it doesn't return any results. I'm assuming this is is an error in the way I'm dealing with the AutoCAD command line.

I'll keep working at it but if anyone can see something obvious that I'm doing wrong it would be great if you let me know.

Code: [Select]

#region Using directives

using System;
using System.IO;
using System.Collections;
using IronPython.Hosting;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Pynk.Wrapper;


namespace PyAcad_net
    public class Commands
        //The command to type at the command line "pycommand".
        [CommandMethod("pycommand", CommandFlags.Modal)]
        public static void PyCommandLine_1()
            //create a call to the command class
            string args;
            CommandLinePrompts.GetString( out args, "Enter a Python Expression: ", false);
            PyAcad pystring = new PyAcad();
            string results = pystring.pythonstring(args);
   public class PyAcad
       public PyAcad()
       public string pythonstring(string Args)
           FrameHolder pyacad = new FrameHolder();
           OutputQueue results = new OutputQueue();
           string returnstring = results.ReadToEnd();
           return returnstring;

Title: C# Help
Post by: Kerry on April 11, 2005, 10:44:50 PM
Hi Tim,

No answer yet, but some questions instead ..:D

Which version of IronPython [ 0.6.0 or 0.7.1] ?
Which Acad              [ 2005] ?
Which C#                [ c#2005 Beta 1]

.. oh, and what are your reference dependencies ?

I haven't had a look at IronPython yet. How have you got it set up. ?
Title: C# Help
Post by: TR on April 11, 2005, 11:13:03 PM
I'm using IronPython-0.7.1, AutoCAD 2005, Visual C# 2005 Express Beta 1 and Pynk.Wrapper (C# wrapper for IronPython that was part of Larry O'Brien's Pynk ( program).

The references are as follows:

If you want to take a look at the entire project Here ( is my project. Please not this is just my early testing to see what I can do so everything is pretty sloppy and all over the place. However I have already "built" the application so you can remap my references to Ironpython and Pynk.Wrapper to the ones in the bin\Release directory.

Also if you're interested in working on something like this by all means let me know. I can use all the help I can get.  :)
Title: C# Help
Post by: Kerry on April 11, 2005, 11:28:19 PM
Thanks Tim

Much appreciated.
I'll have a look at it as soon as I get a chance. Wont be real soon though, as the next few days ... [ you know the story, I'm sure ]

Stay well