Author Topic: AutoCAD 2009 Registering Commands w/o Attributes.  (Read 4643 times)

0 Members and 1 Guest are viewing this topic.

tjr

  • Guest
AutoCAD 2009 Registering Commands w/o Attributes.
« on: March 19, 2009, 11:07:13 PM »
Out of the blue on Tuesday Kean Walmsley dropped me an email asking me about IronPython, AutoCAD and registering commands. This is something I had been struggling with for a while but after a few email exchanges and a tip about a a function hidden in AutoCAD 2009's version of acmgdinternal.dll I was able to come up with a dirt simple solution to this problem.

C# code can be found at: http://paste.pocoo.org/show/108774/
Python code can be found at: http://paste.pocoo.org/show/108775/

That's the code I just sent to Kean. While ugly and hacky it works.

With that being said be on the lookout for a new version of PyAcad.NET targeting AC 2009+ only in the future that allows real registering of commands. Also Kean said he planned on blogging about the topic at some point, so look out for that too.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8662
  • AKA Daniel
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #1 on: March 19, 2009, 11:26:11 PM »
Cool work,  It still executes the file and not a function within a file right?

tjr

  • Guest
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #2 on: March 19, 2009, 11:30:17 PM »
No It now executes a function in the file. If you look at the Utils.AddCommand code at the bottom of the python file it registers the functions "itWorks", and "drawCircle" as commands from the same file.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8662
  • AKA Daniel
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #3 on: March 19, 2009, 11:32:35 PM »
Wow! That’s cool, great work!

tjr

  • Guest
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #4 on: March 19, 2009, 11:34:44 PM »
I wish I could claim it was somehow hard. It's just the AutoCAD .NET API becoming more complete to allow this kind of stuff.

FengK

  • Guest
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #5 on: March 20, 2009, 03:34:04 AM »
I wish I could claim it was somehow hard. It's just the AutoCAD .NET API becoming more complete to allow this kind of stuff.

Still, it sounds exciting: AutoCAD & IronPython.


MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #7 on: March 20, 2009, 03:34:02 PM »
Very cool Tim + congrats on the public "att-a-boy". :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

tjr

  • Guest
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #8 on: March 20, 2009, 06:47:10 PM »
I'm not going to complain about the att-a-boy, as it is nice to get one every once in a while. I am fairly excited about the possibilities available with AC2009 and Ironpython now that registering commands is available. I've been trying to do this for almost 4 years.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #9 on: March 20, 2009, 06:51:40 PM »
Timing is good for me: I'm hooked on (I)Python now. :lol:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

TonyT

  • Guest
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #10 on: March 20, 2009, 09:53:53 PM »
Very cool Tim + congrats on the public "att-a-boy". :)

Yes, congrats on the AddCommand() trick.

   http://www.theswamp.org/index.php?topic=18355.msg314733#msg314733

As Yogi would way, it's like deja vu all over again

 :lmao:


MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #11 on: March 20, 2009, 10:02:39 PM »
For the record the "att-a-boy" was for his Tim's efforts over the years to bring Python to AutoCAD, not one function call. However, if you feel slighted "att-a-boy Tony", genuine thanks for your contributions to said effort. Sincerely, MP.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

tjr

  • Guest
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #12 on: March 21, 2009, 12:14:51 PM »
Very cool Tim + congrats on the public "att-a-boy". :)

Yes, congrats on the AddCommand() trick.

   http://www.theswamp.org/index.php?topic=18355.msg314733#msg314733

As Yogi would way, it's like deja vu all over again

 :lmao:


As I posted over on Kean's blog, your post was 4 days after I got married and internet browsing was the last thing on my mind at that time. I missed a lot of posts then and sadly yours was one of them as it would have been very helpful to me.

tjr

  • Guest
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #13 on: March 21, 2009, 12:16:11 PM »
Timing is good for me: I'm hooked on (I)Python now. :lol:
Production code or still exploring? What kind of stuff are you working on. I'm always interested in what people are using python for.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: AutoCAD 2009 Registering Commands w/o Attributes.
« Reply #14 on: March 21, 2009, 12:31:36 PM »
Timing is good for me: I'm hooked on (I)Python now. :lol:
Production code or still exploring? What kind of stuff are you working on. I'm always interested in what people are using python for.

Rather than working on production code I'm forcing myself to take it slow, starting from simplistic coding, and avoiding IronPython until my vanilla Python is solid.

Recent playing in this thread and this thread.

Don't laugh,  I'm a n00b. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst