.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Registering a command through code.

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
359 Views, 2 Replies

Registering a command through code.

Hi.

I'm wondering if it's possible to register an AutoCAD command through code
without the use of the CommandMethod attribute. If so can anyone point me in
the right direction on how to accomplish this?

Note I'm using AutoCAD 2007.
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Using only managed code you can't do that without
resorting to dynanically generated code, which is not
trivial. Essentially, you would use Reflection.Emit to
dynamically generate and load an assembly that has
a class with the command methods that can delegate
to another static method in your code.

A kludge would be to evaluate LISP that defines a
C:XXXX function that calls a method exported by
your code via [LispFunction]

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"TJRiley" wrote in message news:5664986@discussion.autodesk.com...
Hi.

I'm wondering if it's possible to register an AutoCAD command through code
without the use of the CommandMethod attribute. If so can anyone point me in
the right direction on how to accomplish this?

Note I'm using AutoCAD 2007.
Message 3 of 3
Anonymous
in reply to: Anonymous

Tony:

I am working on an open source tool to embed IronPython[1] in AutoCAD 2007
and newer. I already have sample code that's compiled dynamically[2] and
accesses the managed api. Basically at this point I can access any portion
of the managed api via python code but I have to do it by running a python
file every time. The problem I have is that IronPython doesn't support .NET
attributes. However since I can do anything in python that I could in .NET I
could use python decorators[3] to provide a wrapper to code that would
register as a command if it's possible.

If you want to see what I'm doing for yourself you can get everything from
the projects google code page.

http://code.google.com/p/pyacaddotnet/

binary for AutoCAD 2007 is available under downloads. Source is available
via subversion from the source tab.

[1] http://www.codeplex.com/IronPython
[2] http://pyacaddotnet.googlecode.com/svn/trunk/Samples/winforms2.py
[3] http://wiki.python.org/moin/PythonDecoratorLibrary

Regards,
Tim Riley

"Tony Tanzillo" wrote in message
news:5665195@discussion.autodesk.com...
Using only managed code you can't do that without
resorting to dynanically generated code, which is not
trivial. Essentially, you would use Reflection.Emit to
dynamically generate and load an assembly that has
a class with the command methods that can delegate
to another static method in your code.

A kludge would be to evaluate LISP that defines a
C:XXXX function that calls a method exported by
your code via [LispFunction]

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"TJRiley" wrote in message
news:5664986@discussion.autodesk.com...
Hi.

I'm wondering if it's possible to register an AutoCAD command through code
without the use of the CommandMethod attribute. If so can anyone point me in
the right direction on how to accomplish this?

Note I'm using AutoCAD 2007.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost