TheSwamp

Code Red => .NET => Topic started by: tjr on March 19, 2009, 11:07:13 PM

Title: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: tjr 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.
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: It's Alive! on March 19, 2009, 11:26:11 PM
Cool work,  It still executes the file and not a function within a file right?
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: tjr 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.
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: It's Alive! on March 19, 2009, 11:32:35 PM
Wow! That’s cool, great work!
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: tjr 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.
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: FengK 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.
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: tjr on March 20, 2009, 01:16:53 PM
Here's the link.

http://through-the-interface.typepad.com/through_the_interface/2009/03/using-ironpython-with-autocad.html
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: MP on March 20, 2009, 03:34:02 PM
Very cool Tim + congrats on the public "att-a-boy". :)
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: tjr 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.
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: MP on March 20, 2009, 06:51:40 PM
Timing is good for me: I'm hooked on (I)Python now. :lol:
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: TonyT 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 (http://www.theswamp.org/index.php?topic=18355.msg314733#msg314733)

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

 :lmao:

Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: MP 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.
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: tjr 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 (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.
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: tjr 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.
Title: Re: AutoCAD 2009 Registering Commands w/o Attributes.
Post by: MP 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 (http://www.theswamp.org/index.php?topic=27945.0) thread and this (http://www.theswamp.org/index.php?topic=27943.0;all) thread.

Don't laugh,  I'm a n00b. :)