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

0 Members and 1 Guest are viewing this topic.

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #45 on: August 27, 2007, 07:02:19 AM »
Wow, you have been busy Daniel, there's alot of work there!
I'm afraid though that although I can follow it, this CLI stuff is still a bit greek to me   :-(  :laugh:
"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 #46 on: August 27, 2007, 10:30:16 AM »
Dan:

Wow! That was a lot of work you did, thanks. However when I load your assembly It raises an exception. :(

I see that you ported all the C# code to C++/CLI, but can I still access the function for registering commands from C#? I don't know C++/CLI and there is a lot of stuff I want to do to this project in the future, like stuff with standard paths and eventually hook this code up to IronPython V2 which uses the DLR. If I can plug the DLR into AutoCAD then it might be possible to make Ruby.NET and IronLisp available with not too much trouble as they use the DLR too.

If possible I would also would want to use Python decorators as the method to define a command, instead of placing it at the first line of the file. example:
Code: [Select]
@CommandMethod('testcommand')
def testcommand():
    print "The test command worked"
With the CommandMethod decorator calling back to the C# code to register the command. I'm thinking this shouldn't be hard as C# and IronPython can pass objects back and forth fairly easily.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: Expose ARX Function to .NET
« Reply #47 on: August 27, 2007, 12:31:51 PM »
Quote
..However when I load your assembly It raises an exception
Try this one attached for 2007 & 2008, If you still get the exception, maybe you can attach it so I can debug it. It works well with my machine. Also this one is linked with IronPython 1.1

Quote
..but can I still access the function for registering commands from C#?

You should be able to add commands from C# using

Code: [Select]
PyAcad.CcStorage.StoreCmd(String strCmd ,String path)
Then
PyAcad.CcStorage.RegCmd(String strCmd)

But this .DLL will needed to be netloaded for the reactors to fire. Of course you could also build your own reactors in C#.

Quote
.If possible I would also would want to use Python decorators as the method to define a command 

Sure, All you need to do is search the file for decorators then register the commands, Though did not see any method in IronPython for executing/accessing individual functions within a .py file. I am sure it’s possible, I just didn’t see it.

This is just a start though

TR

  • Guest
Re: Expose ARX Function to .NET
« Reply #48 on: August 27, 2007, 09:47:15 PM »
Dan:

Perhaps I was doing something wrong but I tested the latest version you posted and it seemed to work. Is there any chance I can get you to post a stripped down version of that code that does nothing but handle the registration of AutoCAD commands? If possible I'd like the code to register commands not have any reference to IronPython at all, just provide access to dealing with command registration. This way I can swap out IronPython versions without worrying about updating your C++ code.

I have been trying for the past couple hours to get either your code or Mick's code to compile on my system without any luck. If I could do that then I think I could remove the parts myself. I think it's an issue with the express edition.

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #49 on: August 27, 2007, 10:00:08 PM »
What sort of errors are you getting Tim?
"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 #50 on: August 27, 2007, 10:03:20 PM »
When I try to compile your code I get the following output:

Command Line:
Quote
IronPyCmdReg : warning PRJ0041 : Cannot find missing dependency 'winres.h' for file 'IronPyCmdReg.rc'.  Your project may still build, but may continue to appear out of date until this file is found.

Creating temporary file "c:\Documents and Settings\TJRiley\Desktop\IronPyRegCmds\IronPyCmdReg\Debug\RSP0000011152908.rsp" with contents
[
/Od /I "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include" /I "C:\ObjectARX_2008\inc" /AI "C:\Program Files\AutoCAD 2006" /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "IRONPYCMDREG_MODULE" /D "_ACRXAPP" /D "_VC80_UPGRADE=0x0700" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MD /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W1 /c /Wp64 /ZI /TP ".\StdAfx.cpp"

".\IronPyCmdReg.cpp"

".\DocData.cpp"

".\acrxEntryPoint.cpp"
]
Creating command line "cl.exe @"c:\Documents and Settings\TJRiley\Desktop\IronPyRegCmds\IronPyCmdReg\Debug\RSP0000011152908.rsp" /nologo /errorReport:prompt"

Output Window
Quote
Compiling...
acrxEntryPoint.cpp
     Compiling MFC / STL / ATL header files in release mode.
c:\program files\microsoft visual studio 8\vc\include\use_ansi.h(49) : fatal error C1189: #error :  You have included some C++/C library header files with _DEBUG defined and some with _DEBUG not defined. This will not work correctly. Please have _DEBUG set or clear consistently.
DocData.cpp
     Compiling MFC / STL / ATL header files in release mode.
c:\program files\microsoft visual studio 8\vc\include\use_ansi.h(49) : fatal error C1189: #error :  You have included some C++/C library header files with _DEBUG defined and some with _DEBUG not defined. This will not work correctly. Please have _DEBUG set or clear consistently.
IronPyCmdReg.cpp
     Compiling MFC / STL / ATL header files in release mode.
c:\program files\microsoft visual studio 8\vc\include\use_ansi.h(49) : fatal error C1189: #error :  You have included some C++/C library header files with _DEBUG defined and some with _DEBUG not defined. This will not work correctly. Please have _DEBUG set or clear consistently.
StdAfx.cpp
     Compiling MFC / STL / ATL header files in release mode.
c:\program files\microsoft visual studio 8\vc\include\use_ansi.h(49) : fatal error C1189: #error :  You have included some C++/C library header files with _DEBUG defined and some with _DEBUG not defined. This will not work correctly. Please have _DEBUG set or clear consistently.
Generating Code...

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #51 on: August 27, 2007, 10:05:54 PM »
Did you create a new solution from scratch or copy in my files from the vs2002 sln?
"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 #52 on: August 27, 2007, 10:12:57 PM »
I loaded your solution and changed the paths to the headers. When I try to create a new solution in C++ Express Edition I can't even build an empty project. I keep getting the error
Code: [Select]
LINK : fatal error LNK1104: cannot open file 'mfcs80u.lib' Which I assume is the unicode mfc lib. I  downloaded the platform sdk but it doesn't contain that lib in it.
« Last Edit: August 27, 2007, 10:14:00 PM by Tim Riley »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: Expose ARX Function to .NET
« Reply #53 on: August 27, 2007, 10:26:28 PM »
You bet, I will also remove MFC support, so you should be able to compile with the express version

TR

  • Guest
Re: Expose ARX Function to .NET
« Reply #54 on: August 27, 2007, 10:33:52 PM »
Thanks Daniel.

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: Expose ARX Function to .NET
« Reply #55 on: August 27, 2007, 10:38:59 PM »
Sorry I can't help Tim, if you can get Daniel's to compile, copy and paste that one function (RegPyCmd) into the acrxentrypoint.cpp as noted before, it 'should' compile. The only difference may be if they changed the function signature to take unicode strings(?). You will have two options to register commands then ;)
"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 #56 on: August 27, 2007, 10:51:18 PM »
I'll give it a shot Mick. I appreciate all the effort.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: Expose ARX Function to .NET
« Reply #57 on: August 27, 2007, 11:30:26 PM »
try this  :-o

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Expose ARX Function to .NET
« Reply #58 on: August 27, 2007, 11:36:48 PM »

I haven't had a chance to follow this conversation ...

putting IronPython aside for a sec' ..
Have you guys posted a solution for MSc# with an arx function ??
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 #59 on: August 27, 2007, 11:52:41 PM »
Dan:

So I would pass this a delegate from C#? It says it only accept a string.