Author Topic: C# Help  (Read 1495 times)

0 Members and 1 Guest are viewing this topic.

TR

  • Guest
C# Help
« 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;

#endregion

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);
            CommandLinePrompts.Message(results);
        }
    }
   
   public class PyAcad
    {
       public PyAcad()
       {
       }
       public string pythonstring(string Args)
       {
           FrameHolder pyacad = new FrameHolder();
           OutputQueue results = new OutputQueue();
           pyacad.ParseAndRun(Args);
           string returnstring = results.ReadToEnd();
           return returnstring;
         
       }
    }

}

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
C# Help
« Reply #1 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. ?
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

TR

  • Guest
C# Help
« Reply #2 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:
acdbmgd
acmgd
IronPython
Pynk.Wrapper
stdole
System
System.Data
System.XML

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.  :)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
C# Help
« Reply #3 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
kwb
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--