Author Topic: Expose ARX Function to .NET  (Read 37413 times)

0 Members and 1 Guest are viewing this topic.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #90 on: August 28, 2007, 11:43:59 PM »
I take it that you are not getting an error when running regcmds then Tim?

Dan, could you compile it using std 'char's instead of ACHAR's, there's something screwy going on with the strings I think.

The reason I think ACHAR may not work is that the command stack may not be updated for unicode, while arx has made many changes to the way strings are handled as input etc, to change every instance of a char* would be some feat!
Another thing to consider is what is happening to the strings when passed from .net which is unicode by default if I remember correctly, just a thought.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #91 on: August 28, 2007, 11:52:17 PM »
Maybe a cast the param's to char* in the acedRegCmd function would do the trick even??
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: Expose ARX Function to .NET
« Reply #92 on: August 28, 2007, 11:55:52 PM »
I tried and got

Error   1   error C2664: 'AcEdCommandStack::addCommand' : cannot convert parameter 1 from 'const char *' to 'const ACHAR *'
                   c:\PyRegCmd\PyRegCmd\acrxEntryPoint.cpp   39   

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: Expose ARX Function to .NET
« Reply #93 on: August 28, 2007, 11:58:37 PM »
Well, I am off to Disneyland. we need another volunteer for the night shift  :-D
be back later

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #94 on: August 29, 2007, 12:08:05 AM »
Thanks Daniel, I'm downloading vc2005xpress now, then the platform sdk, then the arx sdk, you will probably having breakfast by the time I'm done :D.
I'll see if I can nut something out at this end then although I can't test as I don't have ac2008.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

TR

  • Guest
Re: Expose ARX Function to .NET
« Reply #95 on: August 29, 2007, 12:15:23 AM »
Mick:
Yes, I'm not getting any errors at the command line. I appreciate any help I can get getting this going too.

As far as not having 2008 goes if you're really interested you can snag the 30 day trial.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #96 on: August 29, 2007, 12:21:25 AM »
Tim, try adding the bold text below to the DllImport -

Quote
[DllImport("PyRegCmd.dll",
          CallingConvention=CallingConvention.Cdecl,CharSet = CharSet.Unicode,
          EntryPoint = "?RegPyCmd@@YAXPB_W0HP6AXXZ@Z")]
      public static extern void RegPyCmd(
         string cmd_group,
         string cmd_name,
         Autodesk.AutoCAD.Runtime.CommandFlags cmd_flags,
         [MarshalAs(UnmanagedType.FunctionPtr)] PyAcadCmd.CmdDelegate cmd_delegate);

If that works you can thank Luis, I just noticed it in his latest thread ;)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

TR

  • Guest
Re: Expose ARX Function to .NET
« Reply #97 on: August 29, 2007, 12:27:45 AM »
Oh heck yes!!!!!!!


Here's the command line output:
Quote
AutoCAD menu utilities loaded.
Command: netload
Assembly file name: "C:/Documents and Settings/TJRiley/My
Documents/pyacaddotnet/bin/Debug/PyAcadDotNet.dll"

PyAcad.NET Loaded Successfully....
type 'pyhelp' for commands....Enter BACKSPACE to interrupt script.

Command: DASHBOARD

Command: regcmds

Register command was called, but does it work?

Command: tester

cb1 delegate seems to work!

You guys are the greatest.

Mick, Dan and Luis please PM me your info that you'd like posted in the credits section of the project.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #98 on: August 29, 2007, 12:39:18 AM »
Woot! Great news!

'nothing like learning on the run :D
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: Expose ARX Function to .NET
« Reply #99 on: August 29, 2007, 04:13:08 AM »
Quote
…CharSet.Unicode…

thought of this while I was standing in line for Space Mountain, Awesome  8-)

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: Expose ARX Function to .NET
« Reply #100 on: August 29, 2007, 04:59:26 AM »
And here is the alternative method.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Expose ARX Function to .NET
« Reply #101 on: August 29, 2007, 10:02:17 PM »
I've been trying for the past hour to get the C++ dll with the changes Mick noted above without any luck. I keep getting missing "mfc80u.lib" errors in visual C++ 2005 express.

Dan: can you bail me out again?

This may be unrelated.

We have had to update most work machines with vcredist_x86.exe
from http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en
to ensure that the runtime support dll's for our Cpp stuff are up to date.

Quote
The Microsoft Visual C++ 2005 Redistributable Package (x86) installs runtime components of Visual C++ Libraries required to run applications developed with Visual C++ on a computer that does not have Visual C++ 2005 installed.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

TR

  • Guest
Re: Expose ARX Function to .NET
« Reply #102 on: August 29, 2007, 10:10:01 PM »
Thanks Kerry. I'll give it a shot.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #103 on: August 25, 2008, 11:14:00 PM »
Quote from: From the pyacad.net download readme
Currently the only way to bind a python file to an AutoCAD command is to do so via lisp. For this we have added a lisp command called "runpyfile". The runpyfile returns (T) on success (nil) on error.

didn't we have a workable solution to this?

I can see why you may want to run a whole script at times but this also could be done via a command.

I have been thinking on this since I wrote the other command stack for pyarx stuff, thought I'd re-visit it and clean it up so it automatically loads your commands from an init file say
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

tjr

  • Guest
Re: Expose ARX Function to .NET
« Reply #104 on: August 26, 2008, 12:43:42 AM »
Quote from: From the pyacad.net download readme
Currently the only way to bind a python file to an AutoCAD command is to do so via lisp. For this we have added a lisp command called "runpyfile". The runpyfile returns (T) on success (nil) on error.

didn't we have a workable solution to this?

I can see why you may want to run a whole script at times but this also could be done via a command.

I have been thinking on this since I wrote the other command stack for pyarx stuff, thought I'd re-visit it and clean it up so it automatically loads your commands from an init file say
Not as of yet. I'm hoping you can help me out though. :)